Skip to content

Commit

Permalink
Add rubocop style checks.
Browse files Browse the repository at this point in the history
Rubocop  statically checks code using the [Ruby Style
Guide](https://github.com/bbatsov/ruby-style-guide). This guide is
opinionated in a lot of regards but it has become the most popular and
agreed upon guide.

I have added a custom rubocop file to tweak some
things to Rails-specific style, and I also ignore checks on some important
files.

All of these can be run with the rubocop gem from the terminal.
Since we have a very large number of corrections, I used rubocop to
create a todo file. This makes it easy to enable style checks in small
chunks so that commits are smaller and easier to follow.
  • Loading branch information
drag00n committed Dec 5, 2014
1 parent c00167d commit c7d9896
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
inherit_from: .rubocop_todo.yml
AllCops:
Exclude:
- db/**/*
- vendor/**/*
- node_modules/**/*
ClassLength:
Enabled: false
LineLength:
Enabled: false
MethodLength:
Enabled: false
Documentation:
Enabled: false
297 changes: 297 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2014-12-04 14:36:50 -0500 using RuboCop version 0.26.1.
# 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.
Lint/DeprecatedClassMethods:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Lint/RescueException:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Lint/UnusedBlockArgument:
Enabled: false

# Offense count: 12
Lint/UselessAssignment:
Enabled: false

# Offense count: 4
Metrics/CyclomaticComplexity:
Max: 10

# Offense count: 2
Metrics/PerceivedComplexity:
Max: 10

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AccessModifierIndentation:
Enabled: false

# Offense count: 1
Style/AccessorMethodName:
Enabled: false

# Offense count: 14
# Cop supports --auto-correct.
Style/AlignArray:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
Style/AlignHash:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AlignParameters:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AndOr:
Enabled: false

# Offense count: 5
# Cop supports --auto-correct.
Style/Blocks:
Enabled: false

# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/ColonMethodCall:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/CommentIndentation:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
Style/EmptyLines:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/EmptyLinesAroundAccessModifier:
Enabled: false

# Offense count: 34
# Cop supports --auto-correct.
Style/EmptyLinesAroundBody:
Enabled: false

# Offense count: 7
# Cop supports --auto-correct.
Style/EmptyLiteral:
Enabled: false

# Offense count: 2
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/FormatString:
Enabled: false

# Offense count: 8
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false

# Offense count: 132
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/HashSyntax:
Enabled: false

# Offense count: 4
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Enabled: false

# Offense count: 9
# Cop supports --auto-correct.
Style/IndentationConsistency:
Enabled: false

# Offense count: 131
# Cop supports --auto-correct.
Style/IndentationWidth:
Enabled: false

# Offense count: 7
# Cop supports --auto-correct.
Style/LeadingCommentSpace:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
Style/MethodCallParentheses:
Enabled: false

# Offense count: 1
Style/MultilineTernaryOperator:
Enabled: false

# Offense count: 4
# Cop supports --auto-correct.
Style/NegatedIf:
Enabled: false

# Offense count: 2
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
Style/Next:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IncludeSemanticChanges.
Style/NonNilCheck:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
Style/Not:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
Style/NumericLiterals:
MinDigits: 6

# Offense count: 2
# Cop supports --auto-correct.
Style/RedundantBegin:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Enabled: false

# Offense count: 38
# Cop supports --auto-correct.
Style/RedundantSelf:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SignalException:
Enabled: false

# Offense count: 18
# Cop supports --auto-correct.
Style/SpaceAfterComma:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceAroundEqualsInParameterDefault:
Enabled: false

# Offense count: 10
# Cop supports --auto-correct.
Style/SpaceAroundOperators:
Enabled: false

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceBeforeBlockBraces:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/SpaceBeforeComma:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/SpaceBeforeComment:
Enabled: false

# Offense count: 34
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Style/SpaceInsideBlockBraces:
Enabled: false

# Offense count: 11
# Cop supports --auto-correct.
Style/SpaceInsideBrackets:
Enabled: false

# Offense count: 52
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
Style/SpaceInsideHashLiteralBraces:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
Style/SpaceInsideParens:
Enabled: false

# Offense count: 222
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
Style/SymbolProc:
Enabled: false

# Offense count: 522
# Cop supports --auto-correct.
Style/Tab:
Enabled: false

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/TrailingBlankLines:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
Style/TrailingComma:
Enabled: false

# Offense count: 37
# Cop supports --auto-correct.
Style/TrailingWhitespace:
Enabled: false

# Offense count: 9
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/VariableName:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
Style/WordArray:
MinSize: 7
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,7 @@ gem 'acts_as_xlsx'
gem 'axlsx'

# code syntax highlighter
gem 'codemirror-rails'
gem 'codemirror-rails'

# ruby code style checker
gem 'rubocop'
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ GEM
i18n (>= 0.4.1)
addressable (2.3.6)
arel (5.0.1.20140414130214)
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
axlsx (2.0.1)
htmlentities (~> 4.3.1)
nokogiri (>= 1.4.1)
Expand Down Expand Up @@ -146,7 +149,11 @@ GEM
paper_trail (3.0.6)
activerecord (>= 3.0, < 5.0)
activesupport (>= 3.0, < 5.0)
parser (2.2.0.pre.5)
ast (>= 1.1, < 3.0)
slop (~> 3.4, >= 3.4.5)
pdf-core (0.2.5)
powerpack (0.0.9)
prawn (1.2.1)
pdf-core (~> 0.2.5)
ttfunk (~> 1.2.0)
Expand Down Expand Up @@ -180,13 +187,21 @@ GEM
activesupport (= 4.1.7)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
rake (10.3.2)
redis (3.1.0)
redis-namespace (1.5.1)
redis (~> 3.0, >= 3.0.4)
ref (1.0.5)
responders (1.1.2)
railties (>= 3.2, < 4.2)
rubocop (0.26.1)
astrolabe (~> 1.3)
parser (>= 2.2.0.pre.4, < 3.0)
powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.6.0)
rubyzip (1.0.0)
sass (3.2.19)
sass-rails (4.0.4)
Expand Down Expand Up @@ -268,6 +283,7 @@ DEPENDENCIES
pry-nav
ptools
rails (= 4.1.7)
rubocop
rubyzip (~> 1.0.0)
sass-rails
searchbing
Expand Down

0 comments on commit c7d9896

Please sign in to comment.