Skip to content

Instantly share code, notes, and snippets.

@strawberryjello
Last active August 29, 2015 14:20
Show Gist options
  • Save strawberryjello/ab4eb8f0c15f1dd56928 to your computer and use it in GitHub Desktop.
Save strawberryjello/ab4eb8f0c15f1dd56928 to your computer and use it in GitHub Desktop.
Sample annotated Rubocop YAML file
# GENERAL
# Indent using soft indents (2 whitespace) instead of real tab.
# Enabled by default
# Style/IndentationWidth
# Limit lines to 80 characters except for HAML files.
# Enabled by default
# Metrics/LineLength
# Avoid trailing whitespace.
# Enabled by default
# Style/TrailingWhitespace
# End each file with newline.
# Enabled by default
# Style/TrailingBlankLines
# OPERATORS
# Whitespace before and after binary operators.
# Enabled by default
# Style/SpaceAroundOperators
# No whitespace after unary operators.
# Enabled by default
# Style/SpaceAfterNot
# Whitespace after comma ','.
# Enabled by default
# Style/SpaceAfterComma
# Use && and || instead of and and or.
# Enabled by default
# Style/AndOr
# ASSIGNMENT
# Put right-hand expression on next line if statement exceeds line-length limit.
# StyleGuide: https://github.com/clinic-it/zen/blob/master/guidelines/RoR.md#assignment-newline
Style/MultilineOperationIndentation:
EnforcedStyle: indented
# For if-else, case-when, loop, and other block statements.
# Not implemented
# HASH
# Use hash rocket => instead of :.
Style/HashSyntax:
EnforcedStyle: hash_rockets
StyleGuide: https://github.com/clinic-it/zen/blob/master/guidelines/RoR.md#hash-syntax
# No whitespace before and after hash contents.
Style/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space
StyleGuide: https://github.com/clinic-it/zen/blob/master/guidelines/RoR.md#hash-whitespace
# Hash that exceeds line-length limit.
# Possible match in Style/AlignHash, but it does not check for having only a single key/value pair per line.
# ARRAY
# No whitespace before and after array contents.
# Enabled by default
# Style/SpaceInsideBraces
# STRINGS
# Use single quotes by default.
# Use double quotes only if interpolation is used.
# Enabled by default
# Style/StringLiterals
# Use << instead of + when concatenating strings.
# Not implemented
# Use \ to break long strings instead of +.
# Enabled by default
# Style/LineEndConcatenation
# BLOCKS
# Whitespace before and after proc, lambda, and block contents.
# Enabled by default
# Style/SpaceInsideBlockBraces
# Whitespace before proc, lamda, and block.
# Enabled by default
# Style/SpaceBeforeBlockBraces
# Use do and end for multi-line blocks.
# Enabled by default
# Style/BlockDelimiters
# 1 line break to separate logically grouped statements inside a block.
# Not implemented
# METHOD
# Method definition should not use parentheses.
Style/MethodDefParentheses:
EnforcedStyle: require_no_parentheses
StyleGuide: https://github.com/clinic-it/zen/blob/master/guidelines/RoR.md#method-definition
# Method call should not use parentheses.
# Enabled by default (method call with no args only)
# Style/MethodCallParentheses
# Hash arguments that exceeds line-length limit.
Style/AlignParameters:
EnforcedStyle: with_fixed_indentation
StyleGuide: https://github.com/clinic-it/zen/blob/master/guidelines/RoR.md#method-hash-argument
# 1 non-hash argument and 1 hash argument that exceeds line-length limit.
# Not implemented
# Multiple non-hash arguments that exceeds line-length limit.
# Not implemented
# 2 Line breaks to separate method definitions.
# Not implemented
# 1 line break to separate logically grouped statements inside a method.
# Not implemented
# 1 method call per line if method chaining exceeds line-length limit. Always put the . on the previous line.
Style/DotPosition:
EnforcedStyle: trailing
StyleGuide: https://github.com/clinic-it/zen/blob/master/guidelines/RoR.md#method-multiline
# 3-argument method is only allowed if the 3rd argument is a hash.
# Not implemented
# Use hash argument if you need 3 or more arguments.
# Not implemented
# CONDITIONS
# Don't use unless with else. Convert to if-else statement.
# Enabled by default
# Style/UnlessElse
# Avoid nested conditional statements.
# Enabled by default
# Style/GuardClause
# Use ternary operator ?: for simple statements instead of if-else.
# Not implemented
# For ternary operator ?:, use only 1 statement per line if it exceeds line-length limit.
# Not implemented
# Conflict with Ruby Style Guide: https://github.com/bbatsov/ruby-style-guide#no-multiline-ternary
# Disable default setting
Style/MultilineTernaryOperator:
Enabled: false
# Don't use parentheses around conditions.
# Enabled by default
# Style/ParenthesesAroundCondition
# Multiple expressions that exceeds line-length limit.
# Not implemented
# COMMENTS
# Only use multi-line comments for removing a block of code temporarily.
# Not implemented
# Do not use end-of-line comments.
Style/InlineComment:
Enabled: true
# Use TODO: to note task that needs to be done on a specific statement or block of code in the future.
# Use HACK: to note bad or questionable code that needs to be fixed.
# Use SEE: <insert link> if you need to add a reference to a specific statement or block of code.
# Partial implementation
Style/CommentAnnotation:
Keywords:
- TODO
- HACK
- SEE
# CLASS AND MODULE
# 1 line break before and after class and module contents.
Style/EmptyLinesAroundClassBody:
Enabled: true
EnforcedStyle: empty_lines
Style/EmptyLinesAroundModuleBody:
Enabled: true
EnforcedStyle: empty_lines
# 2 line breaks to separate logically grouped statements inside class and module.
# Not implemented
# 3 line breaks between class/module definitions.
# Not implemented
# 5 line breaks to separate logically grouped methods.
# Not implemented
# Always use self when calling public and protected properties of a class.
# Not implemented
# Conflict with Ruby Style Guide: https://github.com/bbatsov/ruby-style-guide#no-self-unless-required
# Disable default setting
Style/RedundantSelf:
Enabled: false
# Use header to describe group of methods if necessary.
# Not implemented
# Class statements order.
# Not implemented
# VISIBILITY MODIFIER
# Use protected for private methods that use instance variables/methods.
# Not implemented
# Use private for utility methods that don't use instance variables/methods.
# Not implemented
# MODEL
# Model statements order will be the same as the class statement order (see above). Rails model specific statements will be inserted on the Other macros here part.
# Not implemented
# Define the associated Models for a belongs_to association
# Not implemented
# FILTERS
# Prefer whitelisting over blacklisting as per Ruby on Rails Security Guide: When sanitizing, protecting or verifying something, prefer whitelists over blacklists.
# Not implemented
# RUBY STYLE GUIDE CONFLICTS
# The ff disable/configure default settings imposed by the Ruby Style Guide or Rubocop itself.
# Avoid methods longer than 10 lines of code.
# https://github.com/bbatsov/ruby-style-guide#short-methods
Metrics/MethodLength:
Enabled: false
# Checks style of children classes and modules.
# https://github.com/bbatsov/rubocop/issues/868
Style/ClassAndModuleChildren:
EnforcedStyle: compact
# Document classes and non-namespace modules.
Style/Documentation:
Enabled: false
# Don't use several empty lines in a row.
Style/EmptyLines:
Enabled: false
# Use the new lambda literal syntax for single-line blocks.
# https://github.com/bbatsov/ruby-style-guide#lambda-multi-line
Style/Lambda:
Enabled: false
# Use %w or %W for arrays of words.
# https://github.com/bbatsov/ruby-style-guide#percent-w
Style/WordArray:
Enabled: false
# RAILS STYLE GUIDE
# No conflicts
# Rails cops must be invoked manually: rubocop -R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment