################# ## DVLA Specials ################# AllCops: TargetRubyVersion: 3.0 ############ ## General ############ Layout/BlockAlignment: Description: "Align block ends correctly." Enabled: true Layout/CaseIndentation: Description: Indentation of when in a case/when/[else/]end. Enabled: true EnforcedStyle: case SupportedStyles: - case - end IndentOneStep: false Layout/ClosingParenthesisIndentation: Description: "Checks the indentation of hanging closing parentheses." Enabled: false Style/MutableConstant: Description: "Freeze mutable objects assigned to constants." Enabled: true Lint/ElseLayout: Description: "Check for odd code arrangement in an else block." Enabled: true # Supports --auto-correct Layout/EmptyLineBetweenDefs: Description: Use empty lines between defs. Enabled: true AllowAdjacentOneLineDefs: false Layout/EmptyLines: Description: "Don't use several empty lines in a row." Enabled: true Layout/EndAlignment: Description: "Align ends correctly." Enabled: true Layout/EndOfLine: Description: "Use Unix-style line endings." Enabled: true # Supports --auto-correct Layout/IndentationWidth: Description: Use 2 spaces for indentation. Enabled: true # Supports --auto-correct Layout/IndentationConsistency: Description: Keep indentation straight. Enabled: true Layout/LineContinuationLeadingSpace: Description: Checks that strings broken over multiple lines have leading/trailing spaces Enabled: true Layout/LineContinuationSpacing: Description: Checks that the backslash of a line continuation is separated from preceeding text by exactly one or zero spaces Enabled: true Layout/LineLength: Description: Limit lines to 80 characters. Enabled: false Max: 120 # Supports --auto-correct Layout/SpaceAroundOperators: Description: Use spaces around operators. Enabled: true # Supports --auto-correct Layout/SpaceBeforeBlockBraces: Description: Checks that the left block brace has or doesn't have space before it. Enabled: true EnforcedStyle: space SupportedStyles: - space - no_space # Supports --auto-correct Layout/SpaceAfterSemicolon: Description: Use spaces after semicolons. Enabled: true # Supports --auto-correct Layout/SpaceAfterColon: Description: Use spaces after colons. Enabled: true # Supports --auto-correct Layout/SpaceAfterComma: Description: Use spaces after commas. Enabled: true # Supports --auto-correct Layout/SpaceInsideReferenceBrackets: Description: No spaces after array[ or before ]. Enabled: true # Supports --auto-correct Layout/SpaceInsideArrayLiteralBrackets: Description: No spaces after array = [ or before ]. Enabled: true # Supports --auto-correct Layout/SpaceInsideParens: Description: No spaces after ( or before ). Enabled: true Layout/IndentationStyle: Description: No hard tabs. Enabled: true # Supports --auto-correct Layout/TrailingWhitespace: Description: Avoid trailing whitespace. Enabled: true # Supports --auto-correct Layout/TrailingEmptyLines: Description: Checks trailing blank lines and final newline. Enabled: true EnforcedStyle: final_newline SupportedStyles: - final_newline - final_blank_line ## Syntax # Supports --auto-correct Style/AndOr: Description: Use &&/|| instead of and/or. Enabled: true # Supports --auto-correct Style/DefWithParentheses: Description: Use def with parentheses when there are arguments. Enabled: true Style/For: Description: Checks use of for or each in multiline loops. Enabled: true EnforcedStyle: each SupportedStyles: - for - each Style/IfUnlessModifier: Description: Favor modifier if/unless usage when you have a single-line body. Enabled: false Style/MethodCalledOnDoEndBlock: Description: Avoid chaining a method call on a do...end block. Enabled: false Style/MethodCallWithoutArgsParentheses: Description: "Do not use parentheses for method calls with no arguments." Enabled: true Style/MultilineBlockChain: Description: Avoid multi-line chains of blocks. Enabled: true Style/MultilineIfThen: Description: Never use then for multi-line if/unless. Enabled: true Style/MultilineTernaryOperator: Description: "Avoid multi-line ?: (the ternary operator); use if/unless instead." Enabled: true Style/NestedTernaryOperator: Description: Use one expression per branch in a ternary operator. Enabled: true Style/OneLineConditional: Description: Favor the ternary operator(?:) over if/then/else/end constructs. Enabled: true # Supports --auto-correct Style/ParenthesesAroundCondition: Description: Don't use parentheses around the condition of an if/unless/while. Enabled: true AllowSafeAssignment: true # Supports --auto-correct Style/RedundantReturn: Description: Don't use return where it's not required. Enabled: true AllowMultipleReturnValues: false # Supports --auto-correct Layout/SpaceAfterMethodName: Description: Never put a space between a method name and the opening parenthesis in a method definition. Enabled: true # Supports --auto-correct Layout/SpaceAroundEqualsInParameterDefault: Description: Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration. Enabled: true EnforcedStyle: space SupportedStyles: - space - no_space Style/UnlessElse: Description: Never use unless with else. Rewrite these with the positive case first. Enabled: true # Supports --auto-correct Lint/UnusedBlockArgument: Description: Checks for unused block arguments. Enabled: true Style/EmptyElse: Description: "Checks for empty else blocks. Causes issues when assigning a variable to a conditional statement." Enabled: false ## Naming Naming/ClassAndModuleCamelCase: Description: Use CamelCase for classes and modules. Enabled: true # Supports --auto-correct Style/ClassMethods: Description: Use self when defining module/class methods. Enabled: true Style/ClassVars: Description: Avoid the use of class variables. Enabled: true Naming/ConstantName: Description: Constants should use SCREAMING_SNAKE_CASE. Enabled: true Naming/MethodName: Description: Use the configured style when naming methods. Enabled: true EnforcedStyle: snake_case SupportedStyles: - snake_case - camelCase # Supports --auto-correct Style/TrivialAccessors: Description: Prefer attr_* methods to trivial readers/writers. Enabled: true ExactNameMatch: true AllowPredicates: true AllowDSLWriters: false AllowedMethods: - to_ary - to_a - to_c - to_enum - to_h - to_hash - to_i - to_int - to_io - to_open - to_path - to_proc - to_r - to_regexp - to_str - to_s - to_sym Naming/VariableName: Description: Use the configured style when naming variables. Enabled: true EnforcedStyle: snake_case SupportedStyles: - snake_case - camelCase ## Exceptions # Supports --auto-correct Lint/RescueException: Description: Avoid rescuing the Exception class. Enabled: true ## Collections # Supports --auto-correct Layout/ArrayAlignment: Description: Align the elements of an array literal if they span more than one line. Enabled: true # Supports --auto-correct Style/HashSyntax: Description: "Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax { :a => 1, :b => 2 }." Enabled: true Exclude: - "db/schema.rb" EnforcedStyle: ruby19 SupportedStyles: - ruby19 - hash_rockets Style/TrailingCommaInArrayLiteral: Enabled: true EnforcedStyleForMultiline: comma Style/TrailingCommaInHashLiteral: Enabled: true EnforcedStyleForMultiline: comma Style/TrailingCommaInArguments: Enabled: true EnforcedStyleForMultiline: comma # Supports --auto-correct Style/WordArray: Description: Use %w or %W for arrays of words. Enabled: true MinSize: 0 Layout/MultilineMethodCallIndentation: Enabled: false ## Strings # Supports --auto-correct Lint/RedundantStringCoercion: Description: Checks for Object#to_s usage in string interpolation. Enabled: true # Supports --auto-correct Style/StringLiterals: Description: Checks if uses of quotes match the configured preference. Enabled: true EnforcedStyle: single_quotes SupportedStyles: - single_quotes - double_quotes ## New Rules yet to be configured Lint/RaiseException: Enabled: false Lint/StructNewOverride: Enabled: false Style/HashEachMethods: Enabled: false Style/HashTransformKeys: Enabled: false Style/HashTransformValues: Enabled: false Layout/EmptyLinesAroundAttributeAccessor: Enabled: false Layout/SpaceAroundMethodCallOperator: Enabled: false Lint/DeprecatedOpenSSLConstant: Enabled: false Lint/DuplicateElsifCondition: Enabled: false Lint/MixedRegexpCaptureTypes: Enabled: false Style/AccessorGrouping: Enabled: false Style/ArrayCoercion: Enabled: false Style/BisectedAttrAccessor: Enabled: false Style/CaseLikeIf: Enabled: false Style/ExponentialNotation: Enabled: false Style/HashAsLastArrayItem: Enabled: false Style/HashLikeCase: Enabled: false Style/RedundantAssignment: Enabled: false Style/RedundantFetchBlock: Enabled: false Style/RedundantFileExtensionInRequire: Enabled: false Style/RedundantRegexpCharacterClass: Enabled: false Style/RedundantRegexpEscape: Enabled: false Style/SlicingWithRange: Enabled: false Rails/ActiveRecordCallbacksOrder: Enabled: false Rails/AfterCommitOverride: Enabled: false Rails/FindById: Enabled: false Rails/Inquiry: Enabled: false Rails/MailerName: Enabled: false Rails/MatchRoute: Enabled: false Rails/NegateInclude: Enabled: false Rails/Pluck: Enabled: false Rails/PluckInWhere: Enabled: false Rails/RenderInline: Enabled: false Rails/RenderPlainText: Enabled: false Rails/ShortI18n: Enabled: false Rails/SquishedSQLHeredocs: Enabled: false Rails/WhereExists: Enabled: false Rails/WhereNot: Enabled: false Performance/AncestorsInclude: Enabled: false Performance/BigDecimalWithNumericArgument: Enabled: false Performance/RedundantSortBlock: Enabled: false Performance/RedundantStringChars: Enabled: false Performance/ReverseFirst: Enabled: false Performance/SortReverse: Enabled: false Performance/Squeeze: Enabled: false Performance/StringInclude: Enabled: false Performance/Sum: Enabled: false # New rules Layout/LineEndStringConcatenationIndentation: # new in 1.18 Description: Checks the indentation of the next line after a line that ends with a string literal and a backslash. Enabled: true Layout/SpaceBeforeBrackets: # new in 1.7 Description: Checks for space between the name of a receiver and a left brackets. Enabled: true Lint/AmbiguousAssignment: # new in 1.7 Description: Checks for mistyped shorthand assignments Enabled: true Lint/AmbiguousOperatorPrecedence: # new in 1.21 Description: Looks for expressions containing multiple binary operators where precedence is ambiguous due to lack of parentheses Enabled: true Lint/AmbiguousRange: # new in 1.19 Enabled: true Lint/DeprecatedConstants: # new in 1.8 Enabled: true Lint/DuplicateBranch: # new in 1.3 Description: Checks that there are no repeated bodies within if/unless, case-when and rescue constructs Enabled: true Lint/DuplicateRegexpCharacterClassElement: # new in 1.1 Description: Checks for duplicate elements in Regexp character classes Enabled: true Lint/EmptyBlock: # new in 1.1 Description: Checks for blocks without a body Enabled: true Lint/EmptyClass: # new in 1.3 Description: Checks for classes and metaclasses without a body Enabled: true AllowComments: true Lint/EmptyInPattern: # new in 1.16 Description: Checks for the presence of in pattern branches without a body Enabled: true Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21 Enabled: true Lint/LambdaWithoutLiteralBlock: # new in 1.8 Enabled: true Lint/NoReturnInBeginEndBlocks: # new in 1.2 Description: Checks for the presence of a return inside a begin..end block in assignment contexts Enabled: true Lint/NumberedParameterAssignment: # new in 1.9 Description: Checks for uses of numbered parameter assignment Enabled: true Lint/OrAssignmentToConstant: # new in 1.9 Description: Checks for unintended or-assignment to a constant Enabled: true Lint/RedundantDirGlobSort: # new in 1.8 Description: Sort globbed results by default in Ruby 3.0 Enabled: true Lint/RequireRelativeSelfPath: # new in 1.22 Description: Checks for uses a file requiring itself with require_relative Enabled: true Lint/SymbolConversion: # new in 1.9 Description: Checks for uses of literal strings converted to a symbol where a literal symbol could be used instead Enabled: true Lint/ToEnumArguments: # new in 1.1 Description: ensures that to_enum/enum_for, called for the current method, has correct arguments Enabled: true Lint/TripleQuotes: # new in 1.9 Description: Checks for "triple quotes" (strings delimted by any odd number of quotes greater than 1) Enabled: true Lint/UnexpectedBlockArity: # new in 1.5 Description: Checks for a block that is known to need more positional block arguments than are given Enabled: false Lint/UnmodifiedReduceAccumulator: # new in 1.1 Description: Looks for reduce or inject blocks where the value returned (implicitly or explicitly) does not include the accumulator Enabled: true Lint/UselessRuby2Keywords: # new in 1.23 Description: Looks for ruby2_keywords calls for methods that do not need it Enabled: true Security/IoMethods: # new in 1.22 Enabled: false Style/ArgumentsForwarding: # new in 1.1 Description: Identifies places where do_something(*args, &block) can be replaced by do_something(...) Enabled: true Style/CollectionCompact: # new in 1.2 Description: Checks for places where custom logic on rejection nils from arrays and hashes can be replaced with {Array,Hash}#{compact,compact!} Enabled: false Style/DocumentDynamicEvalDefinition: # new in 1.1 Description: When using class_eval (or other eval) with string interpolation, add a comment block showing its appearance if interpolated (a practice used in Rails code) Enabled: false Style/EndlessMethod: # new in 1.8 Description: Checks for endless methods. It can enforce either the use of endless methods definitions for single-lined method bodies, or disallow endless methods. Enabled: true EnforcedStyle: allow_single_line Style/FileRead: # new in 1.24 Description: Favor File.(bin)read convenience methods Enabled: false Style/FileWrite: # new in 1.24 Description: Favor File.(bin)write convenience methods Enabled: false Style/HashConversion: # new in 1.10 Description: Checks the usage of pre-2.1 Hash[args] method of converting enumerables and sequences of values to hashes Enabled: true Style/HashExcept: # new in 1.7 Description: Checks for usages of Hash#reject, Hash#select, and Hash#filter methods that can be replaced with Hash#except method Enabled: true Style/IfWithBooleanLiteralBranches: # new in 1.9 Description: Checks for redundant if with boolean literal branches Enabled: true Style/InPatternThen: # new in 1.16 Description: Checks for in; uses in case expressions Enabled: true Style/MapToHash: # new in 1.24 Description: Looks for uses of map.to_h or collect.to_h that could be written with just to_h in Ruby >= 2.6 Enabled: true Style/MultilineInPatternThen: # new in 1.16 Description: Checks uses of the then keyword in multi-line in statement Enabled: true Style/NegatedIfElseCondition: # new in 1.2 Description: Checks for uses of if-else and ternary operators with a negated condition which can be simplified by inverting condition and swapping branches Enabled: true Style/NestedFileDirname: # new in 1.26 Description: Checks for nested File.dirname. It replaces nested File.dirname with the level argument introduced in Ruby 3.1. Enabled: true Style/NilLambda: # new in 1.3 Description: Checks for lambdas that always return nil, which can be replaced with an empty lambda instead Enabled: true Style/NumberedParameters: # new in 1.22 Description: Checks for numbered parameters Enabled: false Style/NumberedParametersLimit: # new in 1.22 Description: Detects use of an excessive amount of numbered parameters in a single block. Having too many numbered parameters can make code too cryptic and hard to read Enabled: false Style/OpenStructUse: # new in 1.23 Description: Flags uses of OpenStruct, as it is now officially discouraged to be used for performance, version compatibility, and potential security issues Enabled: false Style/QuotedSymbols: # new in 1.16 Description: Checks if the quotes used for quoted symbols match the configured defaults. By default uses the same configuration as Style/StringLiterals Enabled: true Style/RedundantArgument: # new in 1.4 Description: Checks for a redundant argument passed to certain methods Enabled: false Style/RedundantSelfAssignmentBranch: # new in 1.19 Description: Checks for places where conditional branch makes redundant self-assignment Enabled: true Style/SelectByRegexp: # new in 1.22 Description: Looks for places where an subset of an Enumerable (array, range, set, etc.; see note below) is calculated based on a Regexp match, and suggests grep or grep_v instead Enabled: true Style/StringChars: # new in 1.12 Description: Checks for uses of String#split with empty string or regexp literal argument Enabled: false Style/SwapValues: # new in 1.1 Description: Enforces the use of shorthand-style swapping of 2 variables Enabled: true Rails/AddColumnIndex: # new in 2.11 Enabled: true Rails/AttributeDefaultBlockValue: # new in 2.9 Enabled: true Rails/EagerEvaluationLogMessage: # new in 2.11 Enabled: true Rails/ExpandedDateRange: # new in 2.11 Enabled: true Rails/I18nLocaleAssignment: # new in 2.11 Enabled: true Rails/RedundantTravelBack: # new in 2.12 Enabled: true Rails/TimeZoneAssignment: # new in 2.10 Enabled: true Rails/UnusedIgnoredColumns: # new in 2.11 Enabled: true Rails/WhereEquals: # new in 2.9 Enabled: true Performance/BlockGivenWithExplicitBlock: # new in 1.9 Description: Identifies unnecessary use of a block_given? where explicit check of block argument would suffice Enabled: true Performance/CollectionLiteralInLoop: # new in 1.8 Description: Identifies places where Array and Hash literals are used within loops Enabled: true Performance/ConcurrentMonotonicTime: # new in 1.12 Enabled: false Performance/ConstantRegexp: # new in 1.9 Description: Finds regular expressions with dynamic components that are all constants Enabled: true Performance/MapCompact: # new in 1.11 Description: Identifies places where map { ... }.compact can be replaced by filter_map Enabled: true Performance/MethodObjectAsBlock: # new in 1.9 Description: Identifies places where methods are converted to blocks, with the use of &method, and passed as arguments to method calls Enabled: true Performance/RedundantEqualityComparisonBlock: # new in 1.10 Enabled: false Performance/RedundantSplitRegexpArgument: # new in 1.10 Description: Identifies places where split argument can be replaced from a deterministic regexp to a string Enabled: true Performance/StringIdentifierArgument: # new in 1.13 Description: Identifies places where string identifier argument can be replaced by symbol identifier argument. It prevents the redundancy of the internal string-to-symbol conversion Enabled: true Gemspec/DeprecatedAttributeAssignment: # new in 1.30 Description: Checks that deprecated attribute attributes are not set in a gemspec file Enabled: true Gemspec/RequireMFA: # new in 1.23 Description: Requires a gemspec to have rubygems_mfa_required metadata set. Enabled: false Naming/BlockForwarding: # new in 1.24 Description: Identifies places where do_something(&block) can be replaced by do_something(&) Enabled: true