Skip to content
Snippets Groups Projects
Commit 357cce11 authored by Mike McQuaid's avatar Mike McQuaid Committed by GitHub
Browse files

Merge pull request #1008 from MikeMcQuaid/more-rubocop

More Rubocop tweaks
parents 569dbf4d 8a4f26f9
No related branches found
No related tags found
No related merge requests found
inherit_from: .rubocop_todo.yml
inherit_from:
- .rubocop_rules.yml
- .rubocop_todo.yml
AllCops:
TargetRubyVersion: 2.0
......@@ -6,129 +8,3 @@ AllCops:
- 'Homebrew/cask/**/*'
- 'Homebrew/vendor/**/*'
- 'Homebrew/test/vendor/**/*'
# ruby style guide favorite
Style/StringLiterals:
EnforcedStyle: double_quotes
# consistency with above
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
# percent-x is allowed for multiline
Style/CommandLiteral:
EnforcedStyle: mixed
# paths abound, easy escape
Style/RegexpLiteral:
EnforcedStyle: slashes
# too prevalent to change this now, but might be discussed/changed later
Style/Alias:
EnforcedStyle: prefer_alias_method
# our current conditional style is established, clear and
# requiring users to change that now would be confusing.
Style/ConditionalAssignment:
Enabled: false
# no metrics for formulas
Metrics/AbcSize:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
# we often need very long lines
Metrics/LineLength:
Enabled: false
# formulas have no mandatory doc
Style/Documentation:
Enabled: false
# favor parens-less DSL-style arguments
Lint/AmbiguousOperator:
Enabled: false
Lint/AmbiguousRegexpLiteral:
Enabled: false
Lint/AssignmentInCondition:
Enabled: false
Lint/ParenthesesAsGroupedExpression:
Enabled: false
# compact style
Style/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true
# port numbers and such tech stuff
Style/NumericLiterals:
Enabled: false
# zero-prefixed octal literals are just too widely used (and mostly understood)
Style/NumericLiteralPrefix:
EnforcedOctalStyle: zero_only
# consistency and readability when faced with string interpolation
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%': '()'
'%i': '()'
'%q': '()'
'%Q': '()'
'%r': '{}'
'%s': '()'
'%w': '[]'
'%W': '[]'
'%x': '()'
# conflicts with DSL-style path concatenation with `/`
Style/SpaceAroundOperators:
Enabled: false
# not a problem for typical shell users
Style/SpecialGlobalVars:
Enabled: false
# `system` is a special case and aligns on second argument
Style/AlignParameters:
Enabled: false
# counterproductive in formulas, notably within the install method
Style/GuardClause:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
# dashes in filenames are typical
# TODO: enforce when rubocop has fixed this
# https://github.com/bbatsov/rubocop/issues/1545
Style/FileName:
Enabled: false
# no percent word array, being friendly to non-ruby users
# TODO: enforce when rubocop has fixed this
# https://github.com/bbatsov/rubocop/issues/1543
Style/WordArray:
Enabled: false
Style/UnneededCapitalW:
Enabled: false
# we prefer compact if-else-end/case-when-end alignment
Lint/EndAlignment:
AlignWith: variable
Style/CaseIndentation:
IndentWhenRelativeTo: end
# we prefer Perl-style regex back references
Style/PerlBackrefs:
Enabled: false
# makes diffs nicer
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: comma
# ruby style guide favorite
Style/StringLiterals:
EnforcedStyle: double_quotes
# consistency with above
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
# percent-x is allowed for multiline
Style/CommandLiteral:
EnforcedStyle: mixed
# paths abound, easy escape
Style/RegexpLiteral:
EnforcedStyle: slashes
# too prevalent to change this now, but might be discussed/changed later
Style/Alias:
EnforcedStyle: prefer_alias_method
# our current conditional style is established, clear and
# requiring users to change that now would be confusing.
Style/ConditionalAssignment:
Enabled: false
# no metrics for formulas
Metrics/AbcSize:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
# we often need very long lines
Metrics/LineLength:
Enabled: false
# formulas have no mandatory doc
Style/Documentation:
Enabled: false
# favor parens-less DSL-style arguments
Lint/AmbiguousOperator:
Enabled: false
Lint/AmbiguousRegexpLiteral:
Enabled: false
Lint/AssignmentInCondition:
Enabled: false
Lint/ParenthesesAsGroupedExpression:
Enabled: false
# compact style
Style/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true
# port numbers and such tech stuff
Style/NumericLiterals:
Enabled: false
# zero-prefixed octal literals are just too widely used (and mostly understood)
Style/NumericLiteralPrefix:
EnforcedOctalStyle: zero_only
# consistency and readability when faced with string interpolation
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%': '()'
'%i': '()'
'%q': '()'
'%Q': '()'
'%r': '{}'
'%s': '()'
'%w': '[]'
'%W': '[]'
'%x': '()'
# conflicts with DSL-style path concatenation with `/`
Style/SpaceAroundOperators:
Enabled: false
# not a problem for typical shell users
Style/SpecialGlobalVars:
Enabled: false
# `system` is a special case and aligns on second argument
Style/AlignParameters:
Enabled: false
# counterproductive in formulas, notably within the install method
Style/GuardClause:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
# dashes in filenames are typical
# TODO: enforce when rubocop has fixed this
# https://github.com/bbatsov/rubocop/issues/1545
Style/FileName:
Enabled: false
# no percent word array, being friendly to non-ruby users
# TODO: enforce when rubocop has fixed this
# https://github.com/bbatsov/rubocop/issues/1543
Style/WordArray:
Enabled: false
Style/UnneededCapitalW:
Enabled: false
# we prefer compact if-else-end/case-when-end alignment
Lint/EndAlignment:
AlignWith: variable
Style/CaseIndentation:
IndentWhenRelativeTo: end
# we prefer Perl-style regex back references
Style/PerlBackrefs:
Enabled: false
# makes diffs nicer
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: comma
# we won't change backward compatible method names
Style/MethodName:
Exclude:
- 'Homebrew/compat/**/*'
# we won't change backward compatible predicate names
Style/PredicateName:
Exclude:
- 'Homebrew/compat/**/*'
# `formula do` uses nested method definitions
Lint/NestedMethodDefinition:
Exclude:
- 'Homebrew/test/**/*'
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-09-17 15:44:31 +0100 using RuboCop version 0.42.0.
# `rubocop --auto-gen-config --exclude-limit 30`
# on 2016-09-18 15:15:22 +0100 using RuboCop version 0.41.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
......@@ -48,6 +48,7 @@ Lint/Loop:
# Offense count: 6
Lint/NestedMethodDefinition:
Exclude:
- 'Homebrew/test/**/*'
- 'Homebrew/dev-cmd/bottle.rb'
- 'Homebrew/dev-cmd/test-bot.rb'
......@@ -58,7 +59,23 @@ Lint/NonLocalExitFromIterator:
# Offense count: 28
Lint/RescueException:
Enabled: false
Exclude:
- 'Homebrew/brew.rb'
- 'Homebrew/build.rb'
- 'Homebrew/cmd/fetch.rb'
- 'Homebrew/cmd/reinstall.rb'
- 'Homebrew/cmd/update-report.rb'
- 'Homebrew/debrew.rb'
- 'Homebrew/dev-cmd/pull.rb'
- 'Homebrew/dev-cmd/test.rb'
- 'Homebrew/formula.rb'
- 'Homebrew/formula_installer.rb'
- 'Homebrew/migrator.rb'
- 'Homebrew/postinstall.rb'
- 'Homebrew/readall.rb'
- 'Homebrew/test.rb'
- 'Homebrew/test/test_ENV.rb'
- 'Homebrew/utils/fork.rb'
# Offense count: 1
Lint/ShadowedException:
......@@ -77,7 +94,7 @@ Metrics/BlockNesting:
# Offense count: 20
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 369
Max: 400
# Offense count: 1
# Configuration parameters: CountKeywordArgs.
......@@ -110,7 +127,23 @@ Style/Alias:
# Offense count: 26
Style/CaseEquality:
Enabled: false
Exclude:
- 'Homebrew/cleanup.rb'
- 'Homebrew/cmd/search.rb'
- 'Homebrew/compilers.rb'
- 'Homebrew/cxxstdlib.rb'
- 'Homebrew/debrew.rb'
- 'Homebrew/dependencies.rb'
- 'Homebrew/dependency_collector.rb'
- 'Homebrew/download_strategy.rb'
- 'Homebrew/formula.rb'
- 'Homebrew/options.rb'
- 'Homebrew/patch.rb'
- 'Homebrew/pkg_version.rb'
- 'Homebrew/requirement.rb'
- 'Homebrew/requirements.rb'
- 'Homebrew/software_spec.rb'
- 'Homebrew/version.rb'
# Offense count: 1
# Cop supports --auto-correct.
......@@ -170,6 +203,7 @@ Style/IdenticalConditionalBranches:
# SupportedStyles: snake_case, camelCase
Style/MethodName:
Exclude:
- 'Homebrew/compat/**/*'
- 'Homebrew/cleanup.rb'
- 'Homebrew/diagnostic.rb'
- 'Homebrew/formula_cellar_checks.rb'
......@@ -230,7 +264,7 @@ Style/OpMethod:
# NameWhitelist: is_a?
Style/PredicateName:
Exclude:
- 'spec/**/*'
- 'Homebrew/compat/**/*'
- 'Homebrew/download_strategy.rb'
- 'Homebrew/hardware.rb'
......
#: * `style` [`--fix`] [`--display-cop-names`] [<formulae>|<files>]:
#: * `style` [`--fix`] [`--display-cop-names`] [<files>|<taps>|<formulae>]:
#: Check formulae or files for conformance to Homebrew style guidelines.
#:
#: <formulae> is a list of formula names.
#:
#: <files> is a list of file names.
#:
#: <formulae> and <files> may not be combined. If both are omitted, style will run
#: style checks on the whole Homebrew `Library`, including core code and all
#: formulae.
#:
#: If `--fix` is passed and `HOMEBREW_DEVELOPER` is set, style violations
#: will be automatically fixed using RuboCop's `--auto-correct` feature.
#: If `--fix` is passed, style violations will be automatically fixed using
#: RuboCop's `--auto-correct` feature.
#:
#: If `--display-cop-names` is passed, the RuboCop cop name for each violation
#: is included in the output.
......@@ -23,9 +19,11 @@ require "utils/json"
module Homebrew
def style
target = if ARGV.named.empty?
[HOMEBREW_LIBRARY]
[HOMEBREW_LIBRARY_PATH]
elsif ARGV.named.any? { |file| File.exist? file }
ARGV.named
elsif ARGV.named.any? { |tap| tap.count("/") == 1 }
ARGV.named.map { |tap| Tap.fetch(tap).path }
else
ARGV.formulae.map(&:path)
end
......@@ -53,7 +51,7 @@ module Homebrew
--force-exclusion
--config #{HOMEBREW_LIBRARY}/.rubocop.yml
]
args << "--auto-correct" if ARGV.homebrew_developer? && fix
args << "--auto-correct" if fix
args += files
case output_type
......
inherit_from: ../../.rubocop.yml
# We won't change method or predicate names because of backward compatibility.
Style/MethodName:
Enabled: false
Style/PredicateName:
Enabled: false
......@@ -719,6 +719,7 @@ module Homebrew
test "brew", "update-test", "--commit=HEAD"
end
test "brew", "style"
test "brew", "readall", "--syntax"
coverage_args = []
......@@ -741,6 +742,9 @@ module Homebrew
test "brew", "cask-tests", *coverage_args
end
elsif @tap
if @tap.name == "homebrew/core"
test "brew", "style", @tap.name
end
test "brew", "readall", "--aliases", @tap.name
end
end
......
inherit_from: ../../.rubocop.yml
# `formula do` uses nested method definitions
Lint/NestedMethodDefinition:
Enabled: false
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment