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:
|
||||
Enabled: false
|
||||
|
||||
Style/BarePercentLiterals:
|
||||
EnforcedStyle: percent_q
|
||||
|
||||
Style/BlockDelimiters:
|
||||
EnforcedStyle: line_count_based
|
||||
|
||||
Style/CaseIndentation:
|
||||
IndentWhenRelativeTo: end
|
||||
|
||||
@ -76,9 +82,11 @@ Style/FileName:
|
||||
Style/GuardClause:
|
||||
Enabled: false
|
||||
|
||||
# depends_on a: :b looks weird in formulae.
|
||||
Style/HashSyntax:
|
||||
EnforcedStyle: hash_rockets
|
||||
|
||||
# disabled until it respects line length
|
||||
Style/IfUnlessModifier:
|
||||
Enabled: false
|
||||
|
||||
@ -133,8 +141,6 @@ Style/StringLiterals:
|
||||
Style/StringLiteralsInInterpolation:
|
||||
EnforcedStyle: double_quotes
|
||||
|
||||
# TODO: enforce when rubocop has shipped this
|
||||
# https://github.com/bbatsov/rubocop/pull/3513
|
||||
Style/TernaryParentheses:
|
||||
Enabled: false
|
||||
|
||||
@ -142,15 +148,8 @@ Style/TernaryParentheses:
|
||||
Style/TrailingCommaInLiteral:
|
||||
EnforcedStyleForMultiline: comma
|
||||
|
||||
Style/UnneededCapitalW:
|
||||
Enabled: false
|
||||
|
||||
# TODO: enforce when rubocop has fixed this
|
||||
# https://github.com/bbatsov/rubocop/issues/3516
|
||||
Style/VariableNumber:
|
||||
Enabled: false
|
||||
|
||||
# TODO: enforce when rubocop has fixed this
|
||||
# https://github.com/bbatsov/rubocop/issues/1543
|
||||
Style/WordArray:
|
||||
Enabled: false
|
||||
|
@ -9,11 +9,19 @@ AllCops:
|
||||
- 'cask/**/*'
|
||||
- '**/vendor/**/*'
|
||||
|
||||
# so many of these in formulae but none in here
|
||||
Lint/AmbiguousRegexpLiteral:
|
||||
Enabled: true
|
||||
|
||||
# `formula do` uses nested method definitions
|
||||
Lint/NestedMethodDefinition:
|
||||
Exclude:
|
||||
- 'test/**/*'
|
||||
|
||||
# so many of these in formulae but none in here
|
||||
Lint/ParenthesesAsGroupedExpression:
|
||||
Enabled: false
|
||||
|
||||
Metrics/ModuleLength:
|
||||
CountComments: false
|
||||
Exclude:
|
||||
@ -21,81 +29,11 @@ Metrics/ModuleLength:
|
||||
- 'cask/lib/hbc/macos.rb'
|
||||
- 'cask/lib/hbc/utils.rb'
|
||||
|
||||
Style/BarePercentLiterals:
|
||||
EnforcedStyle: percent_q
|
||||
|
||||
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
|
||||
# so many of these in formulae but none in here
|
||||
Style/GuardClause:
|
||||
Enabled: true
|
||||
|
||||
# hash-rockets preferred for formulae, a: 1 preferred elsewhere
|
||||
Style/HashSyntax:
|
||||
EnforcedStyle: ruby19_no_mixed_keys
|
||||
|
||||
@ -109,4 +47,3 @@ Style/PredicateName:
|
||||
Exclude:
|
||||
- 'compat/**/*'
|
||||
NameWhitelist: is_32_bit?, is_64_bit?
|
||||
|
||||
|
@ -20,7 +20,7 @@ module Homebrew
|
||||
|
||||
Diagnostic.missing_deps(ff) do |name, missing|
|
||||
print "#{name}: " if ff.size > 1
|
||||
puts (missing * " ").to_s
|
||||
puts missing.join(" ")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ module Homebrew
|
||||
fix = options[:fix]
|
||||
Homebrew.install_gem_setup_path! "rubocop", "0.43.0"
|
||||
|
||||
args = %W[
|
||||
args = %w[
|
||||
--force-exclusion
|
||||
]
|
||||
args << "--auto-correct" if fix
|
||||
|
@ -137,7 +137,7 @@ class FormulaAuditor
|
||||
|
||||
attr_reader :formula, :text, :problems
|
||||
|
||||
BUILD_TIME_DEPS = %W[
|
||||
BUILD_TIME_DEPS = %w[
|
||||
autoconf
|
||||
automake
|
||||
boost-build
|
||||
@ -449,10 +449,9 @@ class FormulaAuditor
|
||||
end
|
||||
|
||||
return unless @new_formula
|
||||
unless formula.deprecated_options.empty?
|
||||
return if formula.deprecated_options.empty?
|
||||
problem "New formulae should not use `deprecated_option`."
|
||||
end
|
||||
end
|
||||
|
||||
def audit_desc
|
||||
# For now, only check the description when using `--strict`
|
||||
|
@ -139,7 +139,7 @@ module Superenv
|
||||
end
|
||||
|
||||
def determine_pkg_config_libdir
|
||||
paths = %W[/usr/lib/pkgconfig]
|
||||
paths = %w[/usr/lib/pkgconfig]
|
||||
paths += homebrew_extra_pkg_config_paths
|
||||
paths.to_path_s
|
||||
end
|
||||
|
@ -51,20 +51,20 @@ class Locale
|
||||
def include?(other)
|
||||
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?
|
||||
true
|
||||
else
|
||||
public_send(var) == other.public_send(var)
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def eql?(other)
|
||||
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)
|
||||
}
|
||||
end
|
||||
rescue ParserError
|
||||
false
|
||||
end
|
||||
|
@ -206,7 +206,7 @@ class Tap
|
||||
end
|
||||
|
||||
ohai "Unshallowing #{name}" unless quiet
|
||||
args = %W[fetch --unshallow]
|
||||
args = %w[fetch --unshallow]
|
||||
args << "-q" if quiet
|
||||
path.cd { safe_system "git", *args }
|
||||
return
|
||||
|
@ -78,9 +78,9 @@ module Formatter
|
||||
rows.times do |row_index|
|
||||
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])
|
||||
}
|
||||
end
|
||||
|
||||
# don't add trailing whitespace to last column
|
||||
last = objects.values_at(item_indices_for_row.last)
|
||||
|
Loading…
x
Reference in New Issue
Block a user