Update Rubocop style.
Another look at the current Rubocop rules and how they fit with our existing and desired future style. Almost all of these changes were automatic. Split some rules between formulae/brew where brew doesn't have millions of cases that need fixed.
This commit is contained in:
parent
5b421b93c9
commit
1f963267b6
@ -48,6 +48,12 @@ Style/AlignHash:
|
|||||||
Style/AlignParameters:
|
Style/AlignParameters:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Style/BarePercentLiterals:
|
||||||
|
EnforcedStyle: percent_q
|
||||||
|
|
||||||
|
Style/BlockDelimiters:
|
||||||
|
EnforcedStyle: line_count_based
|
||||||
|
|
||||||
Style/CaseIndentation:
|
Style/CaseIndentation:
|
||||||
IndentWhenRelativeTo: end
|
IndentWhenRelativeTo: end
|
||||||
|
|
||||||
@ -76,9 +82,11 @@ Style/FileName:
|
|||||||
Style/GuardClause:
|
Style/GuardClause:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# depends_on a: :b looks weird in formulae.
|
||||||
Style/HashSyntax:
|
Style/HashSyntax:
|
||||||
EnforcedStyle: hash_rockets
|
EnforcedStyle: hash_rockets
|
||||||
|
|
||||||
|
# disabled until it respects line length
|
||||||
Style/IfUnlessModifier:
|
Style/IfUnlessModifier:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
@ -133,8 +141,6 @@ Style/StringLiterals:
|
|||||||
Style/StringLiteralsInInterpolation:
|
Style/StringLiteralsInInterpolation:
|
||||||
EnforcedStyle: double_quotes
|
EnforcedStyle: double_quotes
|
||||||
|
|
||||||
# TODO: enforce when rubocop has shipped this
|
|
||||||
# https://github.com/bbatsov/rubocop/pull/3513
|
|
||||||
Style/TernaryParentheses:
|
Style/TernaryParentheses:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
@ -142,15 +148,8 @@ Style/TernaryParentheses:
|
|||||||
Style/TrailingCommaInLiteral:
|
Style/TrailingCommaInLiteral:
|
||||||
EnforcedStyleForMultiline: comma
|
EnforcedStyleForMultiline: comma
|
||||||
|
|
||||||
Style/UnneededCapitalW:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# TODO: enforce when rubocop has fixed this
|
|
||||||
# https://github.com/bbatsov/rubocop/issues/3516
|
|
||||||
Style/VariableNumber:
|
Style/VariableNumber:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# TODO: enforce when rubocop has fixed this
|
|
||||||
# https://github.com/bbatsov/rubocop/issues/1543
|
|
||||||
Style/WordArray:
|
Style/WordArray:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -9,11 +9,19 @@ AllCops:
|
|||||||
- 'cask/**/*'
|
- 'cask/**/*'
|
||||||
- '**/vendor/**/*'
|
- '**/vendor/**/*'
|
||||||
|
|
||||||
|
# so many of these in formulae but none in here
|
||||||
|
Lint/AmbiguousRegexpLiteral:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
# `formula do` uses nested method definitions
|
# `formula do` uses nested method definitions
|
||||||
Lint/NestedMethodDefinition:
|
Lint/NestedMethodDefinition:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'test/**/*'
|
- 'test/**/*'
|
||||||
|
|
||||||
|
# so many of these in formulae but none in here
|
||||||
|
Lint/ParenthesesAsGroupedExpression:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
Metrics/ModuleLength:
|
Metrics/ModuleLength:
|
||||||
CountComments: false
|
CountComments: false
|
||||||
Exclude:
|
Exclude:
|
||||||
@ -21,81 +29,11 @@ Metrics/ModuleLength:
|
|||||||
- 'cask/lib/hbc/macos.rb'
|
- 'cask/lib/hbc/macos.rb'
|
||||||
- 'cask/lib/hbc/utils.rb'
|
- 'cask/lib/hbc/utils.rb'
|
||||||
|
|
||||||
Style/BarePercentLiterals:
|
# so many of these in formulae but none in here
|
||||||
EnforcedStyle: percent_q
|
Style/GuardClause:
|
||||||
|
Enabled: true
|
||||||
Style/BlockDelimiters:
|
|
||||||
EnforcedStyle: semantic
|
|
||||||
FunctionalMethods:
|
|
||||||
- expect
|
|
||||||
- find
|
|
||||||
- let
|
|
||||||
- let!
|
|
||||||
- subject
|
|
||||||
- watch
|
|
||||||
- inject
|
|
||||||
- map
|
|
||||||
- map!
|
|
||||||
- collect
|
|
||||||
- collect!
|
|
||||||
- reject
|
|
||||||
- reject!
|
|
||||||
- delete_if
|
|
||||||
- with_object
|
|
||||||
- popen_read
|
|
||||||
ProceduralMethods:
|
|
||||||
- after
|
|
||||||
- at_exit
|
|
||||||
- before
|
|
||||||
- benchmark
|
|
||||||
- bm
|
|
||||||
- bmbm
|
|
||||||
- capture_io
|
|
||||||
- capture_output
|
|
||||||
- capture_subprocess_io
|
|
||||||
- chdir
|
|
||||||
- context
|
|
||||||
- create
|
|
||||||
- define_method
|
|
||||||
- define_singleton_method
|
|
||||||
- fork
|
|
||||||
- measure
|
|
||||||
- new
|
|
||||||
- open
|
|
||||||
- realtime
|
|
||||||
- shutup
|
|
||||||
- tap
|
|
||||||
- each
|
|
||||||
- each_pair
|
|
||||||
- each_with_index
|
|
||||||
- reverse_each
|
|
||||||
- ignore_interrupts
|
|
||||||
IgnoredMethods:
|
|
||||||
- each_with_object
|
|
||||||
- it
|
|
||||||
- its
|
|
||||||
- lambda
|
|
||||||
- proc
|
|
||||||
- formula
|
|
||||||
- mock
|
|
||||||
- devel
|
|
||||||
- stable
|
|
||||||
- head
|
|
||||||
- assert_raises
|
|
||||||
- assert_nothing_raised
|
|
||||||
- resource
|
|
||||||
- with_build_environment
|
|
||||||
- ensure_writable
|
|
||||||
- satisfy
|
|
||||||
- fetch
|
|
||||||
- brew
|
|
||||||
- expand
|
|
||||||
- env
|
|
||||||
- recursive_dependencies
|
|
||||||
- trap
|
|
||||||
- link_dir
|
|
||||||
- with_system_path
|
|
||||||
|
|
||||||
|
# hash-rockets preferred for formulae, a: 1 preferred elsewhere
|
||||||
Style/HashSyntax:
|
Style/HashSyntax:
|
||||||
EnforcedStyle: ruby19_no_mixed_keys
|
EnforcedStyle: ruby19_no_mixed_keys
|
||||||
|
|
||||||
@ -109,4 +47,3 @@ Style/PredicateName:
|
|||||||
Exclude:
|
Exclude:
|
||||||
- 'compat/**/*'
|
- 'compat/**/*'
|
||||||
NameWhitelist: is_32_bit?, is_64_bit?
|
NameWhitelist: is_32_bit?, is_64_bit?
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ module Homebrew
|
|||||||
|
|
||||||
Diagnostic.missing_deps(ff) do |name, missing|
|
Diagnostic.missing_deps(ff) do |name, missing|
|
||||||
print "#{name}: " if ff.size > 1
|
print "#{name}: " if ff.size > 1
|
||||||
puts (missing * " ").to_s
|
puts missing.join(" ")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -49,7 +49,7 @@ module Homebrew
|
|||||||
fix = options[:fix]
|
fix = options[:fix]
|
||||||
Homebrew.install_gem_setup_path! "rubocop", "0.43.0"
|
Homebrew.install_gem_setup_path! "rubocop", "0.43.0"
|
||||||
|
|
||||||
args = %W[
|
args = %w[
|
||||||
--force-exclusion
|
--force-exclusion
|
||||||
]
|
]
|
||||||
args << "--auto-correct" if fix
|
args << "--auto-correct" if fix
|
||||||
|
@ -137,7 +137,7 @@ class FormulaAuditor
|
|||||||
|
|
||||||
attr_reader :formula, :text, :problems
|
attr_reader :formula, :text, :problems
|
||||||
|
|
||||||
BUILD_TIME_DEPS = %W[
|
BUILD_TIME_DEPS = %w[
|
||||||
autoconf
|
autoconf
|
||||||
automake
|
automake
|
||||||
boost-build
|
boost-build
|
||||||
@ -449,9 +449,8 @@ class FormulaAuditor
|
|||||||
end
|
end
|
||||||
|
|
||||||
return unless @new_formula
|
return unless @new_formula
|
||||||
unless formula.deprecated_options.empty?
|
return if formula.deprecated_options.empty?
|
||||||
problem "New formulae should not use `deprecated_option`."
|
problem "New formulae should not use `deprecated_option`."
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit_desc
|
def audit_desc
|
||||||
|
@ -139,7 +139,7 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
def determine_pkg_config_libdir
|
def determine_pkg_config_libdir
|
||||||
paths = %W[/usr/lib/pkgconfig]
|
paths = %w[/usr/lib/pkgconfig]
|
||||||
paths += homebrew_extra_pkg_config_paths
|
paths += homebrew_extra_pkg_config_paths
|
||||||
paths.to_path_s
|
paths.to_path_s
|
||||||
end
|
end
|
||||||
|
@ -51,20 +51,20 @@ class Locale
|
|||||||
def include?(other)
|
def include?(other)
|
||||||
other = self.class.parse(other) unless other.is_a?(self.class)
|
other = self.class.parse(other) unless other.is_a?(self.class)
|
||||||
|
|
||||||
[:language, :region, :script].all? { |var|
|
[:language, :region, :script].all? do |var|
|
||||||
if other.public_send(var).nil?
|
if other.public_send(var).nil?
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
public_send(var) == other.public_send(var)
|
public_send(var) == other.public_send(var)
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def eql?(other)
|
def eql?(other)
|
||||||
other = self.class.parse(other) unless other.is_a?(self.class)
|
other = self.class.parse(other) unless other.is_a?(self.class)
|
||||||
[:language, :region, :script].all? { |var|
|
[:language, :region, :script].all? do |var|
|
||||||
public_send(var) == other.public_send(var)
|
public_send(var) == other.public_send(var)
|
||||||
}
|
end
|
||||||
rescue ParserError
|
rescue ParserError
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -206,7 +206,7 @@ class Tap
|
|||||||
end
|
end
|
||||||
|
|
||||||
ohai "Unshallowing #{name}" unless quiet
|
ohai "Unshallowing #{name}" unless quiet
|
||||||
args = %W[fetch --unshallow]
|
args = %w[fetch --unshallow]
|
||||||
args << "-q" if quiet
|
args << "-q" if quiet
|
||||||
path.cd { safe_system "git", *args }
|
path.cd { safe_system "git", *args }
|
||||||
return
|
return
|
||||||
|
@ -78,9 +78,9 @@ module Formatter
|
|||||||
rows.times do |row_index|
|
rows.times do |row_index|
|
||||||
item_indices_for_row = row_index.step(objects.size - 1, rows).to_a
|
item_indices_for_row = row_index.step(objects.size - 1, rows).to_a
|
||||||
|
|
||||||
first_n = item_indices_for_row[0...-1].map { |index|
|
first_n = item_indices_for_row[0...-1].map do |index|
|
||||||
objects[index] + "".rjust(col_width - object_lengths[index])
|
objects[index] + "".rjust(col_width - object_lengths[index])
|
||||||
}
|
end
|
||||||
|
|
||||||
# don't add trailing whitespace to last column
|
# don't add trailing whitespace to last column
|
||||||
last = objects.values_at(item_indices_for_row.last)
|
last = objects.values_at(item_indices_for_row.last)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user