canvas-lms/.rubocop.common.yml

281 lines
8.1 KiB
YAML

require:
- rubocop-rails
- rubocop-rake
- rubocop-rspec
- rubocop-performance
# this odd relative path is so that rubocop works when run without "bundle
# exec", such as from most editors/IDEs.
- ./gems/rubocop-canvas/lib/rubocop_canvas
- outrigger/cops/migration/tagged
AllCops:
TargetRubyVersion: 2.7
NewCops: enable
Bundler:
Severity: error
Bundler/OrderedGems:
Enabled: false # this isn't good for us because of how we pin dependencies
Gemspec:
Severity: error
Gemspec/RequiredRubyVersion:
# all the gemspecs in this repo are non-published gems
# the root Gemfile enforces the Ruby version, and we purposely
# don't specify required_ruby_version in the rest to reduce
# maintenance pain when updating ruby versions
Enabled: false
Layout:
Severity: error
Layout/LineLength:
Enabled: false # TODO. Maybe.
Lint/AmbiguousOperator:
Severity: error
Lint/AmbiguousOperatorPrecedence:
Severity: error
Lint/AmbiguousRegexpLiteral:
Severity: error
Lint/AssignmentInCondition:
Severity: error
Lint/Debugger:
Severity: error
Lint/DeprecatedClassMethods:
Severity: error
Lint/DeprecatedOpenSSLConstant:
Severity: error
Lint/NonDeterministicRequireOrder:
Severity: error
Lint/ParenthesesAsGroupedExpression:
Severity: error
Lint/RedundantRequireStatement:
Severity: error
Lint/RedundantSafeNavigation:
Severity: error
Lint/RedundantSplatExpansion:
Severity: error
Lint/RedundantStringCoercion:
Severity: error
Lint/RedundantWithIndex:
Severity: error
Lint/SafeNavigationConsistency:
Enabled: false # https://github.com/rubocop/rubocop/issues/9816
Lint/SendWithMixinArgument:
Severity: error
Lint/SymbolConversion:
Severity: error
Lint/UnifiedInteger:
Severity: error
Lint/UselessAssignment:
Severity: error
Lint/UnusedBlockArgument:
Severity: error
Lint/UnusedMethodArgument:
AllowUnusedKeywordArguments: true # there's no way to mark a kwarg as unused
Severity: error
Metrics:
Enabled: false # SnR is just too low to have this enabled
Migration/Tagged:
Severity: error
AllowedTags:
- predeploy
- postdeploy
- cassandra
- dynamodb
Naming/FileName:
Exclude:
- "**/Gemfile.d/~after.rb"
Rails/ApplicationRecord:
Enabled: false # we never bothered creating an ApplicationRecord
Rails/HasManyOrHasOneDependent:
Enabled: false # legacy code + most things we soft delete anyway
Rails/HelperInstanceVariable:
Enabled: false # legacy code
Rails/SkipsModelValidations:
Enabled: false # Canvas skips validations in many places for optimization reasons
Rails/ContentTag:
Severity: error
Exclude:
- "**/db/migrate/*" # this cop is for views, not migrations, where it gets confused with outrigger
- "doc/**/*"
RSpec/AnyInstance:
Enabled: false # while using an instance double would be preferable, it's a pain
RSpec/DescribedClass:
Enabled: false # we haven't used it, and it seems antithetical to RSpec/NamedSubject
RSpec/EmptyExampleGroup:
Severity: error
RSpec/ExampleLength:
Enabled: false # this is a Metrics-style cop
RSpec/ExampleWording:
Severity: error
RSpec/ExpectInHook:
Enabled: false # follows RSpec/MultipleExpectations
RSpec/InstanceVariable:
Enabled: false # legacy code
RSpec/MessageSpies:
Enabled: false # we don't use spies
RSpec/MultipleExpectations:
Enabled: false # we don't write specs in this style
RSpec/MultipleMemoizedHelpers:
Enabled: false # complicated setup is sometimes necessary
RSpec/NestedGroups:
Enabled: false # legacy code
RSpec/RepeatedDescription:
Severity: error
RSpec/SubjectStub:
Enabled: false # yes, canvas is big and complicated sometimes
RSpec/StubbedMock:
Enabled: false # this style goes along with spies
Specs/EnsureSpecExtension:
Exclude:
- spec/shared_examples/**/*
Style/Alias:
EnforcedStyle: prefer_alias_method # https://github.com/rubocop/ruby-style-guide/issues/821
Severity: error
Style/Documentation:
Enabled: false # most things don't need to be documented
Style/Encoding:
Severity: error
Style/FrozenStringLiteralComment:
Severity: error
Style/IfUnlessModifier:
# see also https://github.com/rubocop/rubocop/discussions/10048
Enabled: false # can obscure important decisions or put too much code in a line
Style/NumericPredicate:
Enabled: false # `> 0` can be easier to read than `.positive?`
Style/ParenthesesAroundCondition:
Severity: error
Style/PerlBackrefs:
Enabled: false # Regexp.last_match(1) is far worse than $1
Style/SpecialGlobalVars:
Enabled: false # $! and $? are fine
Style/WhileUntilModifier:
Enabled: false # nontrivial loops should look like loops
# the following cops are currently silenced, but we may want to enable them IF
# we correct all instances in the codebase first
Lint/AmbiguousBlockAssociation: # TODO
IgnoredMethods:
- change
- not_change
- raise_error
Naming/VariableNumber: # TODO
Enabled: false
Rails/DynamicFindBy: # TODO; autocorrect (unsafe)
AllowedMethods:
- find_by_name # PluginSetting.find_by_name
- find_by_asset_string # ApplicationRecord.find_by_asset_string
AutoCorrect: false
Rails/ReadWriteAttribute: # TODO: autocorrect (unsafe)
Enabled: false # accessors are often defined in terms of read_attribute
Rails/TimeZone: # TODO: autocorrect (unsafe)
Enabled: false
Rails/WhereExists: # TODO: autocorrect(unsafe)
EnforcedStyle: where
AutoCorrect: false
RSpec/BeEql: # TODO: autocorrect
Enabled: false
RSpec/ContextWording: # TODO
Enabled: false
RSpec/DescribeClass: # TODO
Enabled: false
RSpec/ExpectChange: # TODO: autocorrect (unsafe)
Enabled: false
RSpec/HookArgument: # TODO: autocorrect
Enabled: false
RSpec/NamedSubject: # TODO
Enabled: false
RSpec/NotToNot: # TODO: autocorrect
Enabled: false
RSpec/PredicateMatcher: # TODO: autocorrect (unsafe)
Enabled: false
RSpec/ScatteredSetup: # TODO: investigate if these are required
Enabled: false
RSpec/VerifiedDoubles: # TODO
Enabled: false
Style/BlockDelimiters: # TODO: autocorrect
Enabled: true
Exclude:
- spec/**/*_spec.rb
- spec/shared_examples/**/*.rb
AutoCorrect: false
Style/ClassAndModuleChildren: # TODO: autocorrect (unsafe)
Enabled: false
Style/DoubleNegation: # TODO: autocorrect (unsafe)
Enabled: false
Style/Dir: # TODO: autocorrect
Enabled: false
Style/EmptyElse: # TODO: autocorrect
Enabled: false
EnforcedStyle: empty # explicit nil indicates programmer intent
Style/FormatStringToken: # TODO: investigate if this complains about our i18n library
Enabled: false
Style/GuardClause: # TODO
Enabled: false
Style/HashSyntax:
EnforcedStyle: ruby19_no_mixed_keys
Enabled: false # TODO: autocorrect
Style/Lambda: # TODO: autocorrect
Enabled: false
Style/MethodCallWithArgsParentheses: # TODO: autocorrect
Enabled: false
Style/MethodCallWithoutArgsParentheses: # TODO: autocorrect
Enabled: false
Style/NumericLiterals: # TODO: autocorrect
Enabled: false
Style/ParallelAssignment: # TODO: autocorrect (with probable exceptions)
Enabled: false
Style/PercentLiteralDelimiters: # TODO: autocorrect
Enabled: false
Style/PercentQLiterals: # TODO: autocorrect
Enabled: false
Style/RedundantSelf: # TODO: autocorrect
Enabled: false
Style/RegexpLiteral: # TODO: autocorrect
Enabled: false
Style/RescueModifier: # TODO
Severity: warning
AutoCorrect: false
Style/RescueStandardError: # TODO: autocorrect
EnforcedStyle: implicit
Enabled: false
Style/ReturnNil: # TODO: autocorrect (investigate violations)
Enabled: false
Style/SignalException: # TODO: autocorrect
Enabled: false
Style/StderrPuts: # TODO: autocorrect
Enabled: false
Style/StringConcatenation: # TODO: autocorrect (maybe)
Enabled: false
Style/StringLiterals:
EnforcedStyle: double_quotes
Enabled: false # TODO: autocorrect
Style/SymbolArray: # TODO: autocorrect
Enabled: false
Style/QuotedSymbols:
# once Style/StringLiterals is enabled, we can remove this since it will inherit
EnforcedStyle: double_quotes
AutoCorrect: false
Style/TrailingCommaInArguments: # TODO: autocorrect
Enabled: false
Style/TrailingCommaInArrayLiteral: # TODO: autocorrect
Enabled: false
Style/TrailingCommaInHashLiteral: # TODO: autocorrect
Enabled: false
Style/WordArray: # TODO: autocorrect
Enabled: false
Style/ZeroLengthPredicate: # TODO: autocorrect (unsafe)
Enabled: false