# Defaults https://github.com/bbatsov/rubocop/blob/master/config/default.yml AllCops: Exclude: # Exclude .gemspec files because they are generally auto-generated - '*.gemspec' # In most cases, Gems are sorted alphabetically. # However, in some few cases the order is relevant due to dependencies. Bundler/OrderedGems: Enabled: false # Generally, the keyword style uses a lot of space. This is particularly true when # you use case/if statements, in combination with a long-name variable. # # invoice_error_message = case error # when 1 == 1 # do_something # else # do_else # end # Lint/EndAlignment: EnforcedStyleAlignWith: variable # [codesmell] Lint/HandleExceptions: Enabled: false # [codesmell] Metrics/AbcSize: Enabled: false Exclude: - 'spec/**/*_spec.rb' - 'test/**/*_test.rb' # [codesmell] Metrics/BlockLength: Enabled: false # [codesmell] Metrics/CyclomaticComplexity: Enabled: false Exclude: - 'spec/**/*_spec.rb' - 'test/**/*_test.rb' # [codesmell] Metrics/ClassLength: Enabled: false Exclude: - 'spec/**/*_spec.rb' - 'test/**/*_test.rb' # [codesmell] Metrics/LineLength: Enabled: false Exclude: - 'spec/**/*_spec.rb' - 'test/**/*_test.rb' Max: 100 # [codesmell] Metrics/MethodLength: Enabled: false Exclude: - 'spec/**/*_spec.rb' - 'test/**/*_test.rb' Max: 10 # [codesmell] Metrics/ModuleLength: Enabled: false Exclude: - 'spec/**/*_spec.rb' - 'test/**/*_test.rb' # [codesmell] Metrics/ParameterLists: Enabled: false Max: 5 # [codesmell] Metrics/PerceivedComplexity: Enabled: false # [codesmell] # I don't really get the point of this cop. Performance/RedundantMerge: Enabled: false # Do not use "and" or "or" in conditionals, but for readability we can use it # to chain executions. Just beware of operator order. Style/AndOr: EnforcedStyle: conditionals # No specific reason, except that %q() is easier to grep than %() Style/BarePercentLiterals: EnforcedStyle: percent_q # braces_for_chaining seems a good fit of what we've been doing so far. Style/BlockDelimiters: EnforcedStyle: braces_for_chaining IgnoredMethods: - expect # I'm not sure we should enforce a style, # but if we do, context_dependent offers a good compromise on readability. Style/BracesAroundHashParameters: Enabled: false EnforcedStyle: context_dependent # Warn on empty else. Style/EmptyElse: EnforcedStyle: empty # There is no specific preference for empty methods. # One-line methods are not exceptionally nice in Ruby. Just ignore this cop for now. Style/EmptyMethod: Enabled: false # I personally don't care about the format style. # In most cases I like to use %, but not at the point I want to enforce it # as a convention in the entire code. Style/FormatString: Enabled: false # We don't support frozen strings. # This is an experimental feature and we don't know if it will be shipped with # Ruby 3.0 or not. Style/FrozenStringLiteralComment: Enabled: false # Prefer the latest Hash syntax Style/HashSyntax: Exclude: # But Rakefiles generally have some definition like # :default => :test # that looks nicer with the old rocket syntax. - 'Rakefile' # We want to be able to decide when to use one-line if/unless modifiers. Style/IfUnlessModifier: Enabled: false # [codesmell] # It's not always that bad. Style/IfInsideElse: Enabled: false # module_function doesn't respect the visibility of the methods, # and doesn't work well when the module contain both public/private methods. Style/ModuleFunction: Enabled: false Style/MultilineBlockChain: Exclude: # RSpec uses multi-line blocks for certain features - 'spec/**/*_spec.rb' # unless is not always cool. Style/NegatedIf: Enabled: false # Magic numbers are not welcomed Style/NumericLiterals: Exclude: # however tests can use numeric literals for method calls, # without the need to define a variable just for that. - 'spec/**/*_spec.rb' - 'test/**/*_test.rb' # For years, %w() has been the de-facto standard. A lot of libraries are using (). # Switching to [] would be a nightmare. Style/PercentLiteralDelimiters: Enabled: false # We use it from time to time, as it's not always possible (or maintainable) # to use simple ? methods. # Moreover, it's actually more efficient to not-use predicates: # https://github.com/bbatsov/rubocop/issues/3633 Style/PredicateName: Enabled: false # Do we care? Style/RegexpLiteral: Enabled: false # There are cases were the inline rescue is ok. We can either downgrade the severity, # or rely on the developer judgement on a case-by-case basis. Style/RescueModifier: Enabled: false # This is quite annoying, especially in cases where we don't control it (e.g. schema.rb). Style/SymbolArray: Enabled: false # We don't have a preference. Style/SpecialGlobalVars: Enabled: false EnforcedStyle: use_perl_names # We generally use double quotes, sometimes single quotes. # Should we enforce it at code level? Style/StringLiterals: Enabled: false EnforcedStyle: double_quotes # As before. Style/StringLiteralsInInterpolation: Enabled: false EnforcedStyle: double_quotes # It's nice to be consistent. The trailing comma also allows easy reordering, # and doesn't cause a diff in Git when you add a line to the bottom. Style/TrailingCommaInLiteral: EnforcedStyleForMultiline: consistent_comma Style/TrivialAccessors: # IgnoreClassMethods because I want to be able to define class-level accessors # that sets an instance variable on the metaclass, such as: # # def self.default=(value) # @default = value # end # IgnoreClassMethods: true Style/WordArray: EnforcedStyle: percent MinSize: 3 # Forces the order of comparison arguments. # # According to this cop, the following statement is bad: # # "https" == uri.scheme # # Whereas the following is considered good: # # uri.scheme == "https" Style/YodaCondition: Enabled: false # For the same reason of EndAlignment, aligning with the case may have a bad impact # on a case after a very long variable. # # invoice_error_message = case error # when 1 == 1 # do_something # else # do_else # end # Layout/CaseIndentation: EnforcedStyle: end # I was a big fan of leading, but trailing seems to be more commonly adopted. # At least at the time being. Layout/DotPosition: EnforcedStyle: leading # Double empty lines are useful to separate conceptually different methods # in the same class or module. Layout/EmptyLines: Enabled: false Layout/EmptyLinesAroundBlockBody: Exclude: # RSpec is all made of blocks. Disable this config in RSpec # to be consistent with EmptyLinesAroundClassBody and EmptyLinesAroundModuleBody - 'spec/**/*_spec.rb' - 'test/**/*_test.rb' # In most cases, a space is nice. Sometimes, it's not. # Just be consistent with the rest of the surrounding code. Layout/EmptyLinesAroundClassBody: Enabled: false # We're ok with it. We use it quite often for method-level rescue statements. Layout/EmptyLinesAroundExceptionHandlingKeywords: Enabled: false # In most cases, a space is nice. Sometimes, it's not. # Just be consistent with the rest of the surrounding code. Layout/EmptyLinesAroundModuleBody: Enabled: false # This is quite buggy, as it doesn't recognize double lines. Layout/EmptyLineBetweenDefs: Enabled: false # Multi-line differs from standard indentation, they are indented twice. Layout/FirstParameterIndentation: IndentationWidth: 4 # Array indentation should be considered like MultilineMethodCallIndentation indentation # and use 4 spaces instead of 2. Layout/IndentArray: IndentationWidth: 4 # Hash indentation should be considered like MultilineMethodCallIndentation indentation # and use 4 spaces instead of 2. Layout/IndentHash: IndentationWidth: 4 # Multi-line differs from standard indentation, they are indented twice. Layout/MultilineMethodCallIndentation: EnforcedStyle: indented IndentationWidth: 4 # Multi-line differs from standard indentation, they are indented twice. Layout/MultilineOperationIndentation: EnforcedStyle: indented IndentationWidth: 4 # Sorry, but using trailing spaces helps readability. # # %w( foo bar ) # # looks better to me than # # %w( foo bar ) # Layout/SpaceInsidePercentLiteralDelimiters: Enabled: false