Skip to content

Commit d914a72

Browse files
authored
Merge pull request #20030 from Homebrew/rubocop-messages
audits: quote and reword problem description text
2 parents 54c8b12 + cd6777f commit d914a72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+390
-394
lines changed

Library/Homebrew/formula_auditor.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def audit_file
114114
ln -s #{formula.path.to_s.gsub(formula.tap.path, "..")} #{alias_name}
115115
EOS
116116
else
117-
problem "Formula has other versions so create an alias named #{alias_name}."
117+
problem "Formula has other versions so create an alias named '#{alias_name}'."
118118
end
119119
end
120120

@@ -153,7 +153,7 @@ def audit_synced_versions_formulae
153153
next if synced_formula == name
154154

155155
if (synced_version = Formulary.factory(synced_formula).version) != version
156-
problem "Version of `#{synced_formula}` (#{synced_version}) should match version of `#{name}` (#{version})"
156+
problem "Version of #{synced_formula} (#{synced_version}) should match version of #{name} (#{version})"
157157
end
158158
end
159159

@@ -188,7 +188,7 @@ def audit_name
188188
return if formula.core_formula?
189189
return unless Formula.core_names.include?(name)
190190

191-
problem "Formula name conflicts with existing core formula."
191+
problem "Formula name conflicts with an existing formula in homebrew/core."
192192
end
193193

194194
PERMITTED_LICENSE_MISMATCHES = {
@@ -226,7 +226,7 @@ def audit_license
226226
problem <<~EOS
227227
Formula #{formula.name} contains incompatible licenses: #{incompatible_licenses}.
228228
Formulae in homebrew/core must either use a Debian Free Software Guidelines license
229-
or be released into the public domain. See #{Formatter.url("https://docs.brew.sh/License-Guidelines")}
229+
or be released into the public domain: #{Formatter.url("https://docs.brew.sh/License-Guidelines")}
230230
EOS
231231
end
232232

@@ -327,7 +327,7 @@ def audit_deps
327327
end
328328
end
329329

330-
problem "Dependency '#{dep}' does not define option #{opt.name.inspect}"
330+
problem "Dependency '#{dep}' does not define option: #{opt.name.inspect}"
331331
end
332332

333333
problem "Don't use 'git' as a dependency (it's always available)" if @new_formula && dep.name == "git"
@@ -448,7 +448,7 @@ def audit_conflicts
448448

449449
if T.must(tap).formula_renames.key?(conflict.name) || T.must(tap).aliases.include?(conflict.name)
450450
problem "Formula conflict should be declared using " \
451-
"canonical name (#{conflicting_formula.name}) instead of #{conflict.name}"
451+
"canonical name (#{conflicting_formula.name}) instead of '#{conflict.name}'"
452452
end
453453

454454
reverse_conflict_found = T.let(false, T::Boolean)
@@ -457,7 +457,7 @@ def audit_conflicts
457457
if T.must(tap).formula_renames.key?(reverse_conflict.name) ||
458458
T.must(tap).aliases.include?(reverse_conflict.name)
459459
problem "Formula #{conflicting_formula.name} conflict should be declared using " \
460-
"canonical name (#{reverse_conflict_formula.name}) instead of #{reverse_conflict.name}"
460+
"canonical name (#{reverse_conflict_formula.name}) instead of '#{reverse_conflict.name}'"
461461
end
462462

463463
reverse_conflict_found ||= reverse_conflict_formula == formula
@@ -651,7 +651,7 @@ def audit_github_repository_archived
651651
metadata = SharedAudits.github_repo_data(user, repo)
652652
return if metadata.nil?
653653

654-
problem "GitHub repo is archived" if metadata["archived"]
654+
problem "GitHub repository is archived" if metadata["archived"]
655655
end
656656

657657
def audit_gitlab_repository_archived
@@ -663,7 +663,7 @@ def audit_gitlab_repository_archived
663663
metadata = SharedAudits.gitlab_repo_data(user, repo)
664664
return if metadata.nil?
665665

666-
problem "GitLab repo is archived" if metadata["archived"]
666+
problem "GitLab repository is archived" if metadata["archived"]
667667
end
668668

669669
def audit_github_repository
@@ -712,7 +712,7 @@ def get_repo_data(regex)
712712
end
713713

714714
def audit_specs
715-
problem "Head-only (no stable download)" if head_only?(formula)
715+
problem "HEAD-only (no stable download)" if head_only?(formula)
716716

717717
%w[Stable HEAD].each do |name|
718718
spec_name = name.downcase.to_sym
@@ -759,7 +759,7 @@ def audit_specs
759759

760760
if formula.head && @versioned_formula &&
761761
!formula.tap&.audit_exception(:versioned_head_spec_allowlist, formula.name)
762-
problem "Versioned formulae should not have a `HEAD` spec"
762+
problem "Versioned formulae should not have a `head` spec"
763763
end
764764

765765
stable = formula.stable
@@ -771,7 +771,7 @@ def audit_specs
771771

772772
stable_version_string = version.to_s
773773
if stable_version_string.start_with?("HEAD")
774-
problem "Stable: non-HEAD version name (#{stable_version_string}) should not begin with HEAD"
774+
problem "Stable: non-HEAD version (#{stable_version_string}) should not begin with `HEAD`"
775775
end
776776

777777
stable_url_version = Version.parse(stable.url)
@@ -790,7 +790,7 @@ def audit_specs
790790
return if formula.tap&.audit_exception :unstable_allowlist, formula.name, version_prefix
791791
return if formula.tap&.audit_exception :unstable_devel_allowlist, formula.name, version_prefix
792792

793-
problem "Stable version URLs should not contain #{matched}"
793+
problem "Stable: version URLs should not contain `#{matched}`"
794794
when %r{download\.gnome\.org/sources}, %r{ftp\.gnome\.org/pub/GNOME/sources}i
795795
version_prefix = stable.version.major_minor
796796
return if formula.tap&.audit_exception :gnome_devel_allowlist, formula.name, version_prefix
@@ -800,11 +800,11 @@ def audit_specs
800800
return if stable_url_version >= Version.new("40.0")
801801
return if stable_url_minor_version.even?
802802

803-
problem "#{stable.version} is a development release"
803+
problem "Stable: version (#{stable.version}) is a development release"
804804
when %r{isc.org/isc/bind\d*/}i
805805
return if stable_url_minor_version.even?
806806

807-
problem "#{stable.version} is a development release"
807+
problem "Stable: version (#{stable.version}) is a development release"
808808

809809
when %r{https?://gitlab\.com/([\w-]+)/([\w-]+)}
810810
owner = T.must(Regexp.last_match(1))
@@ -845,7 +845,7 @@ def audit_stable_version
845845
if !newest_committed[:version].nil? &&
846846
current_version < newest_committed[:version] &&
847847
current_version_scheme == previous_committed[:version_scheme]
848-
problem "stable version should not decrease (from #{newest_committed[:version]} to #{current_version})"
848+
problem "Stable: version should not decrease (from #{newest_committed[:version]} to #{current_version})"
849849
end
850850
end
851851

@@ -867,14 +867,14 @@ def audit_revision
867867
!current_revision.zero? &&
868868
current_revision == newest_committed[:revision] &&
869869
current_revision == previous_committed[:revision]
870-
problem "'revision #{current_revision}' should be removed"
870+
problem "`revision #{current_revision}` should be removed"
871871
elsif current_version == previous_committed[:version] &&
872872
!previous_committed[:revision].nil? &&
873873
current_revision < previous_committed[:revision]
874-
problem "revision should not decrease (from #{previous_committed[:revision]} to #{current_revision})"
874+
problem "`revision` should not decrease (from #{previous_committed[:revision]} to #{current_revision})"
875875
elsif newest_committed[:revision] &&
876876
current_revision > (newest_committed[:revision] + 1)
877-
problem "revisions should only increment by 1"
877+
problem "`revision` should only increment by 1"
878878
end
879879
end
880880

@@ -891,10 +891,10 @@ def audit_version_scheme
891891
return if previous_committed[:version_scheme].nil?
892892

893893
if current_version_scheme < previous_committed[:version_scheme]
894-
problem "version_scheme should not decrease (from #{previous_committed[:version_scheme]} " \
894+
problem "`version_scheme` should not decrease (from #{previous_committed[:version_scheme]} " \
895895
"to #{current_version_scheme})"
896896
elsif current_version_scheme > (previous_committed[:version_scheme] + 1)
897-
problem "version_schemes should only increment by 1"
897+
problem "`version_scheme` should only increment by 1"
898898
end
899899
end
900900

@@ -935,7 +935,7 @@ def audit_text
935935
bin_names.each do |name|
936936
shell_commands.each do |cmd|
937937
if text.to_s.match?(/test do.*#{cmd}[(\s]+['"]#{Regexp.escape(name)}[\s'"]/m)
938-
problem %Q(fully scope test #{cmd} calls, e.g. #{cmd} "\#{bin}/#{name}")
938+
problem %Q(Fully scope test `#{cmd}` calls, e.g.: #{cmd} "\#{bin}/#{name}")
939939
end
940940
end
941941
end

Library/Homebrew/resource_auditor.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,30 @@ def audit_download_strategy
6363
url_strategy = DownloadStrategyDetector.detect(url)
6464

6565
if (using == :git || url_strategy == GitDownloadStrategy) && specs[:tag] && !specs[:revision]
66-
problem "Git should specify :revision when a :tag is specified."
66+
problem "Git should specify `revision:` when a `tag:` is specified."
6767
end
6868

6969
return unless using
7070

7171
if using == :cvs
7272
mod = specs[:module]
7373

74-
problem "Redundant :module value in URL" if mod == name
74+
problem "Redundant `module:` value in URL" if mod == name
7575

7676
if url.match?(%r{:[^/]+$})
7777
mod = url.split(":").last
7878

7979
if mod == name
8080
problem "Redundant CVS module appended to URL"
8181
else
82-
problem "Specify CVS module as `:module => \"#{mod}\"` instead of appending it to the URL"
82+
problem "Specify CVS module as `module: \"#{mod}\"` instead of appending it to the URL"
8383
end
8484
end
8585
end
8686

8787
return if url_strategy != DownloadStrategyDetector.detect("", using)
8888

89-
problem "Redundant :using value in URL"
89+
problem "Redundant `using:` value in URL"
9090
end
9191

9292
def audit_checksum
@@ -125,7 +125,7 @@ def audit_resource_name_matches_pypi_package_name_in_url
125125

126126
return if name.casecmp(pypi_package_name).zero?
127127

128-
problem "resource name should be `#{pypi_package_name}` to match the PyPI package name"
128+
problem "`resource` name should be '#{pypi_package_name}' to match the PyPI package name"
129129
end
130130

131131
def audit_urls
@@ -166,12 +166,12 @@ def audit_urls
166166
remote_exists = Utils::Git.remote_exists?(url)
167167
attempts += 1
168168
end
169-
problem "The URL #{url} is not a valid git URL" unless remote_exists
169+
problem "The URL #{url} is not a valid Git URL" unless remote_exists
170170
elsif strategy <= SubversionDownloadStrategy
171171
next unless DevelopmentTools.subversion_handles_most_https_certificates?
172172
next unless Utils::Svn.available?
173173

174-
problem "The URL #{url} is not a valid svn URL" unless Utils::Svn.remote_exists? url
174+
problem "The URL #{url} is not a valid SVN URL" unless Utils::Svn.remote_exists? url
175175
end
176176
end
177177
end
@@ -188,7 +188,7 @@ def audit_head_branch
188188
.match(%r{ref: refs/heads/(.*?)\s+HEAD})&.to_a&.second
189189
return if branch.blank? || branch == specs[:branch]
190190

191-
problem "Use `branch: \"#{branch}\"` to specify the default branch"
191+
problem "Specify the default branch as `branch: \"#{branch}\"`"
192192
end
193193

194194
def problem(text)

Library/Homebrew/rubocops/caveats.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Caveats < FormulaCop
3030
def audit_formula(_formula_nodes)
3131
caveats_strings.each do |n|
3232
if regex_match_group(n, /\bsetuid\b/i)
33-
problem "Don't recommend `setuid` in the caveats, suggest `sudo` instead."
33+
problem "Instead of recommending `setuid` in the caveats, suggest `sudo`."
3434
end
3535

3636
problem "Don't use ANSI escape codes in the caveats." if regex_match_group(n, /\e/)

Library/Homebrew/rubocops/checksum.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ def audit_sha256(checksum)
2828
return if checksum.nil?
2929

3030
if regex_match_group(checksum, /^$/)
31-
problem "sha256 is empty"
31+
problem "`sha256` is empty"
3232
return
3333
end
3434

3535
if string_content(checksum).size != 64 && regex_match_group(checksum, /^\w*$/)
36-
problem "sha256 should be 64 characters"
36+
problem "`sha256` should be 64 characters"
3737
end
3838

3939
return unless regex_match_group(checksum, /[^a-f0-9]+/i)
4040

41-
add_offense(T.must(@offensive_source_range), message: "sha256 contains invalid characters")
41+
add_offense(T.must(@offensive_source_range), message: "`sha256` contains invalid characters")
4242
end
4343
end
4444

@@ -54,7 +54,7 @@ def audit_formula(formula_nodes)
5454
next if checksum.nil?
5555
next unless regex_match_group(checksum, /[A-F]+/)
5656

57-
add_offense(@offensive_source_range, message: "sha256 should be lowercase") do |corrector|
57+
add_offense(@offensive_source_range, message: "`sha256` should be lowercase") do |corrector|
5858
correction = T.must(@offensive_node).source.downcase
5959
corrector.insert_before(T.must(@offensive_node).source_range, correction)
6060
corrector.remove(T.must(@offensive_node).source_range)

Library/Homebrew/rubocops/class.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def audit_formula(formula_nodes)
2323
parent_class = class_name(parent_class_node)
2424
return unless DEPRECATED_CLASSES.include?(parent_class)
2525

26-
problem "#{parent_class} is deprecated, use Formula instead" do |corrector|
26+
problem "`#{parent_class}` is deprecated, use `Formula` instead" do |corrector|
2727
corrector.replace(parent_class_node.source_range, "Formula")
2828
end
2929
end
@@ -49,14 +49,14 @@ def audit_formula(formula_nodes)
4949
p1, p2 = params
5050
if (match = string_content(p1).match(%r{(/usr/local/(s?bin))}))
5151
offending_node(p1)
52-
problem "use \#{#{match[2]}} instead of #{match[1]} in #{node}" do |corrector|
52+
problem "Use `\#{#{match[2]}}` instead of `#{match[1]}` in `#{node}`" do |corrector|
5353
corrector.replace(p1.source_range, p1.source.sub(match[1], "\#{#{match[2]}}"))
5454
end
5555
end
5656

5757
if node == :shell_output && node_equals?(p2, 0)
5858
offending_node(p2)
59-
problem "Passing 0 to shell_output() is redundant" do |corrector|
59+
problem "Passing 0 to `shell_output` is redundant" do |corrector|
6060
corrector.remove(range_with_surrounding_comma(range_with_surrounding_space(range: p2.source_range,
6161
side: :left)))
6262
end

Library/Homebrew/rubocops/components_order.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def audit_formula(formula_nodes)
3939

4040
if on_method_blocks.length > 1
4141
@offensive_node = on_method_blocks.second
42-
problem "there can only be one `#{on_method}` block in a formula."
42+
problem "There can only be one `#{on_method}` block in a formula."
4343
end
4444

4545
check_on_system_block_content(component_precedence_list, on_method_blocks.first)
@@ -112,7 +112,7 @@ def audit_formula(formula_nodes)
112112

113113
on_system_blocks.each do |on_method, blocks|
114114
if blocks.length > 1
115-
problem "there can only be one `#{on_method}` block in a resource block."
115+
problem "There can only be one `#{on_method}` block in a resource block."
116116
next
117117
end
118118
end

Library/Homebrew/rubocops/components_redundancy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def audit_formula(formula_nodes)
3232

3333
url_args = arg.keys.each.map(&:value)
3434
if method_called?(body_node, :sha256) && url_args.include?(:tag) && url_args.include?(:revision)
35-
problem "Do not use both sha256 and tag/revision."
35+
problem "Do not use both `sha256` and `tag:`/`revision:`."
3636
end
3737
end
3838
end

Library/Homebrew/rubocops/dependency_order.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def verify_order_in_source(ordered)
108108

109109
offending_node(node_1)
110110

111-
problem "dependency \"#{dependency_name(node_1)}\" (line #{l1}) should be put before dependency " \
112-
"\"#{dependency_name(node_2)}\" (line #{l2})" do |corrector|
111+
problem "`dependency \"#{dependency_name(node_1)}\"` (line #{l1}) should be put before " \
112+
"`dependency \"#{dependency_name(node_2)}\"` (line #{l2})" do |corrector|
113113
indentation = " " * (start_column(node_2) - line_start_column(node_2))
114114
line_breaks = "\n"
115115
corrector.insert_before(node_2.source_range,

0 commit comments

Comments
 (0)