# Configuration for the Rubocop code linting tool. See README. AllCops: DisabledByDefault: true DisplayStyleGuide: true SuggestExtensions: false Exclude: - db/schema.rb - vendor/**/* - node_modules/**/* - tmp/**/* - deploy/tmp/**/* # Enable all Security cops Security: Enabled: true # Allow: # # foo # .bar # # Disallow: # # foo. # bar # Layout/DotPosition: EnforcedStyle: leading # Allow: "foo" # Disallow: 'foo' Style/StringLiterals: EnforcedStyle: double_quotes StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#double-quote-strings-unless-the-string-contains-double-quotes #https://docs.rubocop.org/rubocop/cops_style.html#stylequotedsymbols Style/QuotedSymbols: EnforcedStyle: same_as_string_literals # Require a comma after the last item in a multi-line hash or array. # # The "consistent_comma" setting allows # # [ # 1, 2, # 3, # ] # # Whereas the "comma" setting seems to not want the comma after 3 if 1 and 2 were on the same line. Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: consistent_comma StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#add-commas-to-the-end-of-multiline-lists-and-hashes Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: consistent_comma StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#add-commas-to-the-end-of-multiline-lists-and-hashes # Allow: # # list.map { |x| x } # # Disallow: # # list.map{ |x| x } # # Not in our styleguide, but it's what we've done for the most part. Layout/SpaceBeforeBlockBraces: Enabled: true # Allow: # # list.map {|x| x } # # Disallow: # # list.map {|x| x } # # Not in our styleguide, but it's what we've done for the most part. Layout/SpaceInsideBlockBraces: Enabled: true # Allow: # # { a: 1 } # # Disallow: # # {a: 1} # Layout/SpaceInsideHashLiteralBraces: Enabled: true StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#whitespace-in-arrays-and-hashes # Allow: # # [ 1 ] # # Disallow: # # [1] # Layout/SpaceInsideArrayLiteralBrackets: EnforcedStyle: space StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#whitespace-in-arrays-and-hashes # Allow: # # "foo" + 1 * 2 / 3**4 # # Disallow: # # "foo"+1*2/3 ** 4 # # Not in our styleguide, but it's what we've done for the most part. Layout/SpaceAroundOperators: Enabled: true # bad: f( 3) # good: f(3) Layout/SpaceInsideParens: Enabled: true # bad: "foo #{ var } bar" # good: "foo #{var} bar" Layout/SpaceInsideStringInterpolation: Enabled: true # Disallow trailing whitespace. Layout/TrailingWhitespace: Enabled: true StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#avoid-trailing-whitespace # `BigDecimal.new` is deprecated on Ruby 2.5 in favour of `BigDecimal()`. Lint/BigDecimalNew: Enabled: true Lint/DuplicateMethods: Enabled: true Lint/DeprecatedClassMethods: Enabled: true Layout/EmptyLineAfterGuardClause: Enabled: true StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#put-a-blank-line-below-guard-statements # Allow: # # Date.new(2019, 1, 2) # # Disallow: # # Date.new(2019,1,2) # # Not in our styleguide, but it's what we've done for the most part. Layout/SpaceAfterComma: Enabled: true Style/NumericLiterals: Enabled: false Style/StabbyLambdaParentheses: Enabled: true EnforcedStyle: require_parentheses StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#lambdas-should-stab-their-arguments # Not in our styleguide, but it's what we've done for the most part. And it ensures "rubocop --auto-correct" doesn't make the StabbyLambdaParentheses rule add in unconventional-to-us spaces. Layout/SpaceInLambdaLiteral: Enabled: true EnforcedStyle: require_no_space Lint/RaiseException: Enabled: true # Skip redundant "begin"/"end" at the top level of method definitions or blocks. Style/RedundantBegin: Enabled: true # Allow: # # foo.bar # # Disallow: # # foo.bar() # Style/MethodCallWithoutArgsParentheses: Enabled: true # https://docs.rubocop.org/rubocop/cops_style.html#enforcedstyleformultiline-comma Style/TrailingCommaInArguments: Enabled: true EnforcedStyleForMultiline: comma # Warn about "too many positional arguments in the parameter list" when more than 5. # Warn about "too many positional arguments with optional values" when more than 3. Metrics/ParameterLists: Enabled: true CountKeywordArgs: false Max: 5 MaxOptionalParameters: 3 # https://docs.rubocop.org/rubocop/cops_lint.html#lintparenthesesasgroupedexpression Lint/ParenthesesAsGroupedExpression: Enabled: true # https://docs.rubocop.org/rubocop/cops_lint.html#lintuselessassignment Lint/UselessAssignment: Enabled: true # https://docs.rubocop.org/rubocop/cops_layout.html#layoutindentationwidth Layout/IndentationWidth: Enabled: true # https://docs.rubocop.org/rubocop/cops_layout.html#layoutindentationconsistency Layout/IndentationConsistency: Enabled: true # https://docs.rubocop.org/rubocop/cops_layout.html#layoutclassstructure # https://github.com/barsoom/devbook/tree/master/styleguide#use-a-consistent-class-layout # AutoCorrect: false because it has a tendency to make private delegates public, and it messes up whitespace Layout/ClassStructure: Enabled: true AutoCorrect: false ExpectedOrder: - module_inclusion - constants - association - public_attribute_macros - public_delegate - macros - public_class_methods - initializer - public_methods - protected_attribute_macros - protected_methods - private_attribute_macros - private_delegate - private_methods # https://docs.rubocop.org/rubocop/cops_style.html#stylehashsyntax Style/HashSyntax: Enabled: true EnforcedStyle: ruby19 Security/IoMethods: # new in 1.22 Enabled: true