.rubocop.yml
inherit_from:
- .rubocop_todo.yml
AllCops:
TargetRubyVersion: 2.3
# Exclude anything that isn't really part of our code.
# rails_helper is excluded because it's full of solecisms, but it's mostly
# generated code and copy-and-pasted snipets from READMEs.
Exclude:
- 'Guardfile'
- 'vendor/**/*'
- 'db/**/*'
- 'bin/**/*'
- '**/*.gemspec'
- '**/Rakefile'
- '**/Vagrantfile'
- 'spec/rails_helper.rb'
- 'lib/tasks/cucumber.rake'
- 'features/support/env.rb'
- 'test_common/page_objects/**/*'
- 'script/cucumber'
- 'lib/log_stuff.rb'
- 'config/routes.rb'
- 'Gemfile'
Rails:
Enabled: true
# Allow long lines in specs, as it's almost impossible to fit RSpec's
# expectations into 80 characters.
Metrics/LineLength:
Max: 120
Exclude:
- 'features/**/*'
- 'spec/**/*'
- 'test_common/**/*'
- 'Gemfile'
Metrics/ModuleLength:
Max: 120
Exclude:
- 'test_common/helpers/**/*'
Metrics/AbcSize:
Exclude:
- 'spec/**/*'
- 'test_common/**/*'
# Allow expect {}.to blocks in specs
# but not in the code
Style/BlockDelimiters:
Enabled: true
Exclude:
- 'spec/**/*'
Style/AsciiComments:
Enabled: true
Exclude:
- 'spec/**/*'
Layout/TrailingBlankLines:
Enabled: true
# Don't worry about long methods in specs.
Metrics/MethodLength:
Exclude:
- 'spec/**/*'
- 'app/models/ability.rb'
- 'config/initializers/markdown_handler.rb'
# No need to check for describe class param in support files.
RSpec/DescribeClass:
Exclude:
- spec/support/**/*
- spec/views/**/*
Rails/FilePath:
Exclude:
- spec/routing/**/*
# private/protected/public
Layout/AccessModifierIndentation:
EnforcedStyle: indent
# Just indent parameters by two spaces. It's less volatile if methods change,
# and there's less busy work lining things up.
Layout/AlignParameters:
EnforcedStyle: with_fixed_indentation
Style/ClassAndModuleChildren:
EnforcedStyle: nested
Style/CollectionMethods:
PreferredMethods:
collect: 'map'
collect!: 'map!'
each_with_object: 'inject'
inject: 'inject'
reduce: 'inject'
detect: 'find'
find_all: 'select'
# Chain methods with trailing dots.
Layout/DotPosition:
EnforcedStyle: trailing
# No, we don't prefer each_with_object
Style/EachWithObject:
Enabled: false
# Prefer blank line after class/module start.
Layout/EmptyLinesAroundClassBody:
Enabled: false
Layout/EmptyLinesAroundModuleBody:
Enabled: false
Layout/EmptyLinesAroundBlockBody:
Enabled: false
# We have a mixture at the moment, so don't enforce anything.
Style/FormatString:
Enabled: false
# It's not really clearer to replace every if with a return if.
Style/GuardClause:
Enabled: false
# Groups of three is not always the right thing for numeric literals
Style/NumericLiterals:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
# Percent-formatting and hash interpolation both have their place. Don't
# enforce any particular one.
Style/StringLiterals:
Enabled: false
# I'm happy with raise, thanks.
Style/SignalException:
Enabled: false
# Let us use foo? methods
Style/TrivialAccessors:
AllowPredicates: true
Style/MixinUsage:
Enabled: true
Exclude:
- 'spec/**/*'
- 'features/**/*'
# Prefer sensible naming to comments everywhere.
Documentation:
Description: Document classes and non-namespace modules.
Enabled: false
# Would enforce do_y if x over if x / do y / end. As with GuardClause above,
# this enforces code organisation that doesn't necesarily make things clearer.
IfUnlessModifier:
Enabled: false
# Allow safe assignment in conditions.
Lint/AssignmentInCondition:
AllowSafeAssignment: false
# Just a preference to use %w[] over %w()
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%w': '[]'
'%W': '[]'
'%i': '[]'
# %w doesn't always make for clearer test data
Style/WordArray:
EnforcedStyle: brackets
Style/SymbolArray:
EnforcedStyle: brackets
RSpec/NestedGroups:
Max: 10
RSpec/ExpectActual:
Exclude:
- 'spec/routing/**/*'
Metrics/BlockLength:
Exclude:
- 'spec/**/*'
- 'test_common/**/*'
- 'config/**/*'
- 'lib/tasks/**/*'
Layout/EmptyLineAfterMagicComment:
Enabled: false
# ---------------
# HttpPositionalArguments is rails 5 only
# https://github.com/bbatsov/rubocop/issues/3629
# ---------------
Rails/HttpPositionalArguments:
Enabled: false
RSpec/MultipleExpectations:
Exclude:
- 'spec/features/**/*'
RSpec/ExampleLength:
Exclude:
- 'spec/**/*'
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
Rails/OutputSafety:
Exclude:
- 'app/helpers/yaml_helper.rb'
Capybara/FeatureMethods:
Exclude:
- 'spec/features/**/*'
Naming/PredicateName:
Exclude:
- 'test_common/**/*'
require: rubocop-rspec