|
| 1 | +# This file defines all the linter rules for the project. |
| 2 | +# See the list of the rules which are called "cops" |
| 3 | +# https://docs.rubocop.org/rubocop/cops.html |
| 4 | +# https://docs.rubocop.org/rubocop-rails/cops_rails.html |
| 5 | + |
| 6 | +# These configurations are *largely* the rubocop defaults. |
| 7 | +# We've relaxed some configurations that may be harder to meet while |
| 8 | +# you are learning. |
| 9 | + |
| 10 | +# rubocop allows us to go simply beyond code formatting and also focus on |
| 11 | +# best practices, like code complexity. |
| 12 | + |
| 13 | +require: |
| 14 | + - rubocop-rails |
| 15 | + - rubocop-rspec |
| 16 | + |
| 17 | +AllCops: |
| 18 | + NewCops: enable |
| 19 | + TargetRubyVersion: 2.6 |
| 20 | + Exclude: |
| 21 | + - bin/* |
| 22 | + - config/routes.rb |
| 23 | + - db/schema.rb |
| 24 | + - db/seed_data.rb |
| 25 | + - db/seeds.rb |
| 26 | + - features/step_definitions/web_steps.rb |
| 27 | + - features/support/paths.rb |
| 28 | + - features/support/selectors.rb |
| 29 | + - Guardfile |
| 30 | + - lib/tasks/cucumber.rake |
| 31 | + - node_modules/**/* |
| 32 | + - vendor/**/* |
| 33 | + |
| 34 | +Layout/EndOfLine: |
| 35 | + EnforcedStyle: lf |
| 36 | + |
| 37 | +Lint/AmbiguousRegexpLiteral: |
| 38 | + Exclude: |
| 39 | + - features/step_definitions/* |
| 40 | + |
| 41 | +Style/CommentAnnotation: |
| 42 | + Keywords: |
| 43 | + - CS169 |
| 44 | + - ACTION-MAP |
| 45 | + - TODO |
| 46 | + - HACK |
| 47 | + - REVIEW |
| 48 | + |
| 49 | +Rails: |
| 50 | + Enabled: true |
| 51 | + |
| 52 | +Gemspec/RequiredRubyVersion: |
| 53 | + Enabled: true |
| 54 | + |
| 55 | +Layout/EmptyLineAfterGuardClause: |
| 56 | + Enabled: true |
| 57 | + |
| 58 | +# No space makes the method definition shorter and differentiates |
| 59 | +# from a regular assignment. |
| 60 | +Layout/SpaceAroundEqualsInParameterDefault: |
| 61 | + EnforcedStyle: no_space |
| 62 | + |
| 63 | +# Most readable form. |
| 64 | +Layout/HashAlignment: |
| 65 | + EnforcedHashRocketStyle: table |
| 66 | + EnforcedColonStyle: table |
| 67 | + |
| 68 | +Layout/LineLength: |
| 69 | + Max: 120 |
| 70 | + |
| 71 | +Lint/RaiseException: |
| 72 | + Enabled: true |
| 73 | + |
| 74 | +Lint/StructNewOverride: |
| 75 | + Enabled: true |
| 76 | + |
| 77 | +# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsabcsize |
| 78 | +Metrics/AbcSize: |
| 79 | + Max: 30 |
| 80 | + Enabled: true |
| 81 | + |
| 82 | +Metrics/BlockLength: |
| 83 | + IgnoredMethods: |
| 84 | + - describe |
| 85 | + - context |
| 86 | + - shared_examples |
| 87 | + - namespace |
| 88 | + - ActiveRecord::Schema.define |
| 89 | + |
| 90 | +# Skips style of child classes and modules. |
| 91 | +Style/ClassAndModuleChildren: |
| 92 | + Enabled: false |
| 93 | + |
| 94 | +Style/CollectionMethods: |
| 95 | + Enabled: true |
| 96 | + PreferredMethods: |
| 97 | + reduce: "inject" |
| 98 | + |
| 99 | +Style/Documentation: |
| 100 | + Enabled: false |
| 101 | + |
| 102 | +Style/HashEachMethods: |
| 103 | + Enabled: true |
| 104 | + AutoCorrect: false # Unsafe autocorrect |
| 105 | + |
| 106 | +Style/HashTransformKeys: |
| 107 | + Enabled: true |
| 108 | + AutoCorrect: false # Unsafe autocorrect |
| 109 | + |
| 110 | +Style/HashTransformValues: |
| 111 | + Enabled: true |
| 112 | + AutoCorrect: false # Unsafe autocorrect |
| 113 | + |
| 114 | +# Mixing the styles looks just silly. |
| 115 | +Style/HashSyntax: |
| 116 | + EnforcedStyle: ruby19_no_mixed_keys |
| 117 | + |
| 118 | +# has_key? and has_value? are far more readable than key? and value? |
| 119 | +Style/PreferredHashMethods: |
| 120 | + EnforcedStyle: verbose |
| 121 | + |
| 122 | +Metrics/MethodLength: |
| 123 | + Max: 20 |
| 124 | + |
| 125 | +RSpec/InstanceVariable: |
| 126 | + Enabled: false |
| 127 | + |
| 128 | +RSpec/DescribeClass: |
| 129 | + Exclude: |
| 130 | + - spec/linters/* |
| 131 | + |
| 132 | +# Ideally, you'd want no more than 2. |
| 133 | +RSpec/MultipleExpectations: |
| 134 | + Max: 4 |
| 135 | + |
| 136 | +RSpec/RepeatedExample: |
| 137 | + Enabled: false |
0 commit comments