Module: QueryPackwerk

Extended by:
QueryPackwerk, T::Sig
Included in:
QueryPackwerk
Defined in:
lib/query_packwerk.rb,
lib/query_packwerk/cli.rb,
lib/query_packwerk/console.rb,
lib/query_packwerk/package.rb,
lib/query_packwerk/version.rb,
lib/query_packwerk/packages.rb,
lib/query_packwerk/violation.rb,
lib/query_packwerk/file_cache.rb,
lib/query_packwerk/violations.rb,
lib/query_packwerk/rule_rewriter.rb,
lib/query_packwerk/query_interface.rb,
lib/query_packwerk/rule_rewriter/base_rule.rb,
lib/query_packwerk/rule_rewriter/rule_set_rewriter.rb,
lib/query_packwerk/rule_rewriter/anonymize_arguments_rule.rb,
lib/query_packwerk/rule_rewriter/anonymize_keyword_arguments_rule.rb

Overview

typed: false frozen_string_literal: true

Defined Under Namespace

Modules: ConsoleHelpers, QueryInterface Classes: CLI, Console, FileCache, Package, Packages, RuleRewriter, Violation, Violations

Constant Summary collapse

VERSION =
'0.1.0'

Instance Method Summary collapse

Instance Method Details

#anonymous_violation_counts_for(pack_name, threshold: 0) ⇒ Object



69
70
71
# File 'lib/query_packwerk.rb', line 69

def anonymous_violation_counts_for(pack_name, threshold: 0)
  violations_for(pack_name).anonymous_source_counts(threshold: threshold)
end

#anonymous_violation_sources_for(pack_name) ⇒ Object



63
64
65
# File 'lib/query_packwerk.rb', line 63

def anonymous_violation_sources_for(pack_name)
  violations_for(pack_name).anonymous_sources
end

#consumers(pack_name, threshold: 0) ⇒ Object



75
76
77
# File 'lib/query_packwerk.rb', line 75

def consumers(pack_name, threshold: 0)
  violations_for(pack_name).consumers(threshold: threshold)
end

#full_name(pack_name) ⇒ Object



81
82
83
84
85
# File 'lib/query_packwerk.rb', line 81

def full_name(pack_name)
  return pack_name if pack_name.match?(%r{\A(packs|components)/})

  "packs/#{pack_name}"
end

#package(name) ⇒ Object



31
32
33
# File 'lib/query_packwerk.rb', line 31

def package(name)
  Packages.where(name: name).first
end

#reload!Object



88
89
90
91
# File 'lib/query_packwerk.rb', line 88

def reload!
  Packages.reload!
  Violations.reload!
end

#todos_for(pack_name) ⇒ Object



45
46
47
# File 'lib/query_packwerk.rb', line 45

def todos_for(pack_name)
  QueryPackwerk::Violations.where(consuming_pack: full_name(pack_name))
end

#violation_counts_for(pack_name, threshold: 0) ⇒ Object



57
58
59
# File 'lib/query_packwerk.rb', line 57

def violation_counts_for(pack_name, threshold: 0)
  violations_for(pack_name).source_counts(threshold: threshold)
end

#violation_sources_for(pack_name) ⇒ Object



51
52
53
# File 'lib/query_packwerk.rb', line 51

def violation_sources_for(pack_name)
  violations_for(pack_name).sources_with_locations
end

#violations_for(pack_name) ⇒ Object



38
39
40
# File 'lib/query_packwerk.rb', line 38

def violations_for(pack_name)
  QueryPackwerk::Violations.where(producing_pack: full_name(pack_name))
end