# This styleguide is built on top of the default Rubocop styleguide, located here: # https://github.com/bbatsov/rubocop/blob/master/config/default.yml. require: rubocop-rails AllCops: # By default, Rubocop now displays warnings for all cops that are going to be enabled in the next # minor version. This disables those cops. We'll pick them up when Rubocop decided they're good # enough to enable by default for everyone. NewCops: disable Exclude: - 'db/schema.rb' - 'bin/*' - 'node_modules/**/*' - 'vendor/**/*' - 'tmp/**/*' ########## # LAYOUT # ########## Layout/ArgumentAlignment: EnforcedStyle: with_fixed_indentation Layout/BlockAlignment: EnforcedStyleAlignWith: start_of_block Layout/CaseIndentation: EnforcedStyle: end Layout/EmptyLinesAroundAttributeAccessor: Enabled: true # Unfortuantely, this rule can't be refined to the point of being useful. Layout/EmptyLinesAroundMethodBody: Enabled: false Layout/EmptyLinesAroundExceptionHandlingKeywords: Enabled: false Layout/EmptyLineAfterGuardClause: Enabled: false Layout/EmptyLinesAroundClassBody: Enabled: false Layout/EmptyLinesAroundBlockBody: Enabled: false Layout/EmptyLinesAroundModuleBody: Enabled: false Layout/EmptyLineBetweenDefs: AllowAdjacentOneLineDefs: true NumberOfEmptyLines: 1 Layout/EndAlignment: EnforcedStyleAlignWith: start_of_line Layout/EndOfLine: EnforcedStyle: lf Layout/ExtraSpacing: AllowForAlignment: false Layout/FirstArgumentIndentation: EnforcedStyle: consistent Layout/FirstArrayElementIndentation: EnforcedStyle: consistent Layout/FirstHashElementIndentation: EnforcedStyle: consistent Layout/HashAlignment: Enabled: false Layout/LineLength: Max: 100 AllowHeredoc: false AllowURI: false AutoCorrect: true Layout/MultilineMethodCallIndentation: EnforcedStyle: indented Layout/MultilineOperationIndentation: EnforcedStyle: indented # Ideally we'd be able to configure begin/rescue blocks to align how our other blocks do, but for # now there doesn't seem to be an option for it. # # TODO: Move this rule change to optimum-energy-rubocop-config. Layout/RescueEnsureAlignment: Enabled: false Layout/SpaceInsideArrayLiteralBrackets: EnforcedStyle: space Layout/SpaceAroundMethodCallOperator: Enabled: true Layout/SpaceAroundOperators: AllowForAlignment: false Layout/SpaceBeforeFirstArg: AllowForAlignment: false Layout/SpaceInsideStringInterpolation: EnforcedStyle: space ######## # LINT # ######## Lint/RaiseException: Enabled: true # Rubocop has a nasty habit of removing inline rule declarations, even when they're necessary. This # disables that behavior. Lint/RedundantCopEnableDirective: AutoCorrect: false Lint/StructNewOverride: Enabled: true Lint/UnusedBlockArgument: AutoCorrect: false Lint/UnusedMethodArgument: AutoCorrect: false ########### # METRICS # ########### Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: true Max: 100 Exclude: - 'spec/**/*' Metrics/ClassLength: Enabled: true Max: 300 Metrics/CyclomaticComplexity: Enabled: false Metrics/MethodLength: Max: 50 Metrics/ModuleLength: Enabled: false Metrics/PerceivedComplexity: Enabled: false ########## # NAMING # ########## Naming/FileName: ExpectMatchingDefinition: true Exclude: - 'config/**/*' - 'bin/**/*' - 'db/**/*' - 'spec/**/*' - '**/config.ru' - 'lib/tasks/**' Naming/RescuedExceptionsVariableName: PreferredName: exception ######### # RAILS # ######### Rails: Enabled: true Rails/BulkChangeTable: Enabled: false Rails/Date: EnforcedStyle: strict Rails/FilePath: Enabled: false # By default, the Rubocop Rails rules warn against using has_and_belongs_to_many. This disables that # behavior. Don't you tell me what to do Rubocop. Rails/HasAndBelongsToMany: Enabled: false Rails/NotNullColumn: Enabled: false Rails/RequestReferer: EnforcedStyle: referrer Rails/TimeZone: EnforcedStyle: strict ######### # STYLE # ######### Style/AccessModifierDeclarations: EnforcedStyle: inline Style/ClassAndModuleChildren: Enabled: false Style/ConditionalAssignment: EnforcedStyle: assign_to_condition Style/Copyright: Enabled: false Style/Documentation: Enabled: false Style/DoubleNegation: Enabled: false Style/EachWithObject: Enabled: false Style/EmptyMethod: AutoCorrect: false Style/ExponentialNotation: Enabled: true AutoCorrect: true Style/FormatString: EnforcedStyle: percent # This rule is wrong for Rails validation messages. Style/FormatStringToken: Enabled: false # TODO: This won't be necessary when we upgrade to Ruby 3.0. Until then, rather than adding a # comment to every file, we should only add it to the files where it's necessary. Style/FrozenStringLiteralComment: EnforcedStyle: never Style/HashEachMethods: Enabled: true Style/HashTransformKeys: Enabled: true Style/HashTransformValues: Enabled: true Style/MultilineBlockChain: Enabled: false Style/MultilineTernaryOperator: Enabled: false Style/PercentLiteralDelimiters: Enabled: false Style/RegexpLiteral: Enabled: false Style/ReturnNil: Enabled: true Style/SlicingWithRange: Enabled: true Style/StringLiterals: EnforcedStyle: double_quotes Style/SymbolArray: MinSize: 3 Style/WordArray: MinSize: 3