require: - rubocop-rails - rubocop-rspec # We exclude files that are generated automatically or test data. AllCops: Exclude: - "vendor/**/*" - "db/schema.rb" - "db/migrate/*" - "db/fixtures/**/*" - "test/factories/**/*" - "spec/factories/**/*" - "spec/test_app/db/*" DisplayCopNames: true NewCops: enable Rails: Enabled: true # For rails >= 5. TODO: This should be enabled in my opinion. Rails/HttpPositionalArguments: Enabled: false Rails/InverseOf: Enabled: false Rails/UnknownEnv: Environments: - production - staging - development - local - test Gemspec/OrderedDependencies: Enabled: false ##################### Style ################################## # We sometimes use non-ascii comments. Style/AsciiComments: Enabled: false # We prefer trailing comma all the time. Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: comma Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: comma Style/TrailingCommaInArguments: EnforcedStyleForMultiline: comma # We sometimes omit the top-level documentation for classes/modules. Style/Documentation: Enabled: false # We sometimes want to use `self` anyway. Style/RedundantSelf: Enabled: false # We want to allow the code like this: # # xs.select { # f x # }.map { |x| # f x # f x # }.compact Style/BlockDelimiters: Enabled: false Style/MultilineBlockChain: Enabled: false Style/EmptyMethod: Enabled: false # We sometimes want to use empty case when there are many conditions. Style/EmptyCaseCondition: Enabled: false Style/DoubleNegation: Enabled: false Style/ParallelAssignment: Enabled: false Style/MethodCallWithoutArgsParentheses: Enabled: false Style/DefWithParentheses: Enabled: false # This might not be a style cop because errors happen due to the order of tests with nested classes/modules. Style/ClassAndModuleChildren: Exclude: - "test/**/*.rb" - "spec/**/*.rb" # This style differs from the expression of SQL. Style/NumericLiterals: Exclude: - "db/fixtures/*.rb" ##################### Layout ################################## # We sometimes want to put multiple spaces before arguments. Layout/SpaceBeforeFirstArg: Enabled: false Layout/SpaceInLambdaLiteral: Enabled: false Layout/HeredocIndentation: Enabled: false # We want to allow various expression for arguments. # # foo(a, # b # ) # foo( # a, # b) # foo( # a, # b # ) # foo(a, # b) Layout/MultilineMethodCallBraceLayout: Enabled: false # We don't want to enforce various method calls. # # while a # .b # something # end # while a # .b # something # end # Thing.a # .b # .c # while a # .b # something # end Layout/MultilineMethodCallIndentation: Enabled: false # Sometimes, we want to write like this: # # aaa(bbb( # ccc # )) Layout/FirstParameterIndentation: Enabled: false # We want to allow both of them: # # aaa. # bb(). # cc() # aaa # .bb() # .cc() # # The first one allows us to insert comments, and it would be convenient. # The second one is the default of this Cop. Layout/DotPosition: Enabled: false # We want to consistently write fixture files with the rule: 1 line for 1 record. # It's not intuitive with multiple lines. Layout/ClosingParenthesisIndentation: Exclude: - "db/fixtures/*.rb" Layout/ParameterAlignment: Exclude: - "db/fixtures/*.rb" Layout/LineLength: Max: 160 Exclude: - "db/migrate/*.rb" - "db/fixtures/*.rb" # Fixture files usually include long lines. ##################### Lint ################################## # We sometimes want to put spaces before arguments. Lint/ParenthesesAsGroupedExpression: Enabled: false ##################### Metrics ################################## # There is something wrong with more than 20 lines aside from migration files. Metrics/MethodLength: Max: 20 Exclude: - "db/migrate/*.rb" # We want to measure this metrics without keyword arguments. Metrics/ParameterLists: CountKeywordArgs: false Metrics/BlockLength: Max: 100 Exclude: - "spec/**/*.rb" - "test/**/*.rb" - "app/admin/*.rb" - "config/**/*.rb" Metrics/AbcSize: Exclude: - "test/**/*.rb" Metrics/ClassLength: Exclude: - "test/**/*.rb" # Does the variable name for an exception object really matter? # There are many things to think about before taking care of it. Naming/RescuedExceptionsVariableName: Enabled: false