okuramasafumi/alba

View on GitHub
.rubocop.yml

Summary

Maintainability
Test Coverage
---

inherit_gem:
  rubocop-gem_dev: 'config/rubocop.yml'

inherit_mode:
  merge:
    - Exclude

require:
  - rubocop-md
  - rubocop-minitest
  - rubocop-performance
  - rubocop-rake

AllCops:
  Exclude:
    - 'alba.gemspec'
    - 'benchmark/**/*.rb'
    - 'docs/**/*'
    - 'script/**/*.rb'
  NewCops: enable
  EnabledByDefault: true
  TargetRubyVersion: 3.0

# Items in Gemfile is dev dependencies and we don't have to specify versions.
Bundler/GemVersion:
  Enabled: false

# Test class is a class, but not really
Layout/ClassStructure:
  Exclude:
    - 'test/**/*'

# LineLength 80 comes from restrictions in good old days.
Layout/LineLength:
  Max: 160

# We'd like to write something like:
#   assert_equal(
#     expected,
#     actual
#   )
Layout/RedundantLineBreak:
  Exclude:
    - 'test/**/*'

Layout/SpaceInsideHashLiteralBraces:
  EnforcedStyle: no_space

Layout/MultilineAssignmentLayout:
  EnforcedStyle: same_line

Lint/ConstantResolution:
  Enabled: false

# In test code we don't care about the metrics!
Metrics:
  Exclude:
    - 'test/**/*.rb'

# `Resource` module is a core module and its length tends to be long...
# `Alba` main module is also long because it has all parts of configuration
Metrics/ClassLength:
  Exclude:
    - 'lib/alba/resource.rb'
    - 'lib/alba.rb'
    - 'test/**/*.rb' # Neec to specify this

Metrics/ModuleLength:
  Exclude:
    - 'lib/alba/resource.rb'
    - 'lib/alba.rb'

# Resource class includes DSLs, which tend to accept long list of parameters
Metrics/ParameterLists:
  Max: 7
  Exclude:
    - 'test/**/*.rb'

# Putting extra empty line is not valuable in test
# We prefer shorter test code
Minitest/EmptyLineBeforeAssertionMethods:
  Enabled: false

# By nature of that test
Minitest/NoTestCases:
  Exclude:
    - 'test/dependencies/test_dependencies.rb'

# We need to use `OpenStruct` to wrap object in ConfitionalAttribute
Performance/OpenStruct:
  Exclude:
    - 'lib/alba/conditional_attribute.rb'

# We need to eval resource code to test errors on resource classes
Security/Eval:
  Exclude:
    - 'test/**/*.rb'

Style/ConstantVisibility:
  Exclude:
    - 'lib/alba/version.rb'
    - 'test/**/*.rb'

# Copyright is in README
Style/Copyright:
  Enabled: false

# I know what I do :)
Style/DisableCopsWithinSourceCodeDirective:
  Enabled: false

# Test files doesn't need to have documentation
Style/Documentation:
  Exclude:
    - 'test/**/*'

# In README it's so obvious
Style/DocumentationMethod:
  Exclude:
    - 'README.md'

# This might be true in the future, but not many good things
Style/FrozenStringLiteralComment:
  Enabled: false

# I don't want to think about error class in example code
Style/ImplicitRuntimeError:
  Exclude:
    - 'README.md'

# We use it, don't we?
Style/InlineComment:
  Enabled: false

Style/MethodCallWithArgsParentheses:
  AllowedMethods: ['require', 'require_relative', 'include', 'extend', 'puts', 'p', 'warn', 'raise', 'send', 'public_send', 'alias_method']
  Exclude:
    # There are so many calls like `attributes` and `register_type` without parenthese and that's absolutely fine
    - 'test/**/*.rb'
    - 'README.md'

# There are so many cases we just want `if` expression!
Style/MissingElse:
  EnforcedStyle: case

# We need to use `OpenStruct` to wrap object in ConfitionalAttribute
Style/OpenStructUse:
  Exclude:
    - 'lib/alba/conditional_attribute.rb'

# It's example code, please forgive us
Style/OptionalBooleanParameter:
  Exclude:
    - 'README.md'