# This file contains NDR's agreed deviations from the standard Ruby # Style Guide, the configuration for which can be found here: # https://github.com/bbatsov/rubocop/blob/master/config/default.yml # # See the README for instructions on using in a project. require: - rubocop-rails - rubocop-rake AllCops: # Given we take a "follow the herd" approach, with this file # containing just deviations, enable new cops by default. NewCops: enable # All cops should ignore files in the following locations: Exclude: - 'bin/*' - 'db/schema.rb' - 'lib/generators/**/templates/*' - 'tmp/**/*' - 'vendor/**/*' # Once supported by RuboCop, this will prevent cop-specific Excludes from # overwriting the AllCops defaults above: # # inherit_mode: # merge: # - Exclude # Run the Rails cops by default (-R/--rails not required): Rails: Enabled: true ##################### Layout ################################# Layout/DotPosition: # Multi-line method chaining should be done with trailing dots. EnforcedStyle: trailing Layout/HashAlignment: EnforcedColonStyle: - key - table EnforcedHashRocketStyle: - key - table ##################### Style ################################## # We make use of block comments, e.g. for validation documentation. Style/BlockComments: Enabled: false Style/Documentation: Exclude: - 'test/**/*.rb' Style/FrozenStringLiteralComment: # We're not confident enough to make this recommendation everywhere Enabled: false Style/ModuleFunction: # `extend self` has fewer side effects than `module_function`. EnforcedStyle: extend_self Style/NumericLiterals: Exclude: - 'db/migrate/*.rb' - 'test/**/*.rb' Style/YodaCondition: # Disagree; literals as first argument can guard against accidental assignment. Enabled: false Style/SingleLineBlockParams: # Prefer readability of contextually-named variables. Enabled: false ##################### Metrics ################################## # NOTE: we bump some metrics by 50%, in recognition of Rubocop's # desire to split that which we would consider atomic. Metrics/AbcSize: Max: 23 Exclude: - 'db/migrate/*.rb' - 'test/**/*.rb' Metrics/BlockLength: # We're already limiting method size, blocks outside of methods # can legitimately be long (RuboCop defaults to max: 25 lines). Enabled: false Metrics/ClassLength: Max: 150 Exclude: - 'db/migrate/*.rb' - 'test/**/*.rb' Metrics/ModuleLength: Max: 150 Exclude: - 'test/**/*.rb' Metrics/CyclomaticComplexity: Max: 9 Layout/LineLength: Exclude: - 'db/migrate/*.rb' - 'test/**/*.rb' Metrics/MethodLength: Max: 15 Exclude: - 'db/migrate/*.rb' - 'test/**/*.rb' Metrics/PerceivedComplexity: Max: 12 ##################### Rails ################################## Rails/ActionFilter: # 'action' is the default already; we explicitly list here as Rails 3.x # projects will want to override this configuration to use 'filter' instead. EnforcedStyle: action Rails/DynamicFindBy: Exclude: - 'test/integration/**/*.rb' Rails/RakeEnvironment: # Particularly without spring, this can make things that should be quick # slower than desirable. Enabled: false Rails/RefuteMethods: Enabled: false Rails/SkipsModelValidations: # Methods like 'update_column' exist for a reason, and it is the developer's # responsibilty to understand the behaviour of the code they write; blanket # avoiding them is not helpful/practical. Enabled: false Style/HashSyntax: EnforcedShorthandSyntax: either