Skip to content

Instantly share code, notes, and snippets.

@backus
Created July 27, 2015 03:35
Show Gist options
  • Save backus/a2bef241bcea53726a91 to your computer and use it in GitHub Desktop.
Save backus/a2bef241bcea53726a91 to your computer and use it in GitHub Desktop.
Some of my rubocop preferences
AllCops:
Include:
- "**/*.rake"
- "**/Gemfile"
- "**/Rakefile"
Exclude:
- "vendor/**/*"
- "db/**/*"
DisplayCopNames: true
RunRailsCops: true
TrailingWhitespace:
Enabled: false
Style/TrailingBlankLines:
Enabled: false
Style/ExtraSpacing:
Enabled: false
StringLiterals:
EnforcedStyle: single_quotes
Metrics/LineLength:
Max: 100
Style/DotPosition:
EnforcedStyle: leading
Style/CommentAnnotation:
Description: Checks formatting of special comments (TODO, FIXME, OPTIMIZE, HACK,
REVIEW).
StyleGuide: https://github.com/bbatsov/ruby-style-guide#annotate-keywords
Enabled: true
Rails/Delegate:
Description: Prefer delegate method for delegations.
Enabled: true
Style/FileName:
Enabled: true
Style/GlobalVars:
Enabled: true
Style/IfUnlessModifier:
Description: Favor modifier if/unless usage when you have a single-line body.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
Enabled: true
MaxLineLength: 100
Style/Next:
Description: Use `next` to skip iteration instead of a condition at the end.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
Enabled: true
EnforcedStyle: always
SupportedStyles:
- skip_modifier_ifs
- always
Style/NumericLiterals:
Description: Add underscores to large numeric literals to improve their readability.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics
Enabled: true
MinDigits: 5
Style/PercentLiteralDelimiters:
Description: Use `%`-literal delimiters consistently
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
Enabled: true
PreferredDelimiters:
"%": "()"
"%i": "()"
"%q": "()"
"%Q": "()"
"%r": "()"
"%s": "()"
"%w": "()"
"%W": "()"
"%x": "()"
Style/RegexpLiteral:
Description: Use %r for regular expressions matching more than `MaxSlashes` '/'
characters. Use %r only for regular expressions matching more than `MaxSlashes`
'/' character.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-r
Enabled: true
Style/SignalException:
Description: Checks for proper usage of fail and raise.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
Enabled: true
Style/SingleLineMethods:
Description: Avoid single-line methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
Enabled: true
AllowIfMethodIsEmpty: true
Style/TrivialAccessors:
Enabled: true
ExactNameMatch: false
AllowPredicates: false
AllowDSLWriters: false
IgnoreClassMethods: false
Whitelist:
- to_ary
- to_a
- to_c
- to_enum
- to_h
- to_hash
- to_i
- to_int
- to_io
- to_open
- to_path
- to_proc
- to_r
- to_regexp
- to_str
- to_s
- to_sym
Style/WordArray:
Description: Use %w or %W for arrays of words.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-w
Enabled: true
MinSize: 0
WordRegex: !ruby/regexp /\A[\p{Word}]+\z/
Metrics/ClassLength:
Description: Avoid classes longer than 250 lines of code.
Enabled: true
CountComments: false
Max: 250
Style/MethodCalledOnDoEndBlock:
Description: Avoid chaining a method call on a do...end block.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#single-line-blocks
Enabled: true
Style/SymbolArray:
Description: Use %i or %I for arrays of symbols.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-i
Enabled: true
Style/AccessorMethodName:
Description: Check the naming of accessor methods for get_/set_.
Enabled: true
Style/CharacterLiteral:
Description: Checks for uses of character literals.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-character-literals
Enabled: true
Style/ClassVars:
Description: Avoid the use of class variables.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-class-vars
Enabled: true
Style/ColonMethodCall:
Description: 'Do not use :: for method call.'
StyleGuide: https://github.com/bbatsov/ruby-style-guide#double-colons
Enabled: true
Style/DeprecatedHashMethods:
Description: Checks for use of deprecated Hash methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#hash-key
Enabled: true
Style/DoubleNegation:
Description: Checks for uses of double negation (!!).
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
Enabled: true
Style/EachWithObject:
Description: Prefer `each_with_object` over `inject` or `reduce`.
Enabled: true
Style/EmptyLiteral:
Description: Prefer literals to Array.new/Hash.new/String.new.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
Enabled: true
Style/IfWithSemicolon:
Description: Do not use if x; .... Use the ternary operator instead.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs
Enabled: true
Style/Lambda:
Description: Use the new lambda literal syntax for single-line blocks.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#lambda-multi-line
Enabled: true
Style/LineEndConcatenation:
Description: Use \ instead of + or << to concatenate two string literals at line
end.
Enabled: true
Style/ModuleFunction:
Description: Checks for usage of `extend self` in modules.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
Enabled: true
Style/NegatedIf:
Description: Favor unless over if for negative conditions (or control flow or).
StyleGuide: https://github.com/bbatsov/ruby-style-guide#unless-for-negatives
Enabled: true
Style/NegatedWhile:
Description: Favor until over while for negative conditions.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#until-for-negatives
Enabled: true
Style/NilComparison:
Description: Prefer x.nil? to x == nil.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#predicate-methods
Enabled: true
Style/SelfAssignment:
Description: Checks for places where self-assignment shorthand should have been
used.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#self-assignment
Enabled: true
Style/StructInheritance:
Description: Checks for inheritance from Struct.new.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-extend-struct-new
Enabled: true
Style/VariableInterpolation:
Description: Don't interpolate global, instance and class variables directly in
strings.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
Enabled: true
Lint/UnderscorePrefixedVariableName:
Description: Do not use prefix `_` for a variable that is used.
Enabled: true
Style/MultilineOperationIndentation:
Description: Checks indentation of binary operations that span more than one line.
Enabled: true
EnforcedStyle: aligned
SupportedStyles:
- aligned
- indented
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment