jez 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,84 @@
1
+ require "ripper"
2
+
3
+ module RubyQuality
4
+ module Measures
5
+ # Baseline both the named cops and the number of lines their directives cover.
6
+ # Strings are ignored; existing exemptions may remain but may not broaden.
7
+ class Disables
8
+ DIRECTIVE = /\A#\s*rubocop:(disable|todo|enable)\s+(.+)/
9
+
10
+ # Counts directives and tracks their per-line coverage in source order.
11
+ class Coverage
12
+ attr_reader :totals
13
+
14
+ def initialize
15
+ @totals = Hash.new(0)
16
+ @active = Set.new
17
+ end
18
+
19
+ def count(line, directive)
20
+ covered = @active.dup
21
+ case directive&.action
22
+ when "enable" then enable(directive.cops)
23
+ when "disable", "todo" then covered.merge(disable(line, directive))
24
+ end
25
+ covered.each { |cop| @totals[[cop, "lines"]] += 1 }
26
+ end
27
+
28
+ private
29
+
30
+ def enable(cops)
31
+ cops.include?("all") ? @active.clear : @active.subtract(cops)
32
+ end
33
+
34
+ def disable(line, directive)
35
+ cops = directive.cops
36
+ cops.each { |cop| @totals[[cop, "directives"]] += 1 }
37
+ @active.merge(cops) if directive.standalone?(line)
38
+ cops
39
+ end
40
+ end
41
+
42
+ # A comment's action, named cops, and location on its source line.
43
+ Directive = Data.define(:action, :cops, :column) do
44
+ def standalone?(line) = line[0...column].strip.empty?
45
+ end
46
+
47
+ def baselined? = true
48
+
49
+ def observe(sources)
50
+ sources.flat_map do |source|
51
+ counts(source.content).map do |(cop, kind), count|
52
+ Observation.new(path: source.path, context: FILE_CONTEXT,
53
+ measure: "rubocop disables #{cop} #{kind}", value: count)
54
+ end
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def counts(content)
61
+ by_line = directives(content)
62
+ coverage = Coverage.new
63
+ content.each_line.with_index(1) do |line, number|
64
+ coverage.count(line, by_line[number])
65
+ end
66
+ coverage.totals
67
+ end
68
+
69
+ def directives(content)
70
+ Ripper.lex(content).filter_map do |(line, column), type, text, _state|
71
+ directive = parse_directive(text, column) if type == :on_comment
72
+ [line, directive] if directive
73
+ end.to_h
74
+ end
75
+
76
+ def parse_directive(text, column)
77
+ if (match = DIRECTIVE.match(text))
78
+ cops = match[2].split(/\s+--/, 2).first.split(/[\s,]+/)
79
+ Directive.new(action: match[1], cops:, column:)
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,52 @@
1
+ require "fileutils"
2
+ require "tmpdir"
3
+
4
+ module RubyQuality
5
+ module Measures
6
+ # Flay duplication across the whole scope. Flay reads only files on disk and
7
+ # silently skips missing ones, so the sources are written to a scratch tree first.
8
+ class Flay
9
+ ITEM = /^\d+\) (?<similarity>\w+) code found in (?<node>:\w+) \(mass(?:\*\d+)? = (?<mass>\d+)\)/
10
+ LOCATION = /^\s+(\S+:\d+)/
11
+
12
+ def initialize(toolchain:, mass:)
13
+ @toolchain = toolchain
14
+ @mass = mass
15
+ end
16
+
17
+ def baselined? = false
18
+
19
+ def observe(sources)
20
+ return [] if sources.empty?
21
+
22
+ items(report(sources)).map { |header, locations| observation(header, locations) }
23
+ end
24
+
25
+ private
26
+
27
+ def report(sources)
28
+ Dir.mktmpdir("ruby-quality-flay") do |directory|
29
+ sources.each { |source| write(directory, source) }
30
+ @toolchain.run("flay", "--mass", @mass.to_s, *sources.map(&:path), directory:)
31
+ end
32
+ end
33
+
34
+ def write(directory, source)
35
+ path = File.join(directory, source.path)
36
+ FileUtils.mkdir_p(File.dirname(path))
37
+ File.write(path, source.content)
38
+ end
39
+
40
+ def items(report)
41
+ report.split(/^(?=\d+\) )/).filter_map do |chunk|
42
+ ITEM.match(chunk)&.then { |header| [header, chunk.scan(LOCATION).flatten] }
43
+ end
44
+ end
45
+
46
+ def observation(header, locations)
47
+ Observation.new(path: locations.first.sub(/:\d+\z/, ""), context: locations.join(", "), measure: "flay",
48
+ value: header[:mass].to_i, details: ["#{header[:similarity].downcase} #{header[:node]}"])
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,33 @@
1
+ module RubyQuality
2
+ module Measures
3
+ # Flog complexity per method, held to a threshold rather than to zero.
4
+ # Flog omits methods that score near zero, so a missing base entry reads as zero.
5
+ class Flog
6
+ METHOD_SCORE = /^\s*(?<score>\d+\.\d+): (?<context>\S+)\s+-:(?<lines>\d+(?:-\d+)?)$/
7
+
8
+ def initialize(toolchain:, limit:)
9
+ @toolchain = toolchain
10
+ @limit = limit
11
+ end
12
+
13
+ def baselined? = false
14
+
15
+ def observe(sources)
16
+ sources.flat_map { |source| observations_for(source) }
17
+ end
18
+
19
+ private
20
+
21
+ def observations_for(source)
22
+ @toolchain.run("flog", "--all", "-", stdin: source.content).each_line.filter_map do |line|
23
+ METHOD_SCORE.match(line)&.then { |score| observation(source.path, score) }
24
+ end
25
+ end
26
+
27
+ def observation(path, score)
28
+ Observation.new(path:, context: score[:context], measure: "flog", value: score[:score].to_f,
29
+ limit: @limit, details: ["lines #{score[:lines]}"])
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,49 @@
1
+ require "json"
2
+ require "pathname"
3
+
4
+ module RubyQuality
5
+ module Measures
6
+ # Reek smells counted per method or class context. Reek reads .reek.yml only
7
+ # from its working directory, so each file is checked from the directory of
8
+ # its nearest config, which lets a carved area carry its own.
9
+ class Reek
10
+ CONFIG = ".reek.yml".freeze
11
+
12
+ def initialize(toolchain:)
13
+ @toolchain = toolchain
14
+ @root = Pathname(toolchain.directory)
15
+ end
16
+
17
+ def baselined? = false
18
+
19
+ def observe(sources)
20
+ sources.flat_map { |source| observations_for(source.path, smells(source)) }
21
+ end
22
+
23
+ private
24
+
25
+ def smells(source)
26
+ path = Pathname(source.path)
27
+ home = config_home(path)
28
+ report = @toolchain.run("reek", "--format", "json", "--stdin-filename", path.relative_path_from(home).to_s,
29
+ stdin: source.content, accept: [0, 2], directory: (@root + home).to_s)
30
+ JSON.parse(report)
31
+ end
32
+
33
+ def config_home(path)
34
+ path.dirname.ascend.find { |directory| (@root + directory + CONFIG).file? } || Pathname(".")
35
+ end
36
+
37
+ def observations_for(path, smells)
38
+ smells.group_by { |smell| smell.values_at("context", "smell_type") }.map do |(context, type), group|
39
+ Observation.new(path:, context:, measure: "reek #{type}", value: group.size,
40
+ details: group.map { |smell| describe(smell) })
41
+ end
42
+ end
43
+
44
+ def describe(smell)
45
+ "line #{smell.fetch("lines").join(", ")}: #{smell.fetch("message")}"
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,42 @@
1
+ require "json"
2
+
3
+ module RubyQuality
4
+ # Each measure plays one role: #observe(sources) returns Observations, and
5
+ # #baselined? says whether even a strict gate compares it to the base revision.
6
+ module Measures
7
+ FILE_CONTEXT = "(file)".freeze
8
+
9
+ # RuboCop offenses counted per cop and file; counts survive the line shifts that offsets would not.
10
+ # RuboCop finds the nearest .rubocop.yml from the path it is given, so nested configs apply.
11
+ class Rubocop
12
+ def initialize(toolchain:)
13
+ @toolchain = toolchain
14
+ end
15
+
16
+ def baselined? = false
17
+
18
+ def observe(sources)
19
+ sources.flat_map { |source| observations_for(source.path, offenses(source)) }
20
+ end
21
+
22
+ private
23
+
24
+ def offenses(source)
25
+ report = @toolchain.run("rubocop", "--format", "json", "--force-exclusion", "--stdin", source.path,
26
+ stdin: source.content, accept: [0, 1])
27
+ JSON.parse(report).fetch("files").flat_map { |file| file.fetch("offenses") }
28
+ end
29
+
30
+ def observations_for(path, offenses)
31
+ offenses.group_by { |offense| offense.fetch("cop_name") }.map do |cop, group|
32
+ Observation.new(path:, context: FILE_CONTEXT, measure: "rubocop #{cop}", value: group.size,
33
+ details: group.map { |offense| describe(offense) })
34
+ end
35
+ end
36
+
37
+ def describe(offense)
38
+ "line #{offense.dig("location", "start_line")}: #{offense.fetch("message")}"
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,23 @@
1
+ module RubyQuality
2
+ # A measured value for one context in one file, and the limit it may not exceed.
3
+ # Counts of smells and offenses have a limit of zero; scores carry their own threshold.
4
+ Observation = Data.define(:path, :context, :measure, :value, :limit, :details) do
5
+ def initialize(path:, context:, measure:, value:, limit: 0, details: [])
6
+ super
7
+ end
8
+
9
+ def key = [path, context, measure]
10
+
11
+ def over_limit? = value > limit
12
+
13
+ def regressed_from?(previous) = over_limit? && value > previous
14
+
15
+ def heading = "#{context} #{measure}"
16
+
17
+ # Shows any value of this measure the way the measure is scored: counts as
18
+ # integers, scores to one decimal place.
19
+ def display(number = value) = limit.is_a?(Float) ? format("%.1f", number) : number.to_s
20
+
21
+ def against_limit = "#{display} (limit #{display(limit)})"
22
+ end
23
+ end
@@ -0,0 +1,52 @@
1
+ require "optparse"
2
+
3
+ module RubyQuality
4
+ # The parsed command line: which gate, against which base, with which limits, over which paths.
5
+ Options = Data.define(:gate, :base, :flog_limit, :flay_mass, :paths)
6
+
7
+ # Parsing and the measures the options configure.
8
+ class Options
9
+ BANNER = "Usage: jez check [--strict] [--base REVISION] [--flog-limit SCORE] " \
10
+ "[--flay-mass MASS] [PATH...]".freeze
11
+ DEFAULTS = { base: "HEAD", flog_limit: 20.0, flay_mass: 16 }.freeze
12
+
13
+ def self.parse(argv)
14
+ settings = DEFAULTS.dup
15
+ paths = parser(settings).parse(argv)
16
+ gate = Gate.named(settings.delete(:strict) ? "strict" : "ratchet")
17
+ new(gate:, paths:, **settings)
18
+ rescue OptionParser::ParseError, UsageError => error
19
+ raise UsageError.with_banner(error, BANNER)
20
+ end
21
+
22
+ def self.parser(settings)
23
+ OptionParser.new(BANNER) do |parser|
24
+ parser.on("--strict", "Check the scope against the quality thresholds") { settings[:strict] = true }
25
+ parser.on("--base REVISION", "Compare against REVISION (default HEAD)") { |value| settings[:base] = value }
26
+ add_thresholds(parser, settings)
27
+ end
28
+ end
29
+
30
+ def self.add_thresholds(parser, settings)
31
+ parser.on("--flog-limit SCORE", Float, "Highest Flog score a method may have (default 20)") do |value|
32
+ settings[:flog_limit] = value
33
+ end
34
+ parser.on("--flay-mass MASS", Integer, "Smallest duplicated mass Flay reports (default 16)") do |value|
35
+ settings[:flay_mass] = value
36
+ end
37
+ end
38
+ private_class_method :parser, :add_thresholds
39
+
40
+ def measures(toolchain)
41
+ gate.measures(
42
+ per_file: [
43
+ Measures::Rubocop.new(toolchain:),
44
+ Measures::Reek.new(toolchain:),
45
+ Measures::Flog.new(toolchain:, limit: flog_limit),
46
+ Measures::Disables.new
47
+ ],
48
+ across_files: [Measures::Flay.new(toolchain:, mass: flay_mass)]
49
+ )
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,35 @@
1
+ module RubyQuality
2
+ # Renders a check result as a compact delta: one line per finding, grouped by
3
+ # file, with at most a few details each so the output stays readable in context.
4
+ class Report
5
+ DETAILS_SHOWN = 3
6
+
7
+ def initialize(result)
8
+ @result = result
9
+ end
10
+
11
+ def to_s
12
+ findings = @result.findings
13
+ body = findings.group_by { |finding| finding.observation.path }.flat_map { |path, group| section(path, group) }
14
+ [headline(findings.size), *body].join("\n") << "\n"
15
+ end
16
+
17
+ private
18
+
19
+ def headline(count)
20
+ command = @result.gate == "strict" ? "jez check --strict" : "jez check"
21
+ summary = "#{command} against #{@result.base}, #{plural(@result.paths.size, "file")}"
22
+ @result.passed? ? "#{summary}: no findings" : "#{summary}: #{plural(count, "finding")}"
23
+ end
24
+
25
+ def section(path, findings)
26
+ [path, *findings.flat_map { |finding| lines(finding) }]
27
+ end
28
+
29
+ def lines(finding)
30
+ [" #{finding}", *finding.observation.details.first(DETAILS_SHOWN).map { |detail| " #{detail}" }]
31
+ end
32
+
33
+ def plural(count, noun) = "#{count} #{noun}#{"s" unless count == 1}"
34
+ end
35
+ end
@@ -0,0 +1,76 @@
1
+ require "pathname"
2
+
3
+ module RubyQuality
4
+ # The git working tree under analysis: which Ruby files are in scope, and what
5
+ # each held at the base revision.
6
+ class Repository
7
+ RUBY_FILE = /(\.rb|\.rake|Rakefile|Gemfile)\z/
8
+
9
+ def self.discover(directory:, shell: Shell.new)
10
+ root = shell.run("git", "rev-parse", "--show-toplevel", chdir: directory).output do
11
+ raise UsageError, "#{directory} is not inside a git repository"
12
+ end
13
+ new(root: root.strip, shell:)
14
+ end
15
+
16
+ attr_reader :root
17
+
18
+ def initialize(root:, shell: Shell.new)
19
+ @root = root
20
+ @shell = shell
21
+ end
22
+
23
+ def verify(revision)
24
+ return if git_result("rev-parse", "--verify", "--quiet", "#{revision}^{commit}").success?
25
+
26
+ raise UsageError, "unknown base revision #{revision}"
27
+ end
28
+
29
+ # Explicit paths, relative to the caller's directory, or else every Ruby file changed since the base.
30
+ def scope(paths:, base:, from:)
31
+ return changed_ruby_files(base) if paths.empty?
32
+
33
+ relative = paths.map { |path| relative_to_root(File.expand_path(path, from)) }
34
+ files = ruby_files(git("ls-files", "-z", "--cached", "--others", "--exclude-standard", "--", *relative))
35
+ raise UsageError, "explicit paths selected no Ruby files" if files.empty?
36
+
37
+ files
38
+ end
39
+
40
+ def current(path)
41
+ Source.new(path:, content: File.read(File.join(root, path)))
42
+ end
43
+
44
+ def at(revision, path)
45
+ content = git_result("show", "#{revision}:#{path}").output { return }
46
+ Source.new(path:, content:)
47
+ end
48
+
49
+ private
50
+
51
+ def changed_ruby_files(base)
52
+ tracked = git("diff", "-z", "--name-only", "--diff-filter=d", base, "--")
53
+ ruby_files(tracked + git("ls-files", "-z", "--others", "--exclude-standard"))
54
+ end
55
+
56
+ def ruby_files(listing)
57
+ listing.split("\0").grep(RUBY_FILE).uniq.select { |path| File.file?(File.join(root, path)) }.sort
58
+ end
59
+
60
+ def relative_to_root(path)
61
+ raise UsageError, "#{path} does not exist" unless File.exist?(path)
62
+
63
+ Pathname(File.realpath(path)).relative_path_from(Pathname(File.realpath(root))).to_s
64
+ end
65
+
66
+ def git(*arguments)
67
+ git_result(*arguments).output do |failure|
68
+ raise ToolError, "git #{arguments.first} failed: #{failure.stderr.strip}"
69
+ end
70
+ end
71
+
72
+ def git_result(*)
73
+ @shell.run("git", *, chdir: root)
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,21 @@
1
+ require "open3"
2
+
3
+ module RubyQuality
4
+ # Runs external commands; the only place the program touches the operating system.
5
+ class Shell
6
+ # What a finished command printed and how it exited.
7
+ Result = Data.define(:stdout, :stderr, :exit_code) do
8
+ def success? = exit_code.zero?
9
+
10
+ # The command's output when it succeeded; otherwise whatever the block makes of the failure.
11
+ def output = success? ? stdout : yield(self)
12
+ end
13
+
14
+ def run(*argv, chdir:, stdin: "", env: {})
15
+ stdout, stderr, status = Open3.capture3(env, *argv, stdin_data: stdin, chdir:)
16
+ Result.new(stdout:, stderr:, exit_code: status.exitstatus)
17
+ rescue SystemCallError => error
18
+ raise ToolError, "#{argv.first}: #{error.message}"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ module RubyQuality
2
+ # One revision of a Ruby file: its repository-relative path and its text.
3
+ Source = Data.define(:path, :content)
4
+ end
@@ -0,0 +1,44 @@
1
+ module RubyQuality
2
+ # RuboCop shares the project's bundle and Ruby so its plugins can load.
3
+ # Other analyzers, and projects without a bundle, use jez's pinned gems.
4
+ class Toolchain
5
+ GEMFILE = File.expand_path("../../Gemfile", __dir__)
6
+ INHERITED_BUNDLER = %w[RUBYOPT RUBYLIB BUNDLER_SETUP BUNDLER_VERSION].freeze
7
+ PROJECT_RUBY = { "GEM_HOME" => nil, "GEM_PATH" => nil }.freeze
8
+
9
+ attr_reader :directory
10
+
11
+ def initialize(directory:, shell: Shell.new, gemfile: GEMFILE)
12
+ @directory = directory
13
+ @shell = shell
14
+ @gemfile = gemfile
15
+ end
16
+
17
+ def run(tool, *, stdin: "", accept: [0], directory: @directory)
18
+ command, env = invocation(tool)
19
+ result = @shell.run(*command, *, stdin:, env:, chdir: directory)
20
+ return result.stdout if accept.include?(result.exit_code)
21
+
22
+ raise ToolError, "#{tool} exited #{result.exit_code}: #{result.stderr.lines.first(5).join.strip}"
23
+ end
24
+
25
+ private
26
+
27
+ def invocation(tool)
28
+ if (project = tool == "rubocop" && project_gemfile)
29
+ [["mise", "-C", @directory, "exec", "--", "bundle", "exec", tool], environment(project).merge(PROJECT_RUBY)]
30
+ else
31
+ [["bundle", "exec", tool], environment(@gemfile)]
32
+ end
33
+ end
34
+
35
+ def project_gemfile
36
+ %w[gems.rb Gemfile].map { |name| File.join(@directory, name) }.find { |path| File.file?(path) }
37
+ end
38
+
39
+ def environment(gemfile)
40
+ names = INHERITED_BUNDLER + ENV.keys.grep(/\ABUNDLE_/)
41
+ names.to_h { |name| [name, nil] }.merge("BUNDLE_GEMFILE" => gemfile)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,16 @@
1
+ require "ruby_quality/errors"
2
+ require "ruby_quality/source"
3
+ require "ruby_quality/observation"
4
+ require "ruby_quality/shell"
5
+ require "ruby_quality/toolchain"
6
+ require "ruby_quality/repository"
7
+ require "ruby_quality/measures/rubocop"
8
+ require "ruby_quality/measures/reek"
9
+ require "ruby_quality/measures/flog"
10
+ require "ruby_quality/measures/flay"
11
+ require "ruby_quality/measures/disables"
12
+ require "ruby_quality/gate"
13
+ require "ruby_quality/options"
14
+ require "ruby_quality/check"
15
+ require "ruby_quality/report"
16
+ require "ruby_quality/cli"
data/mise.toml ADDED
@@ -0,0 +1,2 @@
1
+ [tools]
2
+ ruby = "4.0"
@@ -0,0 +1,43 @@
1
+ # Ruby design decisions
2
+
3
+ ## How can we change existing code safely?
4
+
5
+ Find a caller that observes the behavior at risk.
6
+ A characterization test can pin its result, side effect, or error.
7
+ When an external dependency makes that observation unreliable, look for the narrowest place to substitute it.
8
+ An existing method argument or collaborator may already provide the seam.
9
+ [*Working Effectively with Legacy Code*](https://www.informit.com/store/working-effectively-with-legacy-code-9780131177055) develops this approach.
10
+
11
+ When setup and behavior changes are hard to review together, identify a behavior-preserving transformation you can verify on its own.
12
+ Do it first if it simplifies the requested edit.
13
+ Defer it if the behavioral change will remove the awkward code anyway.
14
+ [*Refactoring*](https://martinfowler.com/books/refactoring.html) informs the transformation and [*Tidy First?*](https://www.oreilly.com/library/view/tidy-first/9781098151232/) informs the sequencing.
15
+
16
+ ## Which object should own this decision?
17
+
18
+ Write the call as the consumer would use it.
19
+ Inspect what the consumer must know to make the call.
20
+ If several callers repeatedly fetch state and apply the same domain rule, consider putting the decision with the object responsible for that rule.
21
+ If the callers need different policies, keep that variation visible.
22
+ [*Practical Object-Oriented Design in Ruby*](https://www.poodr.com/) (POODR) guides this responsibility and dependency analysis.
23
+
24
+ For a new capability, drive a thin slice from its public interface to an observable result.
25
+ If a test double introduces a collaborator, check that the real collaborator supports the same message and semantics.
26
+ A test that dictates a sequence of internal calls can make a harmless refactor look like a regression.
27
+ [*Growing Object-Oriented Software, Guided by Tests*](https://www.informit.com/store/growing-object-oriented-software-guided-by-tests-9780321503626) (GOOS), chapters 4 and 20, covers the first end-to-end slice and the design feedback revealed by excessive mock expectations.
28
+
29
+ ## Has an abstraction earned its cost?
30
+
31
+ Compare the concrete cases and identify the rule they actually share.
32
+ If one requirement would change both for the same reason, give that rule a name and a single owner.
33
+ If the similarity is incidental, keeping the implementations separate lets each evolve independently.
34
+ [*99 Bottles of OOP*](https://sandimetz.com/99bottles) develops this progression from concrete code to an abstraction.
35
+
36
+ When two designs satisfy the request, compare the cost of changing course.
37
+ An adapter earns its place when it contains a real interface mismatch.
38
+ An injected dependency earns its place when a caller or test needs to substitute it.
39
+ Count the extra concepts a maintainer must understand alongside the edits the design saves.
40
+ This applies the ease-of-change criterion from [*The Pragmatic Programmer*](https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/).
41
+
42
+ In a design review, point to the actual caller, dependency, contract, or edit that supports the choice.
43
+ Mention a source when it helps explain the technique.
@@ -0,0 +1,37 @@
1
+ # Ruby diagnostics
2
+
3
+ Run the commands from the target project.
4
+ Capture the base before editing and retain it across commits.
5
+
6
+ ```sh
7
+ BASE_SHA=$(git rev-parse HEAD)
8
+ jez check --base "$BASE_SHA"
9
+ jez check --strict --base "$BASE_SHA" "$SCOPE_PATH"
10
+ ```
11
+
12
+ Set `SCOPE_PATH` to the boundary under review.
13
+ The default check reports regressions relative to the base, which defaults to `HEAD`.
14
+ Use `--strict` to check findings across the selected scope against their thresholds, including duplication.
15
+ Suppression counts still use the base.
16
+ With no paths, both modes select Ruby files changed since the base.
17
+ Explicit paths selecting no Ruby files are an error.
18
+
19
+ If you use the skill from a checkout or an agent skills directory, run `"$JEZ_DIR/exe/jez" check` with the same options, where `JEZ_DIR` is the skill directory.
20
+ See [setup](setup.md#enable-the-optional-diagnostics) to provision the analyzers.
21
+
22
+ Exit codes are 0 for no findings, 1 for findings, and 2 for a usage or tool error.
23
+ Their findings are advisory design evidence unless the project explicitly makes that check mandatory.
24
+ A tool error means “not measured,” never “clean.” Tests are run separately.
25
+
26
+ For each material finding, fix it or record the finding, affected code, why keeping it is simpler or safer, and what future change would justify revisiting it.
27
+ Do not disable checks merely to get a green report.
28
+ A cohesive method can be preferable to several forwarding objects; justified duplication can be preferable to premature generalization.
29
+ Lower scores do not establish better design.
30
+
31
+ RuboCop uses the repository's bundle (`gems.rb` or `Gemfile`) and mise-selected Ruby, so the project must include RuboCop and its configured plugins in that bundle.
32
+ Projects without a bundle use jez's pinned RuboCop.
33
+ Other analyzers use jez's pinned bundle and honor the nearest Reek configuration.
34
+ Missing dependencies or plugins are tool errors; there is no fallback after a project bundle fails.
35
+ RuboCop uses defaults without project configuration.
36
+ Counts can miss replacement offenses or equal-sized suppression moves; inspect the diff.
37
+ The edit hook returns findings as advisory context and does not require restructuring after every edit.