Skip to content

Commit

Permalink
Merge pull request #32 from zendesk/zdrve/rename-badly-named-option
Browse files Browse the repository at this point in the history
Rename --brute-force to --find-no-matches
  • Loading branch information
zdrve authored Feb 21, 2023
2 parents ab2d6dc + 51a347b commit 69b232f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The exit status is 2 if there were any errors, or 0 otherwise.

You can also get the output as json with `--json`.

The remaining options control which checks run: for the full set, use `--brute-force --check-unowned --strict`.
The remaining options control which checks run: for the full set, use `--find-no-matches --check-unowned --strict`.

See [Errors and warnings](#errors-and-warnings) for a description of the checks that are run.

Expand Down
14 changes: 7 additions & 7 deletions bin/check-codeowners

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions spec/checking_mode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
end

it "warns" do
r = run "--brute-force"
r = run "--find-no-matches"
aggregate_failures do
expect(r.status.exitstatus).to eq(0)
expect(r.stdout).to eq("WARNING: Pattern foo at .github/CODEOWNERS:1 doesn't match any files\n" + help_message)
Expand All @@ -56,7 +56,7 @@
end

it "turns warnings into errors in --strict mode" do
r = run "--brute-force", "--strict"
r = run "--find-no-matches", "--strict"
aggregate_failures do
expect(r.status.exitstatus).to eq(1)
expect(r.stdout).to eq("ERROR: Pattern foo at .github/CODEOWNERS:1 doesn't match any files\n" + help_message)
Expand All @@ -66,7 +66,7 @@

it "can be satisifed" do
create_file("foo")
expect_silent_success { run "--brute-force" }
expect_silent_success { run "--find-no-matches" }
end

end
Expand Down
4 changes: 2 additions & 2 deletions spec/debug_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
create_file "y"
add_codeowners "x* @foo/bar"

r0 = run "--json", "--brute-force"
r0 = run "--json", "--find-no-matches"
expect(r0.status).to be_success
data0 = JSON.parse(r0.stdout)

r1 = run "--debug", "--json", "--brute-force"
r1 = run "--debug", "--json", "--find-no-matches"

aggregate_failures do
expect(r1.status).to be_success
Expand Down
2 changes: 1 addition & 1 deletion src/lib/check_codeowners/checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def run_all_checks
repo.git_ls.all_files.sort
end

match_map = if options.find_redundant_ignores
match_map = if options.find_no_matches
warnings.concat(repo.individual_pattern_checker.warnings)
repo.individual_pattern_checker.match_map
end
Expand Down
10 changes: 5 additions & 5 deletions src/lib/check_codeowners/get_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def initialize(argv)
@debug = false
@show_json = false
@strict = false
@find_redundant_ignores = false
@find_no_matches = false
@who_owns = false
@files_owned = false
@check_unowned = false
Expand All @@ -17,14 +17,14 @@ def initialize(argv)
validate
end

attr_reader :debug, :show_json, :strict, :find_redundant_ignores,
attr_reader :debug, :show_json, :strict, :find_no_matches,
:who_owns, :files_owned,
:check_unowned, :should_check_indent, :should_check_sorted, :should_check_valid_owners,
:args

private

attr_writer :debug, :show_json, :strict, :find_redundant_ignores,
attr_writer :debug, :show_json, :strict, :find_no_matches,
:who_owns, :files_owned,
:check_unowned, :should_check_indent, :should_check_sorted, :should_check_valid_owners,
:args
Expand All @@ -39,8 +39,8 @@ def read_options(argv)
opts.on("-s", "--strict", "Treat warnings as errors") do
self.strict = true
end
opts.on("-b", "--brute-force", "Find entries which do not match any files") do
self.find_redundant_ignores = true
opts.on("--find-no-matches", "Find entries which do not match any files") do
self.find_no_matches = true
end
opts.on("--no-check-indent", "Do not require equal indenting") do |value|
self.should_check_indent = value
Expand Down
2 changes: 1 addition & 1 deletion src/lib/check_codeowners/reports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def who_owns

def files_owned
results = repo.git_ls.all_files.map do |file|
# We don't *have* to brute force every pattern - we could instead
# We don't *have* to check every pattern - we could instead
# run git ls-files per owner, not per pattern. But we already have
# the code, so it's convenient.
# Discards warnings
Expand Down

0 comments on commit 69b232f

Please sign in to comment.