inherit_from: .rubocop_todo.yml # Common configuration. AllCops: TargetRubyVersion: 3.1.2 Naming/MethodName: EnforcedStyle: snake_case Exclude: # Overriding WEBrick::HTTPServlet::AbstractServlet::do_GET. # It's not ours to fix, it comes from the WEBrick libraries. - lib/sitediff/webserver/resultserver.rb # Check for grouping of accessors in class and module bodies. # By default it enforces accessors to be placed in grouped declarations Style/AccessorGrouping: Enabled: true # Style/ArrayCoercion: Enabled: false # Check for places where attr_reader and attr_writer for the same method # can be combined into single attr_accessor Style/BisectedAttrAccessor: Enabled: true # Identifies places where if-elsif constructions can be replaced with case-when Style/CaseLikeIf: Enabled: true # Disable rules enforcing unreadable programming styles. # Example: Use the return of the conditional for variable assignment # and comparison Style/ConditionalAssignment: Enabled: false # Require documentation for class methods. Style/DocumentationMethod: Enabled: true # Exponential notation: enforces a mantissa between 1 (inclusive) and 10 (exclusive). Style/ExponentialNotation: Enabled: true # Checks for presence or absence of braces around hash literal as a last array # item depending on configuration. Style/HashAsLastArrayItem: Enabled: true # Check for uses of `each_key` and `each_value` Hash methods. Style/HashEachMethods: Enabled: true # Check for places where case-when represents a simple 1:1 mapping and # can be replaced with a hash lookup. Style/HashLikeCase: Enabled: true # Use of `transform_keys`: This cop should only be enabled on Ruby version 2.5 or newer. Style/HashTransformKeys: Enabled: false # Use of `transform_values`. Style/HashTransformValues: Enabled: true # Check this as the value is changed somewhere after initial assignment. Style/MutableConstant: Exclude: - 'lib/sitediff/sanitize/dom_transform.rb' # Checks for redundant assignment before returning. Style/RedundantAssignment: Enabled: true # Checks for where fetch(key) { value } can be replaced by fetch(key, value) Style/RedundantFetchBlock: Enabled: true # Checks for the presence of superfluous .rb extension in the filename # provided to require and require_relative. Style/RedundantFileExtensionInRequire: Enabled: true # Check for unnecessary single-element Regexp character classes. Style/RedundantRegexpCharacterClass: Enabled: true # Checks for redundant escapes inside Regexp literals. Style/RedundantRegexpEscape: Enabled: true # Check that arrays are sliced with endless ranges instead of ary[start..-1] on Ruby 2.6+. Style/SlicingWithRange: Enabled: true # Allow developers to write complex code. Metrics/AbcSize: Max: 100 # Allow developers to write complex code. Metrics/CyclomaticComplexity: Max: 15 # Allow developers to write complex code. Metrics/PerceivedComplexity: Max: 15 # Classes can have as many lines as they want. # Complex classes can have many methods after all. Metrics/ClassLength: Enabled: false # Methods can have a maximum of 128 lines. # Complex methods might need to be broken in to multiple methods. Metrics/MethodLength: Max: 64 CountComments: false # Methods can have a maximum of 128 lines. # Complex methods might need to be broken in to multiple methods. Metrics/BlockLength: CountComments: false Max: 64 Exclude: # Tests can get fairly long, so we ignore them. - 'spec/**/*_spec.rb' # Some files have very long lines and need to be ignored. # Otherwise, we enforce a max-length of 80 characters per line. Layout/LineLength: AllowHeredoc: true AllowURI: true IgnoredPatterns: - '^\s*SiteDiff\.log' - '^\s*run\s' - '\sif|elsif|unless\s' Exclude: - 'Thorfile' # Spec files contain long strings for testing, so we ignore them. - 'spec/**/*_spec.rb' # Checks if empty lines exist around the arguments of a method invocation. Layout/EmptyLinesAroundAttributeAccessor: Enabled: true # Checks that operators have space around them, except for ** which should or shouldn't have surrounding space. Layout/SpaceAroundMethodCallOperator: Enabled: true # MarshalLoad helps in creating a clone of a Ruby hash, ensuring that it is # completely disconnected from the original hash. A common way of doing this # is by serializing an object and then un-serializing it with Marshal. Security/MarshalLoad: Exclude: - 'lib/sitediff/cache.rb' # Disallow algorithmic constants for OpenSSL::Cipher and OpenSSL::Digest. Lint/DeprecatedOpenSSLConstant: Enabled: true # Check that there are no repeated conditions used in if 'elsif'. Lint/DuplicateElsifCondition: Enabled: true # Do not mix named captures and numbered captures in a Regexp literal. Lint/MixedRegexpCaptureTypes: Enabled: true # This cop checks for `raise` or `fail` statements which are raising `Exception` class. Lint/RaiseException: Enabled: true # Check for unexpected overrides of the `Struct` built-in methods via `Struct.new`. Lint/StructNewOverride: Enabled: true