Autocorrect style issues with brew style --fix

This commit is contained in:
Nanda H Krishna 2021-07-06 23:44:09 +05:30
parent 77d972c67c
commit 5ccfbcd1d2
No known key found for this signature in database
GPG Key ID: 067E5FCD58ADF3AA
10 changed files with 22 additions and 22 deletions

View File

@ -275,7 +275,7 @@ module Formulary
def load_file(flags:, ignore_errors:) def load_file(flags:, ignore_errors:)
if %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(?:/Formula)?/(?<formula_name>[\w+-.@]+).rb} =~ url if %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(?:/Formula)?/(?<formula_name>[\w+-.@]+).rb} =~ url
raise UsageError, "Installation of #{formula_name} from a GitHub commit URL is unsupported! " \ raise UsageError, "Installation of #{formula_name} from a GitHub commit URL is unsupported! " \
"`brew extract #{formula_name}` to a stable tap on GitHub instead." "`brew extract #{formula_name}` to a stable tap on GitHub instead."
elsif url.match?(%r{^(https?|ftp)://}) elsif url.match?(%r{^(https?|ftp)://})
raise UsageError, "Non-checksummed download of #{name} formula file from an arbitrary URL is unsupported! ", raise UsageError, "Non-checksummed download of #{name} formula file from an arbitrary URL is unsupported! ",
"`brew extract` or `brew create` and `brew tap-new` to create a "\ "`brew extract` or `brew create` and `brew tap-new` to create a "\

View File

@ -205,8 +205,8 @@ module RuboCop
return if tap_style_exception? :components_order_exceptions return if tap_style_exception? :components_order_exceptions
problem "`#{format_component(c1)}` (line #{line_number(c1)}) " \ problem "`#{format_component(c1)}` (line #{line_number(c1)}) " \
"should be put before `#{format_component(c2)}` " \ "should be put before `#{format_component(c2)}` " \
"(line #{line_number(c2)})" do |corrector| "(line #{line_number(c2)})" do |corrector|
reorder_components(corrector, c1, c2) reorder_components(corrector, c1, c2)
end end
end end

View File

@ -205,7 +205,7 @@ module RuboCop
find_method_with_args(body_node, :depends_on, "mpich") do find_method_with_args(body_node, :depends_on, "mpich") do
problem "Formulae in homebrew/core should use 'depends_on \"open-mpi\"' " \ problem "Formulae in homebrew/core should use 'depends_on \"open-mpi\"' " \
"instead of '#{@offensive_node.source}'." do |corrector| "instead of '#{@offensive_node.source}'." do |corrector|
corrector.replace(@offensive_node.source_range, "depends_on \"open-mpi\"") corrector.replace(@offensive_node.source_range, "depends_on \"open-mpi\"")
end end
end end
@ -340,7 +340,7 @@ module RuboCop
offending_node(str) offending_node(str)
problem "References to `#{content}` should "\ problem "References to `#{content}` should "\
"match the specified python dependency (`#{fix}`)" do |corrector| "match the specified python dependency (`#{fix}`)" do |corrector|
corrector.replace(str.source_range, "\"#{fix}\"") corrector.replace(str.source_range, "\"#{fix}\"")
end end
end end

View File

@ -293,7 +293,7 @@ module Homebrew
end end
it "checks online and verifies that a standard license id is the same "\ it "checks online and verifies that a standard license id is the same "\
"as what is indicated on its Github repo", :needs_network do "as what is indicated on its Github repo", :needs_network do
formula_text = <<~RUBY formula_text = <<~RUBY
class Cask < Formula class Cask < Formula
url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" url "https://github.com/cask/cask/archive/v0.8.4.tar.gz"
@ -309,7 +309,7 @@ module Homebrew
end end
it "checks online and verifies that a standard license id with AND is the same "\ it "checks online and verifies that a standard license id with AND is the same "\
"as what is indicated on its Github repo", :needs_network do "as what is indicated on its Github repo", :needs_network do
formula_text = <<~RUBY formula_text = <<~RUBY
class Cask < Formula class Cask < Formula
url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" url "https://github.com/cask/cask/archive/v0.8.4.tar.gz"
@ -325,7 +325,7 @@ module Homebrew
end end
it "checks online and verifies that a standard license id with WITH is the same "\ it "checks online and verifies that a standard license id with WITH is the same "\
"as what is indicated on its Github repo", :needs_network do "as what is indicated on its Github repo", :needs_network do
formula_text = <<~RUBY formula_text = <<~RUBY
class Cask < Formula class Cask < Formula
url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" url "https://github.com/cask/cask/archive/v0.8.4.tar.gz"
@ -407,7 +407,7 @@ module Homebrew
end end
it "checks online and detects that a formula-specified license is not "\ it "checks online and detects that a formula-specified license is not "\
"the same as what is indicated on its Github repository", :needs_network do "the same as what is indicated on its Github repository", :needs_network do
formula_text = <<~RUBY formula_text = <<~RUBY
class Cask < Formula class Cask < Formula
url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" url "https://github.com/cask/cask/archive/v0.8.4.tar.gz"
@ -441,7 +441,7 @@ module Homebrew
end end
it "checks online and detects that an array of license does not contain "\ it "checks online and detects that an array of license does not contain "\
"what is indicated on its Github repository", :needs_network do "what is indicated on its Github repository", :needs_network do
formula_text = <<~RUBY formula_text = <<~RUBY
class Cask < Formula class Cask < Formula
url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" url "https://github.com/cask/cask/archive/v0.8.4.tar.gz"
@ -454,11 +454,11 @@ module Homebrew
fa.audit_license fa.audit_license
expect(fa.problems.first[:message]).to match "Formula license [\"0BSD\", \"MIT\"] "\ expect(fa.problems.first[:message]).to match "Formula license [\"0BSD\", \"MIT\"] "\
"does not match GitHub license [\"GPL-3.0\"]." "does not match GitHub license [\"GPL-3.0\"]."
end end
it "checks online and verifies that an array of license contains "\ it "checks online and verifies that an array of license contains "\
"what is indicated on its Github repository", :needs_network do "what is indicated on its Github repository", :needs_network do
formula_text = <<~RUBY formula_text = <<~RUBY
class Cask < Formula class Cask < Formula
url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" url "https://github.com/cask/cask/archive/v0.8.4.tar.gz"

View File

@ -51,7 +51,7 @@ describe RuboCop::Cop::Cask::HomepageUrlTrailingSlash do
let(:expected_offenses) do let(:expected_offenses) do
[{ [{
message: "'https://foo.brew.sh' must have a slash "\ message: "'https://foo.brew.sh' must have a slash "\
"after the domain.", "after the domain.",
severity: :convention, severity: :convention,
line: 2, line: 2,
column: 11, column: 11,

View File

@ -110,7 +110,7 @@ describe RuboCop::Cop::Cask::StanzaOrder do
line: 3, line: 3,
column: 2, column: 2,
source: "uninstall :quit => 'com.example.foo',\n" \ source: "uninstall :quit => 'com.example.foo',\n" \
" :kext => 'com.example.foo.kext'", " :kext => 'com.example.foo.kext'",
}, { }, {
message: "`version` stanza out of order", message: "`version` stanza out of order",
severity: :convention, severity: :convention,

View File

@ -6,11 +6,11 @@ require "utils/pypi"
describe PyPI do describe PyPI do
let(:package_url) do let(:package_url) do
"https://files.pythonhosted.org/packages/b0/3f/2e1dad67eb172b6443b5eb37eb885a054a55cfd733393071499514140282/"\ "https://files.pythonhosted.org/packages/b0/3f/2e1dad67eb172b6443b5eb37eb885a054a55cfd733393071499514140282/"\
"snakemake-5.29.0.tar.gz" "snakemake-5.29.0.tar.gz"
end end
let(:old_package_url) do let(:old_package_url) do
"https://files.pythonhosted.org/packages/6f/c4/da52bfdd6168ea46a0fe2b7c983b6c34c377a8733ec177cc00b197a96a9f/"\ "https://files.pythonhosted.org/packages/6f/c4/da52bfdd6168ea46a0fe2b7c983b6c34c377a8733ec177cc00b197a96a9f/"\
"snakemake-5.28.0.tar.gz" "snakemake-5.28.0.tar.gz"
end end
describe PyPI::Package do describe PyPI::Package do

View File

@ -137,7 +137,7 @@ module Homebrew
def are_required_by_deps def are_required_by_deps
"#{"is".pluralize(reqs.count)} required by #{deps.to_sentence}, " \ "#{"is".pluralize(reqs.count)} required by #{deps.to_sentence}, " \
"which #{"is".pluralize(deps.count)} currently installed" "which #{"is".pluralize(deps.count)} currently installed"
end end
end end

View File

@ -274,10 +274,10 @@ module Utils
formatted_percent_header = formatted_percent_header =
format "%#{percent_width}s", percent_header format "%#{percent_width}s", percent_header
puts "#{formatted_index_header} | #{formatted_name_with_options_header} | "\ puts "#{formatted_index_header} | #{formatted_name_with_options_header} | "\
"#{formatted_count_header} | #{formatted_percent_header}" "#{formatted_count_header} | #{formatted_percent_header}"
columns_line = "#{"-"*index_width}:|-#{"-"*name_with_options_width}-|-"\ columns_line = "#{"-"*index_width}:|-#{"-"*name_with_options_width}-|-"\
"#{"-"*count_width}:|-#{"-"*percent_width}:" "#{"-"*count_width}:|-#{"-"*percent_width}:"
puts columns_line puts columns_line
index = 0 index = 0
@ -296,7 +296,7 @@ module Utils
format_percent((count.to_i * 100) / total_count.to_f) format_percent((count.to_i * 100) / total_count.to_f)
end end
puts "#{formatted_index} | #{formatted_name_with_options} | " \ puts "#{formatted_index} | #{formatted_name_with_options} | " \
"#{formatted_count} | #{formatted_percent}%" "#{formatted_count} | #{formatted_percent}%"
next if index > 10 next if index > 10
end end
return unless results.length > 1 return unless results.length > 1
@ -310,7 +310,7 @@ module Utils
formatted_total_percent_footer = formatted_total_percent_footer =
format "%#{percent_width}s", formatted_total_percent format "%#{percent_width}s", formatted_total_percent
puts "#{formatted_total_footer} | #{formatted_blank_footer} | "\ puts "#{formatted_total_footer} | #{formatted_blank_footer} | "\
"#{formatted_total_count_footer} | #{formatted_total_percent_footer}%" "#{formatted_total_count_footer} | #{formatted_total_percent_footer}%"
end end
def config_true?(key) def config_true?(key)

View File

@ -195,7 +195,7 @@ module PyPI
input_packages.each do |existing_package| input_packages.each do |existing_package|
if existing_package.same_package?(extra_package) && existing_package.version != extra_package.version if existing_package.same_package?(extra_package) && existing_package.version != extra_package.version
odie "Conflicting versions specified for the `#{extra_package.name}` package: "\ odie "Conflicting versions specified for the `#{extra_package.name}` package: "\
"#{existing_package.version}, #{extra_package.version}" "#{existing_package.version}, #{extra_package.version}"
end end
end end