Skip to content

Commit

Permalink
Configure rubocop correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Feb 14, 2020
1 parent 97baa6a commit ff37cba
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 71 deletions.
82 changes: 16 additions & 66 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
AllCops:
TargetRubyVersion: 2.2

Metrics/ParameterLists:
Max: 6
CountKeywordArgs: true

Metrics/MethodLength:
Max: 25
CountComments: false

Metrics/AbcSize:
Enabled: false

Metrics/ClassLength:
Max: 300

Metrics/ModuleLength:
Max: 300

Metrics/BlockLength:
Max: 30

Metrics/CyclomaticComplexity:
Max: 12

Metrics/PerceivedComplexity:
Max: 15

BlockNesting:
Max: 4

Metrics/LineLength:
Enabled: false
inherit_from: .rubocop_todo.yml

AccessModifierIndentation:
Enabled: false

Documentation:
Enabled: false
AllCops:
TargetRubyVersion: 2.0
DisabledByDefault: true
Exclude:
- spec/sandbox/**/*
- spec/fixtures/**/*

# Enforce Ruby 1.8-compatible hash syntax
HashSyntax:
Expand All @@ -47,14 +15,6 @@ HashSyntax:
SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

# Allow dots at the end of lines
DotPosition:
Enabled: false

# Don't require magic comment at the top of every file
Encoding:
Enabled: false

# Enforce outdenting of access modifiers (i.e. public, private, protected)
AccessModifierIndentation:
EnforcedStyle: outdent
Expand All @@ -71,15 +31,9 @@ CaseIndentation:
EnforcedStyle: end
IndentOneStep: false

DoubleNegation:
Enabled: false

StringLiterals:
EnforcedStyle: double_quotes

Style/SymbolLiteral:
Enabled: false

Lint/AssignmentInCondition:
Exclude:
- 'lib/thor/line_editor/readline.rb'
Expand Down Expand Up @@ -110,13 +64,13 @@ Lint/UnusedMethodArgument:
- 'lib/thor/parser/arguments.rb'
- 'lib/thor/shell/html.rb'
- 'spec/actions/empty_directory_spec.rb'
- 'spec/fixtures/invoke.thor'

Style/AccessorMethodName:
Naming/AccessorMethodName:
Exclude:
- 'lib/thor/line_editor/basic.rb'

Style/Alias:
Enabled: false
- 'spec/fixtures/group.thor'
- 'spec/sandbox/group.thor'

Style/ClassAndModuleChildren:
Exclude:
Expand All @@ -130,7 +84,7 @@ Style/ClassVars:
- 'lib/thor/util.rb'
- 'spec/util_spec.rb'

Style/ConstantName:
Naming/ConstantName:
Exclude:
- 'spec/line_editor_spec.rb'

Expand All @@ -145,16 +99,15 @@ Style/GlobalVars:
- 'spec/register_spec.rb'
- 'spec/thor_spec.rb'

Style/IndentArray:
Layout/IndentArray:
EnforcedStyle: consistent

Style/MethodMissing:
Exclude:
- 'lib/thor/core_ext/hash_with_indifferent_access.rb'
- 'lib/thor/runner.rb'

Style/MutableConstant:
Enabled: false
- 'spec/fixtures/script.thor'
- 'spec/sandbox/script.thor'

Style/NumericLiteralPrefix:
Exclude:
Expand All @@ -176,9 +129,6 @@ Style/TrailingUnderscoreVariable:
Exclude:
- 'lib/thor/group.rb'

Style/TrailingWhitespace:
Layout/TrailingWhitespace:
Exclude:
- 'spec/shell/basic_spec.rb'

Style/AlignParameters:
Enabled: false
59 changes: 59 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-02-14 14:37:56 -0500 using RuboCop version 0.50.0.
# 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
# versions of RuboCop, may require this file to be generated again.

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: outdent, indent
Layout/AccessModifierIndentation:
Exclude:
- 'lib/thor/nested_context.rb'

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideHashLiteralBraces:
Exclude:
- 'lib/thor/actions/inject_into_file.rb'
- 'spec/actions_spec.rb'
- 'spec/command_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Lint/EndAlignment:
Exclude:
- 'lib/thor/error.rb'

# Offense count: 65
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Exclude:
- 'lib/thor/actions/inject_into_file.rb'
- 'spec/actions/inject_into_file_spec.rb'

# Offense count: 24
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'Gemfile'
- 'lib/thor/actions.rb'
- 'lib/thor/actions/inject_into_file.rb'
- 'lib/thor/base.rb'
- 'lib/thor/error.rb'
- 'lib/thor/parser/option.rb'
- 'lib/thor/shell/color.rb'
- 'spec/parser/options_spec.rb'
- 'spec/script_exit_status_spec.rb'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ group :test do
gem "coveralls", ">= 0.8.19"
gem "rspec", ">= 3"
gem "rspec-mocks", ">= 3"
gem "rubocop", ">= 0.19"
gem "rubocop", "~> 0.50.0"
gem "simplecov", ">= 0.13"
gem "webmock"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/thor/error.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Thor
Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)
Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName
# In order to support versions of Ruby that don't have keyword
# arguments, we need our own spell checker class that doesn't take key
# words. Even though this code wouldn't be hit because of the check
Expand Down
4 changes: 2 additions & 2 deletions spec/nested_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe Thor::NestedContext do
subject(:context) { described_class.new }

describe "#enter" do
it "is never empty within the entered block" do
context.enter do
Expand All @@ -17,4 +17,4 @@
expect(context).not_to be_entered
end
end
end
end
2 changes: 1 addition & 1 deletion spec/no_warnings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
context "when $VERBOSE is enabled" do
it "prints no warnings" do
root = File.expand_path("..", __dir__)
_, err, _ = Open3.capture3("ruby -I #{root}/lib #{root}/spec/fixtures/verbose.thor")
_, err, = Open3.capture3("ruby -I #{root}/lib #{root}/spec/fixtures/verbose.thor")

expect(err).to be_empty
end
Expand Down

0 comments on commit ff37cba

Please sign in to comment.