Skip to content

Commit

Permalink
Get useful feedback from Rubocop Metrics cops
Browse files Browse the repository at this point in the history
One of the biggest pros of linters like Rubocop is to get valuable feedback to
help write better code. The way we have Rubocop configured now we don't prevent
new code from adhere improved code quality and this is specially important when
touching code that already suffers from complexity.

Without all Rubocop's Metrics cops enabled there's no way to get this insights
and write better code. This enables them while regenerating the
`.rubocop_todo.yml` to hide the current violations.

So, next time we touch existing code that we think could be simpler, we should
go to `.rubocop_todo.yml` and remove any occurrences of the file in question.
This way we could Rubocop's feedback right in the editor. This is tremendously
helpful when refactoring. It shows you where to start.
  • Loading branch information
sauloperez committed Sep 19, 2018
1 parent 62bebdb commit 0ac16ce
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 123 deletions.
16 changes: 8 additions & 8 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "2"
plugins:
rubocop:
enabled: true
channel: "rubocop-0-55"
channel: "rubocop-0-57"
scss-lint:
enabled: true
checks:
Expand All @@ -19,23 +19,23 @@ checks:
argument-count:
enabled: false
complex-logic:
enabled: true
enabled: false
file-lines:
enabled: true
enabled: false
method-complexity:
enabled: true
enabled: false
method-count:
enabled: false
method-lines:
enabled: false
nested-control-flow:
enabled: true
enabled: false
return-statements:
enabled: true
enabled: false
similar-code:
enabled: true
enabled: false
identical-code:
enabled: true
enabled: false
exclude_patterns:
- "spec/**/*"
- "vendor/**/*"
Expand Down
22 changes: 9 additions & 13 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ inherit_from:
AllCops:
TargetRubyVersion: 2.1
TargetRailsVersion: 3.2
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'vendor/**/*'
- 'node_modules/**/*'
- !ruby/regexp /old_and_unused\.rb$/
# The parser gem fails to parse this file with out current Ruby version.
- 'spec/factories.rb'

Expand Down Expand Up @@ -174,28 +170,28 @@ Lint/AssignmentInCondition:
StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition

Metrics/AbcSize:
Enabled: false
Max: 15

Metrics/BlockNesting:
Enabled: false
Max: 3

Metrics/ClassLength:
Enabled: false
Max: 100

Metrics/ModuleLength:
Enabled: false
Max: 100

Metrics/CyclomaticComplexity:
Enabled: false
Max: 6

Metrics/LineLength:
Enabled: false
Max: 80

Metrics/MethodLength:
Enabled: false
Max: 10

Metrics/ParameterLists:
Enabled: false
Max: 5

Metrics/PerceivedComplexity:
Enabled: false
Max: 7
Loading

0 comments on commit 0ac16ce

Please sign in to comment.