Merge pull request #1345 from MikeMcQuaid/rubocop-style

Update Rubocop style.
This commit is contained in:
Mike McQuaid 2016-10-22 15:25:28 +01:00 committed by GitHub
commit c521ff4a94
9 changed files with 33 additions and 98 deletions

View File

@ -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

View File

@ -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?

View File

@ -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

View File

@ -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

View File

@ -137,7 +137,7 @@ class FormulaAuditor
attr_reader :formula, :text, :problems
BUILD_TIME_DEPS = %W[
BUILD_TIME_DEPS = %w[
autoconf
automake
boost-build
@ -449,9 +449,8 @@ class FormulaAuditor
end
return unless @new_formula
unless formula.deprecated_options.empty?
problem "New formulae should not use `deprecated_option`."
end
return if formula.deprecated_options.empty?
problem "New formulae should not use `deprecated_option`."
end
def audit_desc

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)