2021-11-24 00:16:53 +08:00
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
2015-04-05 08:49:25 +08:00
2021-11-24 00:16:53 +08:00
AllCops :
TargetRubyVersion : 2.7
NewCops : enable
2017-01-04 08:52:49 +08:00
2021-11-24 00:16:53 +08:00
Bundler :
Severity : error
2021-09-21 00:20:02 +08:00
2021-11-24 00:16:53 +08:00
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
2021-09-21 00:20:02 +08:00
2021-11-24 00:16:53 +08:00
Layout :
Severity : error
2021-09-21 00:20:02 +08:00
2021-11-24 00:16:53 +08:00
Lint :
Severity : error
Lint/AmbiguousBlockAssociation :
IgnoredMethods :
- change
- not_change
- raise_error
Lint/NoFileUtilsRmRf :
Severity : warning # intended for specs; not enforced
Lint/NoSleep :
Severity : warning # intended for specs; not enforced
Lint/NonLocalExitFromIterator :
Enabled : false # SnR is too low because of how often this construct is used
2021-11-30 00:01:47 +08:00
Lint/RedundantCopDisableDirective :
Enabled : false # can't have this enabled until https://github.com/rubocop/rubocop/issues/10263
2021-11-24 00:16:53 +08:00
Lint/SafeNavigationConsistency :
Enabled : false # https://github.com/rubocop/rubocop/issues/9816
Lint/UnusedBlockArgument :
AutoCorrect : false # force the engineer to think about how come it's unused, instead of silently _ prefixing it
Lint/UnusedMethodArgument :
AllowUnusedKeywordArguments : true # there's no way to mark a kwarg as unused
AutoCorrect : false # force the engineer to think about how come it's unused, instead of silently _ prefixing it
2021-09-21 00:20:02 +08:00
2021-11-24 00:16:53 +08:00
Metrics :
Enabled : false # SnR is just too low to have this enabled
2021-09-25 00:29:32 +08:00
2021-11-24 01:10:12 +08:00
Migration/Tagged :
2021-11-24 00:16:53 +08:00
AllowedTags :
- predeploy
- postdeploy
- cassandra
- dynamodb
2021-11-24 01:10:12 +08:00
Naming :
2021-11-24 00:16:53 +08:00
Severity : error
Naming/HeredocDelimiterNaming :
ForbiddenDelimiters :
# negative regex - these are the _allowed_ delimiters
# any you add should describe the format of the data, not describe
# what the data is for. this allows editors to syntax highlight
lint use of add_foreign_key
test plan:
- create a migration (locally) and add it to a commit
(no need to actually commit, push, or even run the migration)
that adds a foreign key to an existing table, e.g.
add_foreign_key :users, :eportfolios
- run script/rlint, and it should complain that you should
use a non-transactional migration and add `delay_validation: true`
to the arguments
- do those things, run script/rlint again, and it should not
complain
- add a foreign key to a table created in the same migration,
e.g.
create_table :foo do |t|
end
add_foreign_key :foo, :bar
- run script/rlint again, and it shouldn't complain
flag=none
closes DE-940
Change-Id: I3f235cbf1ff4011e20d74bdaa8953b857c7e330a
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/280514
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Isaac Moore <isaac.moore@instructure.com>
QA-Review: Isaac Moore <isaac.moore@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2021-12-07 08:13:15 +08:00
- ^(?!AST|BASE64|CSV|GQL|HTML|JS|MD|PEM|REGEX|RUBY|SQL|SRT|TEXT|XML|YAML|PATTERN).+$
2021-11-24 00:16:53 +08:00
Performance :
Severity : error
Performance/Casecmp :
2022-01-07 06:24:29 +08:00
Enabled : false # casecmp(other).zero? is a bad suggestion because it's not Unicode-aware (also it's less clear)
2021-11-24 00:16:53 +08:00
Performance/CollectionLiteralInLoop :
Severity : convention # not auto-correctable; can be a pain to fix and isn't necessarily performance critical
Performance/MethodObjectAsBlock :
Enabled : false # decreases expressiveness
2021-11-24 01:10:12 +08:00
Rails :
2021-11-24 00:16:53 +08:00
Severity : error
Rails/ApplicationRecord :
Enabled : false # we never bothered creating an ApplicationRecord
Rails/Blank :
UnlessPresent : false # allow `unless foo.present?`
Rails/ContentTag :
Exclude :
- "**/db/migrate/*" # this cop is for views, not migrations, where it gets confused with outrigger
- "doc/**/*"
Rails/DynamicFindBy :
AllowedMethods :
- find_by_confirmation_code # CommunicationChannel
- find_by_signature # AssetSignature
- find_by_domain # Account
- find_by_name # PluginSetting
- find_by_asset_string # ApplicationRecord
- find_by_pseudonym_credentials # SessionPersistenceToken
- find_by_quiz # Quizzes::OutstandingQuizSubmissionManager
Rails/HasManyOrHasOneDependent :
Enabled : false # legacy code + most things we soft delete anyway
Rails/HelperInstanceVariable :
Enabled : false # legacy code
Rails/NegateInclude :
Enabled : false # exclude? isn't as intuitive as !include?
Rails/Present :
UnlessBlank : false # allow `unless foo.blank?`
Rails/SkipsModelValidations :
Enabled : false # Canvas skips validations in many places for optimization reasons
Rails/WhereExists :
EnforcedStyle : where
2021-11-24 01:10:12 +08:00
RSpec :
Severity : error
2021-11-24 00:16:53 +08:00
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/ExampleLength :
Enabled : false # this is a Metrics-style cop
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/SubjectStub :
Enabled : false # yes, canvas is big and complicated sometimes
RSpec/StubbedMock :
Enabled : false # this style goes along with spies
2021-11-24 06:15:50 +08:00
RSpec/Rails :
Severity : error
2021-11-24 00:16:53 +08:00
Security :
Severity : error
Security/YAMLLoad :
# technically even YAML.load is fairly safe in Canvas because we override it and only allow certain types
# but still avoid it if you can.
Severity : warning
AutoCorrect : false
Specs/EnsureSpecExtension :
Exclude :
- spec/shared_examples/**/*
2021-11-24 01:10:12 +08:00
Style :
Severity : error
2021-11-24 00:16:53 +08:00
Style/Alias :
EnforcedStyle : prefer_alias_method # https://github.com/rubocop/ruby-style-guide/issues/821
Style/BlockDelimiters :
IgnoredMethods : [ ]
Style/Documentation :
Enabled : false # most things don't need to be documented
Style/DoubleNegation :
Enabled : false # we use double negation, even outside of return context, to get an actual true/false for various API results
Style/EmptyElse :
EnforcedStyle : empty # explicit nil indicates programmer intent
Style/FloatDivision :
Enabled : false # inherently dangerous cop because the args may not even be integers, and only upside is maybe saving 4 characters
Style/FormatStringToken :
Enabled : false # I18n requires template style, but ohter code uses annotated style, and there are some trivial unannotted that don't really need to be annotated
2022-03-11 10:50:30 +08:00
Style/HashLikeCase :
Enabled : false
2021-11-24 01:10:12 +08:00
Style/HashSyntax :
EnforcedStyle : ruby19_no_mixed_keys
2021-11-24 00:16:53 +08:00
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/MultilineBlockChain :
Enabled : false # this is common when building up a large API result
Style/NumericPredicate :
Enabled : false # `> 0` can be easier to read than `.positive?`
Style/ParallelAssignment :
Enabled : false # most uses are legitimate deconstruction or value swapping
Style/PercentQLiterals :
EnforcedStyle : upper_case_q
Style/PerlBackrefs :
Enabled : false # Regexp.last_match(1) is far worse than $1
Style/RescueStandardError :
EnforcedStyle : implicit
Style/ReturnNil :
Enabled : false # explicit nil is okay when a method is expected to have a return value
2022-01-11 06:31:48 +08:00
Style/SoleNestedConditional :
AllowModifier : true # it makes lines too long and complicated otherwise
2021-11-24 00:16:53 +08:00
Style/SpecialGlobalVars :
Enabled : false # $! and $? are fine
2021-11-24 01:10:12 +08:00
Style/StringLiterals :
2021-11-24 00:16:53 +08:00
EnforcedStyle : double_quotes
Style/StringLiteralsInInterpolation :
EnforcedStyle : double_quotes
Style/SymbolArray :
MinSize : 3
Style/TernaryParentheses :
EnforcedStyle : require_parentheses_when_complex
Style/WhileUntilModifier :
Enabled : false # nontrivial loops should look like loops
Style/WordArray :
MinSize : 3
2021-11-24 01:10:12 +08:00
# the following cops have offenses in the code base that have not been fixed.
# we should eventually either fix them, or turn them off completely (and move
# them to the section above)
# auto-correct needs to be disabled for any that support it in the meantime
2021-11-24 00:16:53 +08:00
2021-11-24 01:10:12 +08:00
Layout/LineLength :
2021-11-24 00:16:53 +08:00
Enabled : false
2021-11-24 01:10:12 +08:00
AutoCorrect : false
2021-11-24 00:16:53 +08:00
2021-11-24 01:10:12 +08:00
Lint/UriEscapeUnescape :
2021-11-24 00:16:53 +08:00
Severity : warning
2021-11-24 01:10:12 +08:00
Naming/AccessorMethodName :
Severity : convention
2021-11-24 00:16:53 +08:00
Naming/BinaryOperatorParameterName :
2021-11-24 01:10:12 +08:00
Severity : convention
AutoCorrect : false
Naming/BlockParameterName :
Severity : convention
Naming/ClassAndModuleCamelCase :
Severity : convention
Naming/ConstantName :
Severity : convention
Naming/FileName :
Severity : convention
Exclude :
- "**/Gemfile.d/~after.rb"
Naming/MemoizedInstanceVariableName :
Severity : convention
Naming/MethodName :
Severity : convention
Naming/MethodParameterName :
Severity : convention
Naming/PredicateName :
Severity : convention
Naming/VariableName :
Severity : convention
Naming/VariableNumber :
Enabled : false
2021-11-24 00:16:53 +08:00
Rails/ActiveRecordCallbacksOrder :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
Rails/ActiveRecordOverride :
Severity : convention
2021-11-24 00:16:53 +08:00
Rails/ApplicationMailer :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Rails/BelongsTo :
2021-11-24 01:10:12 +08:00
Severity : convention
AutoCorrect : false
Rails/BulkChangeTable :
Severity : convention
Rails/CreateTableWithTimestamps :
Severity : convention
Rails/Date :
Enabled : false
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Rails/EagerEvaluationLogMessage :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Rails/EnumHash :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Rails/FindBy :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Rails/FindById :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Rails/FindEach :
2021-11-24 01:10:12 +08:00
Severity : convention
AutoCorrect : false
2021-11-24 05:22:41 +08:00
Rails/I18nLocaleAssignment :
Severity : convention
2021-11-24 01:10:12 +08:00
Rails/InverseOf :
Severity : convention
Rails/LexicallyScopedActionFilter :
Severity : convention
Rails/NotNullColumn :
Severity : convention
2021-11-24 00:16:53 +08:00
Rails/Output :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
Rails/OutputSafety :
Severity : convention
2021-11-24 00:16:53 +08:00
Rails/Pick :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Rails/PluckInWhere :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Rails/RakeEnvironment :
2021-11-24 01:10:12 +08:00
Severity : convention
AutoCorrect : false
Rails/ReadWriteAttribute :
Enabled : false # accessors are often defined in terms of read_attribute
AutoCorrect : false
Rails/ReversibleMigration :
Severity : convention
Rails/TimeZone :
Enabled : false
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 05:22:41 +08:00
Rails/TimeZoneAssignment :
Severity : convention
2021-11-24 00:16:53 +08:00
Rake/Desc :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
Rake/MethodDefinitionInTask :
Severity : convention
2021-11-24 00:16:53 +08:00
RSpec/Capybara/FeatureMethods :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
RSpec/AroundBlock :
Severity : convention
RSpec/Be :
Severity : convention
RSpec/BeEql :
Enabled : false
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
RSpec/BeforeAfterAll :
Severity : convention
2021-11-24 00:16:53 +08:00
RSpec/ContextMethod :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
RSpec/ContextWording :
Enabled : false
RSpec/DescribeClass :
Enabled : false
RSpec/DescribeMethod :
Severity : convention
2021-11-24 00:16:53 +08:00
RSpec/ExpectActual :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
RSpec/ExpectChange :
Enabled : false
AutoCorrect : false
RSpec/FilePath :
Severity : convention
2021-11-24 00:16:53 +08:00
RSpec/HooksBeforeExamples :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
RSpec/IdenticalEqualityAssertion :
Severity : convention
RSpec/ImplicitBlockExpectation :
Severity : convention
2021-11-24 00:16:53 +08:00
RSpec/ImplicitExpect :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
RSpec/IteratedExpectation :
Severity : convention
RSpec/LeakyConstantDeclaration :
Severity : convention
RSpec/LetSetup :
Severity : convention
RSpec/MessageChain :
Severity : convention
RSpec/MissingExampleGroupArgument :
Severity : convention
RSpec/MultipleDescribes :
Severity : convention
RSpec/NamedSubject :
Enabled : false
RSpec/NotToNot :
Enabled : false
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
RSpec/OverwritingSetup :
Severity : convention
RSpec/PredicateMatcher :
Enabled : false
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
RSpec/ReceiveCounts :
Severity : convention
AutoCorrect : false
2021-11-24 00:16:53 +08:00
RSpec/ReturnFromStub :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
RSpec/ScatteredLet :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
RSpec/ScatteredSetup :
Enabled : false
2021-11-24 00:16:53 +08:00
RSpec/SharedContext :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
RSpec/SubjectDeclaration :
Severity : convention
RSpec/VariableName :
Severity : convention
RSpec/VerifiedDoubles :
Enabled : false
2021-11-24 00:16:53 +08:00
2021-11-24 01:10:12 +08:00
Style/AccessModifierDeclarations :
Severity : convention
2021-11-24 00:16:53 +08:00
Style/AccessorGrouping :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2022-03-15 23:02:48 +08:00
Style/CaseLikeIf :
Enabled : false
2021-11-24 01:10:12 +08:00
Style/ClassAndModuleChildren :
Enabled : false
AutoCorrect : false
Style/ClassVars :
Severity : convention
Style/CombinableLoops :
Severity : convention
2021-11-24 00:16:53 +08:00
Style/CommentedKeyword :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
Style/DocumentDynamicEvalDefinition :
Severity : convention
Style/ExponentialNotation :
Severity : convention
2021-11-24 00:16:53 +08:00
Style/FormatString :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
Style/GlobalVars :
Severity : convention
Style/GuardClause :
Enabled : false
2021-11-24 00:16:53 +08:00
Style/HashAsLastArrayItem :
2021-11-24 01:10:12 +08:00
Severity : convention
AutoCorrect : false
2021-11-24 00:16:53 +08:00
Style/InfiniteLoop :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Style/KeywordParametersOrder :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
2021-11-24 01:10:12 +08:00
Style/MissingRespondToMissing :
Severity : convention
Style/MixinUsage :
Severity : convention
2021-11-24 00:16:53 +08:00
Style/ModuleFunction :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Style/MultipleComparison :
2021-11-24 01:10:12 +08:00
Severity : convention
AutoCorrect : false
Style/OptionalArguments :
Severity : convention
Style/OptionalBooleanParameter :
Severity : convention
Style/RescueModifier :
Severity : warning
AutoCorrect : false
Style/StringConcatenation :
Enabled : false
AutoCorrect : false
Style/TrailingCommaInArrayLiteral :
Enabled : false
AutoCorrect : false
Style/TrailingCommaInHashLiteral :
Enabled : false
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Style/TrailingUnderscoreVariable :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false
Style/WhileUntilDo :
2021-11-24 01:10:12 +08:00
Severity : convention
2021-11-24 00:16:53 +08:00
AutoCorrect : false