Last active
March 25, 2018 02:27
-
-
Save amingilani/afd844d63b5d235a9b56e5e6c1f14554 to your computer and use it in GitHub Desktop.
This is my Rubocop setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://gist.github.com/jhass/a5ae80d87f18e53e7b56 | |
AllCops: | |
TargetRubyVersion: 2.4 | |
DisplayCopNames: true | |
Include: | |
- '**/Rakefile' | |
- '**/config.ru' | |
Exclude: | |
- '**/Guardfile' | |
- 'db/**/*' | |
- 'config/**/*' | |
- 'script/**/*' | |
- 'lib/**/*' | |
- 'vendor/**/*' | |
- 'bin/**/*' | |
- 'spec/rails_helper.rb' | |
- 'spec/spec_helper.rb' | |
- 'node_modules/**/*' | |
Rails: | |
Enabled: true | |
# Commonly used screens these days easily fit more than 80 characters. | |
Metrics/LineLength: | |
Max: 120 | |
Exclude: | |
- 'spec/**/*' | |
# Too short methods lead to extraction of single-use methods, which can make | |
# the code easier to read (by naming things), but can also clutter the class | |
Metrics/MethodLength: | |
Max: 25 | |
# The guiding principle of classes is SRP, SRP can't be accurately measured by LoC | |
Metrics/ClassLength: | |
Max: 1500 | |
# We do not need to support Ruby 1.9, so this is good to use. | |
Style/SymbolArray: | |
Enabled: true | |
# Mixing the styles looks just silly. | |
Style/HashSyntax: | |
EnforcedStyle: ruby19_no_mixed_keys | |
# String#% is by far the least verbose and only object oriented variant. | |
Style/FormatString: | |
EnforcedStyle: percent | |
Style/CollectionMethods: | |
Enabled: true | |
PreferredMethods: | |
# Reduce makes more sense to me. | |
reduce: "reduce" | |
# A specialized exception class will take one or more arguments and construct the message from it. | |
# So both variants make sense. | |
Style/RaiseArgs: | |
Enabled: false | |
# Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain. | |
# The argument that fail should be used to abort the program is wrong too, | |
# there's Kernel#abort for that. | |
Style/SignalException: | |
EnforcedStyle: only_raise | |
# No space makes the method definition shorter and differentiates | |
# from a regular assignment. | |
Layout/SpaceAroundEqualsInParameterDefault: | |
EnforcedStyle: no_space | |
# Most readable form. | |
Layout/AlignHash: | |
EnforcedHashRocketStyle: table | |
EnforcedColonStyle: table | |
# Indenting the chained dots beneath each other is not supported by this cop, | |
# see https://github.com/bbatsov/rubocop/issues/1633 | |
Layout/MultilineOperationIndentation: | |
Enabled: false | |
# Suppressing exceptions can be perfectly fine, and be it to avoid to | |
# explicitly type nil into the rescue since that's what you want to return, | |
# or suppressing LoadError for optional dependencies | |
Lint/HandleExceptions: | |
Enabled: false | |
# { ... } for multi-line blocks is okay, follow Weirichs rule instead: | |
# https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc | |
Style/BlockDelimiters: | |
Enabled: false | |
# This is more annoying than helpful, honestly | |
Style/FrozenStringLiteralComment: | |
Enabled: false | |
Style/FileName: | |
Exclude: | |
- '**/Gemfile' | |
# do / end blocks should be used for side effects, | |
# methods that run a block for side effects and have | |
# a useful return value are rare, assign the return | |
# value to a local variable for those cases. | |
Style/MethodCalledOnDoEndBlock: | |
Enabled: true | |
# Enforcing the names of variables? To single letter ones? Just no. | |
Style/SingleLineBlockParams: | |
Enabled: false | |
# Check with yard instead. | |
Style/Documentation: | |
Enabled: false | |
# This is just silly. Calling the argument `other` in all cases makes no sense. | |
Style/OpMethod: | |
Enabled: false | |
# There are valid cases, for example debugging Cucumber steps, | |
# also they'll fail CI anyway | |
Lint/Debugger: | |
Enabled: false | |
## Devise generated controllers | |
# I am not rewriting the controllers | |
Style/ClassAndModuleChildren: | |
Enabled: false | |
Metrics/AbcSize: | |
Enabled: false | |
# Specs tend to be very long | |
Metrics/BlockLength: | |
Exclude: | |
- "**/*_spec.rb" | |
- "spec/**/*" | |
Metrics/CyclomaticComplexity: | |
Exclude: | |
- 'app/models/**/*' | |
Rails/DynamicFindBy: | |
Exclude: | |
- "features/**/*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment