rubocop: split configuration
* remove spurious .rubocop.yml override files * split the configuration into an enforced and optional * run both configurations in jenkins (may result in some duplicate comments at different levels) * auto-correct the enforced configuration in the pre-commit hook * fix comments for Gemfile.d and the root dir; enforced configuration is only applied to that directory for now Change-Id: I8da21073d74e19138b1b580d66c7aae6465348d4 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/273898 Reviewed-by: Simon Williams <simon@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
aa71e6ffbc
commit
e9d63396ff
|
@ -0,0 +1,71 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
Bundler/OrderedGems:
|
||||||
|
Enabled: false # this isn't good for us because of how we pin dependencies
|
||||||
|
|
||||||
|
Gemspec/OrderedDependencies:
|
||||||
|
Enabled: false # this isn't good for us because of how we pin dependencies
|
||||||
|
|
||||||
|
Layout/IndentationConsistency:
|
||||||
|
Exclude:
|
||||||
|
- "**/Gemfile.d/*" # we purposely indent dependent gems
|
||||||
|
|
||||||
|
Lint/Debugger:
|
||||||
|
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:
|
||||||
|
Exclude:
|
||||||
|
- "**/Gemfile.d/*" # Rails isn't loaded yet, so can't use their helpers in the Gemfile
|
||||||
|
|
||||||
|
RSpec/EmptyExampleGroup:
|
||||||
|
Severity: error
|
||||||
|
RSpec/ExampleLength:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/InstanceVariable:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/MultipleExpectations:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/NestedGroups:
|
||||||
|
Max: 5
|
||||||
|
RSpec/RepeatedDescription:
|
||||||
|
Severity: error
|
||||||
|
|
||||||
|
Specs/EnsureSpecExtension:
|
||||||
|
Exclude:
|
||||||
|
- spec/shared_examples/**/*
|
||||||
|
Style/AsciiComments:
|
||||||
|
Enabled: false
|
||||||
|
Style/Documentation:
|
||||||
|
Enabled: false
|
||||||
|
Style/FrozenStringLiteralComment:
|
||||||
|
Severity: error
|
||||||
|
Style/SpecialGlobalVars:
|
||||||
|
Enabled: false
|
||||||
|
Style/StringLiterals:
|
||||||
|
Enabled: false
|
|
@ -0,0 +1,85 @@
|
||||||
|
inherit_from: .rubocop.common.yml
|
||||||
|
|
||||||
|
inherit_mode:
|
||||||
|
merge:
|
||||||
|
- Exclude
|
||||||
|
|
||||||
|
AllCops:
|
||||||
|
NewCops: disable
|
||||||
|
|
||||||
|
<%=
|
||||||
|
|
||||||
|
# keys are cops you want to opt in for (nil being all cops)
|
||||||
|
# values are an array of directories to opt in for (nil being all directories)
|
||||||
|
OPT_IN = {
|
||||||
|
nil => %w[Gemfile.d].freeze
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
# this code generates a configuration that disables all cops for all files
|
||||||
|
# _unless_ the cop is already configured in .rubocop.common.yml, OR the file
|
||||||
|
# is in one of the OPT_IN directories. It does this by generating an Exclude
|
||||||
|
# configuration for every cop (except already configured) that lists all
|
||||||
|
# directories (except OPT_IN). AllCops does not support an Include, and
|
||||||
|
# even if it did, inheritance to individual cops would not work correctly.
|
||||||
|
|
||||||
|
def generate_excludes(opt_in_array)
|
||||||
|
return nil unless opt_in_array
|
||||||
|
|
||||||
|
excludes = []
|
||||||
|
dirs_to_exclude_siblings_of = []
|
||||||
|
|
||||||
|
opt_in_array.each do |dir|
|
||||||
|
components = dir.split("/")
|
||||||
|
(0...components.length).each do |i|
|
||||||
|
ancestor = components[0..i].join("/")
|
||||||
|
exclude = "#{ancestor}/*"
|
||||||
|
excludes << exclude unless excludes.include?(exclude) || opt_in_array.include?(ancestor)
|
||||||
|
dirs_to_exclude_siblings_of << ancestor unless dirs_to_exclude_siblings_of.include?(ancestor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
dirs_to_find_siblings_of = dirs_to_exclude_siblings_of.map do |dir|
|
||||||
|
File.dirname(dir)
|
||||||
|
end.uniq
|
||||||
|
|
||||||
|
dirs_to_find_siblings_of.each do |dir|
|
||||||
|
dirs = Dir["#{dir}/*"]
|
||||||
|
.select { |dir| File.directory?(dir) }
|
||||||
|
.map { |dir| dir.sub(%r{^\./}, "") }
|
||||||
|
dirs -= dirs_to_exclude_siblings_of
|
||||||
|
excludes.concat(dirs.map { |d| "#{d}/**/*" })
|
||||||
|
end
|
||||||
|
|
||||||
|
excludes.sort
|
||||||
|
end
|
||||||
|
|
||||||
|
resolved_excludes = OPT_IN.transform_values do |dirs|
|
||||||
|
next nil unless dirs
|
||||||
|
|
||||||
|
generate_excludes((Array(dirs) + OPT_IN[nil]).uniq)
|
||||||
|
end
|
||||||
|
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
|
common_config = YAML.safe_load(File.read(".rubocop.common.yml"))
|
||||||
|
common_config["require"].each { |f| require f }
|
||||||
|
# already configured cops in common.yml are intended to apply to all files already
|
||||||
|
already_configured_cops = common_config.keys.select { |k| k.include?("/") && !common_config[k]['Exclude'] }.to_set
|
||||||
|
|
||||||
|
config = {}
|
||||||
|
RuboCop::Cop::Registry.all.each do |cop|
|
||||||
|
next if cop.department == :Metrics
|
||||||
|
next if cop.cop_name == 'Lint/Syntax'
|
||||||
|
next if already_configured_cops.include?(cop.cop_name)
|
||||||
|
|
||||||
|
key = [cop.cop_name, cop.department.to_s, nil].find do |key|
|
||||||
|
resolved_excludes.key?(key)
|
||||||
|
end
|
||||||
|
excludes = resolved_excludes[key]
|
||||||
|
next if excludes.nil?
|
||||||
|
|
||||||
|
config[cop.cop_name] = { "Exclude" => excludes }
|
||||||
|
end
|
||||||
|
|
||||||
|
config.to_yaml.sub(/^---\n/, "")
|
||||||
|
%>
|
305
.rubocop.yml
305
.rubocop.yml
|
@ -1,97 +1,109 @@
|
||||||
require:
|
inherit_from: .rubocop.common.yml
|
||||||
- rubocop-rails
|
|
||||||
- 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:
|
AllCops:
|
||||||
TargetRubyVersion: 2.7
|
|
||||||
NewCops: enable
|
NewCops: enable
|
||||||
|
|
||||||
# our style changes: disabling style rules we aren't interested in
|
Gemspec/RequiredRubyVersion:
|
||||||
Layout/ParameterAlignment:
|
|
||||||
Enabled: false
|
|
||||||
Layout/ElseAlignment:
|
|
||||||
Enabled: false
|
|
||||||
Layout/EmptyLines:
|
|
||||||
Enabled: false
|
|
||||||
Layout/EmptyLinesAroundAccessModifier:
|
|
||||||
Enabled: false
|
|
||||||
Layout/EmptyLinesAroundArguments:
|
|
||||||
Enabled: false
|
|
||||||
Layout/EmptyLinesAroundBlockBody:
|
|
||||||
Enabled: false
|
|
||||||
Layout/EmptyLinesAroundClassBody:
|
|
||||||
Enabled: false
|
|
||||||
Layout/EmptyLinesAroundMethodBody:
|
|
||||||
Enabled: false
|
|
||||||
Layout/EmptyLinesAroundModuleBody:
|
|
||||||
Enabled: false
|
|
||||||
Layout/FirstHashElementIndentation:
|
|
||||||
Enabled: false
|
|
||||||
Layout/IndentationConsistency:
|
|
||||||
Enabled: false
|
|
||||||
Layout/IndentationWidth:
|
|
||||||
Enabled: false
|
|
||||||
Layout/MultilineOperationIndentation:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceAfterColon:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceAfterComma:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceAroundEqualsInParameterDefault:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceAroundOperators:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceBeforeBlockBraces:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceBeforeFirstArg:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceInLambdaLiteral:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceInsideArrayLiteralBrackets:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceInsideBlockBraces:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceInsideHashLiteralBraces:
|
|
||||||
Enabled: false
|
|
||||||
Layout/SpaceInsideReferenceBrackets:
|
|
||||||
Enabled: false
|
|
||||||
Layout/TrailingEmptyLines:
|
|
||||||
Enabled: false
|
|
||||||
Layout/TrailingWhitespace:
|
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Style/FormatStringToken:
|
Lint/AmbiguousBlockAssociation:
|
||||||
|
Exclude:
|
||||||
|
- spec/**/*
|
||||||
|
|
||||||
|
Naming/VariableNumber:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/StringLiterals:
|
|
||||||
|
Rails/ApplicationRecord:
|
||||||
|
Enabled: false # we never bothered creating an ApplicationRecord
|
||||||
|
Rails/HasManyOrHasOneDependent:
|
||||||
|
# It whines about update_all too much, which we use a lot specifically to
|
||||||
|
# bypass validations and any other AR-ness
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/SignalException:
|
Rails/ReadWriteAttribute:
|
||||||
|
Enabled: false # accessors are often defined in terms of read_attribute
|
||||||
|
Rails/SkipsModelValidations:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/NumericLiterals:
|
Rails/TimeZone:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/PercentLiteralDelimiters:
|
|
||||||
|
RSpec/ContextWording:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/Documentation:
|
RSpec/DescribeClass:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
RSpec/DescribedClass:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/ExampleWording:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/ExpectChange:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/HookArgument:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/MessageSpies:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/NamedSubject:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/NotToNot:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/ScatteredSetup:
|
||||||
|
Enabled: false
|
||||||
|
RSpec/VerifiedDoubles:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Style/BlockDelimiters:
|
||||||
|
Enabled: true
|
||||||
|
Exclude:
|
||||||
|
- spec/**/*_spec.rb
|
||||||
|
- spec/shared_examples/**/*.rb
|
||||||
Style/ClassAndModuleChildren:
|
Style/ClassAndModuleChildren:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/RegexpLiteral:
|
Style/DateTime:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/GuardClause:
|
Style/DoubleNegation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/RedundantSelf:
|
Style/Dir:
|
||||||
|
Enabled: false
|
||||||
|
Style/FormatStringToken:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/IfUnlessModifier:
|
Style/IfUnlessModifier:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/WordArray:
|
Style/GuardClause:
|
||||||
|
Enabled: false
|
||||||
|
Style/HashSyntax:
|
||||||
|
Enabled: false
|
||||||
|
Style/Lambda:
|
||||||
|
Enabled: false
|
||||||
|
Style/MethodCallWithArgsParentheses:
|
||||||
|
Enabled: false
|
||||||
|
Style/MethodCallWithoutArgsParentheses:
|
||||||
|
Enabled: false
|
||||||
|
Style/NumericLiterals:
|
||||||
|
Enabled: false
|
||||||
|
Style/NumericPredicate:
|
||||||
|
Enabled: false
|
||||||
|
Style/ParallelAssignment:
|
||||||
|
Enabled: false
|
||||||
|
Style/PercentLiteralDelimiters:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/PercentQLiterals:
|
Style/PercentQLiterals:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/DoubleNegation:
|
Style/RedundantSelf:
|
||||||
|
Enabled: false
|
||||||
|
Style/RegexpLiteral:
|
||||||
|
Enabled: false
|
||||||
|
Style/RescueModifier:
|
||||||
|
Severity: warning
|
||||||
|
Style/RescueStandardError:
|
||||||
|
EnforcedStyle: implicit
|
||||||
|
Enabled: false
|
||||||
|
Style/ReturnNil:
|
||||||
|
Enabled: false
|
||||||
|
Style/SignalException:
|
||||||
|
Enabled: false
|
||||||
|
Style/StderrPuts:
|
||||||
|
Enabled: false
|
||||||
|
Style/StringLiterals:
|
||||||
|
Enabled: false
|
||||||
|
Style/SymbolArray:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/TrailingCommaInArguments:
|
Style/TrailingCommaInArguments:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -99,156 +111,9 @@ Style/TrailingCommaInArrayLiteral:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/TrailingCommaInHashLiteral:
|
Style/TrailingCommaInHashLiteral:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/MethodCallWithoutArgsParentheses:
|
|
||||||
Enabled: false
|
|
||||||
Style/MethodCallWithArgsParentheses:
|
|
||||||
Enabled: false
|
|
||||||
Layout/HashAlignment:
|
|
||||||
Enabled: false
|
|
||||||
Style/Lambda:
|
|
||||||
Enabled: false
|
|
||||||
Style/WhileUntilModifier:
|
Style/WhileUntilModifier:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/ParallelAssignment:
|
Style/WordArray:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/ZeroLengthPredicate:
|
Style/ZeroLengthPredicate:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/NumericPredicate:
|
|
||||||
Enabled: false
|
|
||||||
Naming/VariableNumber:
|
|
||||||
Enabled: false
|
|
||||||
Style/Dir:
|
|
||||||
Enabled: false
|
|
||||||
Style/ReturnNil:
|
|
||||||
Enabled: false
|
|
||||||
Style/StderrPuts:
|
|
||||||
Enabled: false
|
|
||||||
Style/DateTime:
|
|
||||||
Enabled: false
|
|
||||||
Style/SymbolArray:
|
|
||||||
Enabled: false
|
|
||||||
Style/FrozenStringLiteralComment:
|
|
||||||
Severity: error
|
|
||||||
Style/AsciiComments:
|
|
||||||
Enabled: false
|
|
||||||
Style/BlockDelimiters:
|
|
||||||
Enabled: true
|
|
||||||
Exclude:
|
|
||||||
- spec/**/*_spec.rb
|
|
||||||
- spec/shared_examples/**/*.rb
|
|
||||||
|
|
||||||
# RSpec cops we don't care about
|
|
||||||
RSpec/MessageSpies:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/HookArgument:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/VerifiedDoubles:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/NamedSubject:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/NotToNot:
|
|
||||||
Enabled: false
|
|
||||||
# RSpec cops we care extra about
|
|
||||||
RSpec/EmptyExampleGroup:
|
|
||||||
Severity: error
|
|
||||||
RSpec/RepeatedDescription:
|
|
||||||
Severity: error
|
|
||||||
RSpec/ExpectChange:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# this isn't good for us because of how we pin dependencies
|
|
||||||
Bundler/OrderedGems:
|
|
||||||
Enabled: false
|
|
||||||
Gemspec/OrderedDependencies:
|
|
||||||
Enabled: false
|
|
||||||
Gemspec/RequiredRubyVersion:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Rails style changes
|
|
||||||
Migration/Tagged:
|
|
||||||
Enabled: true
|
|
||||||
Severity: error
|
|
||||||
AllowedTags:
|
|
||||||
- predeploy
|
|
||||||
- postdeploy
|
|
||||||
- cassandra
|
|
||||||
- dynamodb
|
|
||||||
Rails:
|
|
||||||
Enabled: true
|
|
||||||
Rails/TimeZone:
|
|
||||||
Enabled: false
|
|
||||||
# accessors are often defined in terms of read_attribute
|
|
||||||
Rails/ReadWriteAttribute:
|
|
||||||
Enabled: false
|
|
||||||
# we never bothered creating an ApplicationRecord
|
|
||||||
Rails/ApplicationRecord:
|
|
||||||
Enabled: false
|
|
||||||
Rails/HasManyOrHasOneDependent:
|
|
||||||
Enabled: false
|
|
||||||
# It whines about update_all too much, which we use a lot specifically to
|
|
||||||
# bypass validations and any other AR-ness
|
|
||||||
Rails/SkipsModelValidations:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Lint changes
|
|
||||||
Lint/AmbiguousRegexpLiteral:
|
|
||||||
Severity: convention
|
|
||||||
Lint/AmbiguousBlockAssociation:
|
|
||||||
Exclude:
|
|
||||||
- spec/**/*
|
|
||||||
Lint/UselessAssignment:
|
|
||||||
Severity: convention
|
|
||||||
Lint/Debugger:
|
|
||||||
Severity: error
|
|
||||||
Layout/EndAlignment:
|
|
||||||
EnforcedStyleAlignWith: variable
|
|
||||||
Severity: convention
|
|
||||||
|
|
||||||
# Performance changes
|
|
||||||
Performance/Detect:
|
|
||||||
Severity: warning
|
|
||||||
Performance/TimesMap:
|
|
||||||
Exclude:
|
|
||||||
- spec/**/*
|
|
||||||
|
|
||||||
# these need better configuration than the default:
|
|
||||||
Style/AndOr:
|
|
||||||
EnforcedStyle: conditionals
|
|
||||||
Style/RescueModifier:
|
|
||||||
Severity: warning
|
|
||||||
Layout/MultilineMethodCallIndentation:
|
|
||||||
EnforcedStyle: indented
|
|
||||||
Layout/FirstArrayElementIndentation:
|
|
||||||
EnforcedStyle: consistent
|
|
||||||
|
|
||||||
# SnR is just too low to have this enabled
|
|
||||||
Metrics:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
RSpec/InstanceVariable:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/ExampleWording:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/ContextWording:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/ExampleLength:
|
|
||||||
Max: 48
|
|
||||||
RSpec/NestedGroups:
|
|
||||||
Max: 5
|
|
||||||
RSpec/DescribedClass:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/DescribeClass:
|
|
||||||
Enabled: false
|
|
||||||
Style/HashSyntax:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/MultipleExpectations:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/ScatteredSetup:
|
|
||||||
Enabled: false
|
|
||||||
Style/RescueStandardError:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Specs/EnsureSpecExtension:
|
|
||||||
Enabled: true
|
|
||||||
Exclude:
|
|
||||||
- spec/shared_examples/**/*
|
|
||||||
|
|
26
Gemfile
26
Gemfile
|
@ -2,23 +2,27 @@
|
||||||
|
|
||||||
# What have they done to the Gemfile???
|
# What have they done to the Gemfile???
|
||||||
#
|
#
|
||||||
# Relax. Breathe deep. All the gems are still there; they're just loaded in various files in Gemfile.d/
|
# Relax. Breathe deep. All the gems are still there; they're just loaded in
|
||||||
# This allows us to require gems locally that we might not want to commit to our public repo. We can maintain
|
# various files in Gemfile.d/. This allows us to require gems locally that we
|
||||||
# a customized list of gems for development and debuggery, without affecting our ability to merge with canvas-lms
|
# might not want to commit to our public repo. We can maintain a customized
|
||||||
|
# list of gems for development and debuggery, without affecting our ability to
|
||||||
|
# merge with canvas-lms
|
||||||
#
|
#
|
||||||
# NOTE: some files in Gemfile.d/ will have certain required gems indented. While this may seem arbitrary,
|
# NOTE: some files in Gemfile.d/ will have certain required gems indented.
|
||||||
# it actually has semantic significance. An indented gem required in Gemfile is a gem that is NOT
|
# While this may seem arbitrary, it actually has semantic significance. An
|
||||||
# directly used by Canvas, but required by a gem that is used by Canvas. We lock into specific versions of
|
# indented gem required in Gemfile is a gem that is NOT directly used by
|
||||||
# these gems to prevent regression, and the indentation serves to alert us to the relationship between the gem and canvas-lms
|
# Canvas, but required by a gem that is used by Canvas. We lock into specific
|
||||||
|
# versions of these gems to prevent regression, and the indentation serves to
|
||||||
|
# alert us to the relationship between the gem and canvas-lms
|
||||||
|
|
||||||
source 'https://rubygems.org/'
|
source 'https://rubygems.org/'
|
||||||
|
|
||||||
|
|
||||||
Dir[File.join(File.dirname(__FILE__), 'gems/plugins/*/Gemfile.d/_before.rb')].each do |file|
|
Dir[File.join(File.dirname(__FILE__), 'gems/plugins/*/Gemfile.d/_before.rb')].each do |file|
|
||||||
eval(File.read(file), nil, file)
|
eval(File.read(file), nil, file) # rubocop:disable Security/Eval
|
||||||
end
|
end
|
||||||
|
|
||||||
require File.expand_path("../config/canvas_rails_switcher", __FILE__)
|
require File.expand_path('config/canvas_rails_switcher', __dir__)
|
||||||
|
|
||||||
Dir.glob(File.join(File.dirname(__FILE__), 'Gemfile.d', '*.rb')).sort.each do |file|
|
Dir.glob(File.join(File.dirname(__FILE__), 'Gemfile.d', '*.rb')).sort.each do |file|
|
||||||
eval(File.read(file), nil, file)
|
eval(File.read(file), nil, file) # rubocop:disable Security/Eval
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
inherit_from: ../.rubocop.yml
|
|
||||||
|
|
||||||
Layout/LineLength:
|
|
||||||
Enabled: false
|
|
||||||
Layout/IndentationConsistency:
|
|
||||||
Enabled: false
|
|
||||||
Metrics/MethodLength:
|
|
||||||
Enabled: false
|
|
||||||
Metrics/ClassLength:
|
|
||||||
Enabled: false
|
|
|
@ -26,9 +26,9 @@ if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('1.14.0') &&
|
||||||
end
|
end
|
||||||
|
|
||||||
if RUBY_ENGINE == 'truffleruby'
|
if RUBY_ENGINE == 'truffleruby'
|
||||||
$stderr.puts "TruffleRuby support is experimental" unless ENV['SUPPRESS_RUBY_WARNING']
|
warn "TruffleRuby support is experimental" unless ENV['SUPPRESS_RUBY_WARNING']
|
||||||
elsif RUBY_VERSION >= "3.0.0" && RUBY_VERSION < "3.1"
|
elsif RUBY_VERSION >= "3.0.0" && RUBY_VERSION < "3.1"
|
||||||
$stderr.puts "Ruby 3.0+ support is experimental" unless ENV['SUPPRESS_RUBY_WARNING']
|
warn "Ruby 3.0+ support is experimental" unless ENV['SUPPRESS_RUBY_WARNING']
|
||||||
end
|
end
|
||||||
ruby '>= 2.6.0', '< 3.1'
|
ruby '>= 2.6.0', '< 3.1'
|
||||||
|
|
||||||
|
@ -45,10 +45,9 @@ unless CANVAS_RAILS6_0
|
||||||
end
|
end
|
||||||
|
|
||||||
Bundler::Dsl.class_eval do
|
Bundler::Dsl.class_eval do
|
||||||
def to_definition(lockfile, unlock)
|
def to_definition(_lockfile, unlock)
|
||||||
@sources << @rubygems_source if @sources.respond_to?(:include?) && !@sources.include?(@rubygems_source)
|
@sources << @rubygems_source if @sources.respond_to?(:include?) && !@sources.include?(@rubygems_source)
|
||||||
Definition.new(Bundler.default_lockfile, @dependencies, @sources, unlock, @ruby_version)
|
Definition.new(Bundler.default_lockfile, @dependencies, @sources, unlock, @ruby_version)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License along
|
# You should have received a copy of the GNU Affero General Public License along
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Note: Indented gems are meant to indicate transient dependencies of parent gems
|
# NOTE: Indented gems are meant to indicate transient dependencies of parent gems
|
||||||
|
|
||||||
if CANVAS_RAILS6_0
|
if CANVAS_RAILS6_0
|
||||||
gem 'rails', '6.0.4.1'
|
gem 'rails', '6.0.4.1'
|
||||||
|
|
|
@ -18,10 +18,11 @@
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
group :cassandra do
|
group :cassandra do
|
||||||
gem 'cassandra-cql', '1.2.3', github: 'kreynolds/cassandra-cql', ref: '02b5abbe441a345c051a180327932566fd66bb36' #dependency of canvas_cassandra
|
gem 'cassandra-cql', '1.2.3', github: 'kreynolds/cassandra-cql',
|
||||||
|
ref: '02b5abbe441a345c051a180327932566fd66bb36' # dependency of canvas_cassandra
|
||||||
gem 'simple_uuid', '0.4.0', require: false
|
gem 'simple_uuid', '0.4.0', require: false
|
||||||
gem 'thrift', '0.9.3.0', require: false
|
gem 'thrift', '0.9.3.0', require: false
|
||||||
gem 'thrift_client', '0.9.3', require: false, github: 'twitter/thrift_client', ref: '5c10d59881825cb8e26ab1aa8f1d2738e88c0e83'
|
gem 'thrift_client', '0.9.3', require: false, github: 'twitter/thrift_client',
|
||||||
|
ref: '5c10d59881825cb8e26ab1aa8f1d2738e88c0e83'
|
||||||
gem "canvas_cassandra", path: "gems/canvas_cassandra"
|
gem "canvas_cassandra", path: "gems/canvas_cassandra"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,8 @@
|
||||||
|
|
||||||
group :i18n_tools do
|
group :i18n_tools do
|
||||||
gem 'i18n_extraction', path: 'gems/i18n_extraction', require: false
|
gem 'i18n_extraction', path: 'gems/i18n_extraction', require: false
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
group :i18n_tools, :development do
|
group :i18n_tools, :development do
|
||||||
gem 'i18n_tasks', path: 'gems/i18n_tasks'
|
gem 'i18n_tasks', path: 'gems/i18n_tasks'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ group :test do
|
||||||
gem 'rubocop-canvas', require: false, path: "#{'../' if dedicated_gemfile}gems/rubocop-canvas"
|
gem 'rubocop-canvas', require: false, path: "#{'../' if dedicated_gemfile}gems/rubocop-canvas"
|
||||||
gem 'rainbow', '3.0.0', require: false
|
gem 'rainbow', '3.0.0', require: false
|
||||||
gem 'rubocop-rails', '2.11.3', require: false
|
gem 'rubocop-rails', '2.11.3', require: false
|
||||||
|
gem 'rubocop-rake', '0.6.0', require: false
|
||||||
gem 'rubocop-rspec', '2.4.0', require: false
|
gem 'rubocop-rspec', '2.4.0', require: false
|
||||||
gem 'rubocop-performance', '1.11.5', require: false
|
gem 'rubocop-performance', '1.11.5', require: false
|
||||||
end
|
end
|
||||||
|
|
|
@ -63,6 +63,8 @@ GEM
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
rack (>= 1.1)
|
rack (>= 1.1)
|
||||||
rubocop (>= 1.7.0, < 2.0)
|
rubocop (>= 1.7.0, < 2.0)
|
||||||
|
rubocop-rake (0.6.0)
|
||||||
|
rubocop (~> 1.0)
|
||||||
rubocop-rspec (2.4.0)
|
rubocop-rspec (2.4.0)
|
||||||
rubocop (~> 1.0)
|
rubocop (~> 1.0)
|
||||||
rubocop-ast (>= 1.1.0)
|
rubocop-ast (>= 1.1.0)
|
||||||
|
@ -85,6 +87,7 @@ DEPENDENCIES
|
||||||
rubocop-canvas!
|
rubocop-canvas!
|
||||||
rubocop-performance (= 1.11.5)
|
rubocop-performance (= 1.11.5)
|
||||||
rubocop-rails (= 2.11.3)
|
rubocop-rails (= 2.11.3)
|
||||||
|
rubocop-rake (= 0.6.0)
|
||||||
rubocop-rspec (= 2.4.0)
|
rubocop-rspec (= 2.4.0)
|
||||||
unicode-display_width (= 2.1.0)
|
unicode-display_width (= 2.1.0)
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,6 @@ group :test do
|
||||||
# axe-core* versions at or above 4.2 have difficulties with iframes. Keep these at 4.1.0 until fixes are investigated
|
# axe-core* versions at or above 4.2 have difficulties with iframes. Keep these at 4.1.0 until fixes are investigated
|
||||||
gem 'axe-core-selenium', '~> 4.1.0', require: false
|
gem 'axe-core-selenium', '~> 4.1.0', require: false
|
||||||
gem 'axe-core-rspec', '~> 4.1.0', require: false
|
gem 'axe-core-rspec', '~> 4.1.0', require: false
|
||||||
gem 'axe-core-api', '~> 4.1.0', require:false
|
gem 'axe-core-api', '~> 4.1.0', require: false
|
||||||
gem 'stormbreaker', '0.0.4', require: false
|
gem 'stormbreaker', '0.0.4', require: false
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,5 +21,6 @@
|
||||||
# plugins.
|
# plugins.
|
||||||
Dir[File.join(File.dirname(__FILE__), '../gems/plugins/*/Gemfile.d/*')].each do |g|
|
Dir[File.join(File.dirname(__FILE__), '../gems/plugins/*/Gemfile.d/*')].each do |g|
|
||||||
next if g.end_with?('/_before.rb')
|
next if g.end_with?('/_before.rb')
|
||||||
eval(File.read(g), nil, g)
|
|
||||||
|
eval(File.read(g), nil, g) # rubocop:disable Security/Eval
|
||||||
end
|
end
|
||||||
|
|
2
Rakefile
2
Rakefile
|
@ -3,7 +3,7 @@
|
||||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||||
|
|
||||||
require File.expand_path('../config/application', __FILE__)
|
require File.expand_path('config/application', __dir__)
|
||||||
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/testtask'
|
require 'rake/testtask'
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
inherit_from: ../.rubocop.yml
|
|
||||||
|
|
||||||
Migration/Delay:
|
|
||||||
Enabled: false
|
|
|
@ -27,7 +27,8 @@ gergich capture i18nliner 'rake i18n:check'
|
||||||
ruby script/brakeman
|
ruby script/brakeman
|
||||||
ruby script/tatl_tael
|
ruby script/tatl_tael
|
||||||
ruby script/stylelint
|
ruby script/stylelint
|
||||||
ruby script/rlint --no-fail-on-offense
|
ruby script/rlint --optional --no-fail-on-offense
|
||||||
|
ruby script/rlint --boy-scout --no-fail-on-offense
|
||||||
[ "${SKIP_ESLINT-}" != "true" ] && ruby script/eslint
|
[ "${SKIP_ESLINT-}" != "true" ] && ruby script/eslint
|
||||||
ruby script/lint_commit_message
|
ruby script/lint_commit_message
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# This file is used by Rack-based servers to start the application.
|
# This file is used by Rack-based servers to start the application.
|
||||||
|
|
||||||
require ::File.expand_path('../config/environment', __FILE__)
|
require ::File.expand_path('config/environment', __dir__)
|
||||||
if defined?(CanvasRails)
|
if defined?(CanvasRails)
|
||||||
run CanvasRails::Application
|
run CanvasRails::Application
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
inherit_from: ../../.rubocop.yml
|
|
||||||
|
|
||||||
Layout/LineLength:
|
|
||||||
Enabled: false
|
|
||||||
Layout/IndentationConsistency:
|
|
||||||
Enabled: false
|
|
||||||
Metrics/MethodLength:
|
|
||||||
Enabled: false
|
|
||||||
Metrics/ClassLength:
|
|
||||||
Enabled: false
|
|
||||||
Metrics/AbcSize:
|
|
||||||
Enabled: false
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ -f node_modules/.bin/lint-staged ]; then
|
if [ -f node_modules/.bin/lint-staged ]; then
|
||||||
yarn run --silent lint:staged
|
yarn run --silent lint:staged
|
||||||
else
|
else
|
||||||
|
@ -7,4 +8,6 @@ else
|
||||||
echo 'You should run `yarn` locally or check to make sure docker is running.'
|
echo 'You should run `yarn` locally or check to make sure docker is running.'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
script/rlint ${RLINT_ARGUMENTS:---auto-correct}
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -162,6 +162,11 @@ class Linter
|
||||||
end
|
end
|
||||||
|
|
||||||
if gerrit_patchset
|
if gerrit_patchset
|
||||||
|
if boyscout_mode
|
||||||
|
processed_comments.each do |comment|
|
||||||
|
comment[:severity] = :error
|
||||||
|
end
|
||||||
|
end
|
||||||
publish_gergich_comments(processed_comments)
|
publish_gergich_comments(processed_comments)
|
||||||
else
|
else
|
||||||
publish_local_comments(processed_comments)
|
publish_local_comments(processed_comments)
|
||||||
|
|
43
script/rlint
43
script/rlint
|
@ -10,7 +10,8 @@ linter_options = {
|
||||||
linter_name: "Rubocop",
|
linter_name: "Rubocop",
|
||||||
file_regex: %r{(?:\.e?rb|\.rake|\.gemspec|/[^./]+)$},
|
file_regex: %r{(?:\.e?rb|\.rake|\.gemspec|/[^./]+)$},
|
||||||
format: "rubocop",
|
format: "rubocop",
|
||||||
command: "bin/rubocop",
|
command: +"bin/rubocop",
|
||||||
|
auto_correct: false,
|
||||||
campsite_mode: false,
|
campsite_mode: false,
|
||||||
append_files_to_command: true,
|
append_files_to_command: true,
|
||||||
severe_levels: [],
|
severe_levels: [],
|
||||||
|
@ -25,13 +26,47 @@ linter_options = {
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
no_fail = false
|
no_fail = false
|
||||||
|
optional = false
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
|
# boy scout means treat everything as an error
|
||||||
|
opts.on("--boy-scout", "Treat all comments as errors") { linter_options[:boyscout_mode] = true }
|
||||||
opts.on("--heavy") { linter_options[:heavy_mode] = true }
|
opts.on("--heavy") { linter_options[:heavy_mode] = true }
|
||||||
opts.on("--boy-scout") { linter_options[:boyscout_mode] = true }
|
opts.on("--optional", "Run against the optional rubocop ruleset, instead of the default") { optional = true }
|
||||||
opts.on("--plugin PLUGIN") { |v| linter_options[:plugin] = v }
|
opts.on("--plugin PLUGIN", "Inspect changes from the given plugin, instead of canvas-lms") do |v|
|
||||||
opts.on("--no-fail-on-offense") { |v| no_fail = true }
|
linter_options[:plugin] = v
|
||||||
|
end
|
||||||
|
opts.on("--no-fail-on-offense",
|
||||||
|
<<~TEXT.tr("\n", " ")) do |_v|
|
||||||
|
Don't fail (exit code) if you find an offense.
|
||||||
|
Use if you're processing the output elsewise, like in Jenkins+Gergich.
|
||||||
|
TEXT
|
||||||
|
no_fail = true
|
||||||
|
end
|
||||||
|
opts.on("-a", "--auto-correct") do |_v|
|
||||||
|
linter_options[:auto_correct] = true
|
||||||
|
linter_options[:command] << " -a"
|
||||||
|
end
|
||||||
|
opts.on("-A", "--auto-correct-all") do |_v|
|
||||||
|
linter_options[:auto_correct] = true
|
||||||
|
linter_options[:command] << " -A"
|
||||||
|
end
|
||||||
|
opts.on("-x", "--fix-laout") do
|
||||||
|
linter_options[:auto_correct] = true
|
||||||
|
linter_options[:command] << " -x"
|
||||||
|
end
|
||||||
|
opts.on("-h", "--help", "Display this usage information") do
|
||||||
|
puts opts
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
end.parse!
|
end.parse!
|
||||||
|
|
||||||
|
# without optional, we only run against the "enforced" config. this makes it so
|
||||||
|
# that jenkins will warn about a larger config, but the pre-commit hook can
|
||||||
|
# auto-correct against a much smaller config.
|
||||||
|
unless optional
|
||||||
|
linter_options[:command] << " -c .rubocop.enforced.yml --force-exclusion"
|
||||||
|
end
|
||||||
|
|
||||||
rlint = Linter.new(linter_options)
|
rlint = Linter.new(linter_options)
|
||||||
exit 1 if !rlint.run && !no_fail
|
exit 1 if !rlint.run && !no_fail
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 - present Instructure, Inc.
|
# Copyright (C) 2011 - present Instructure, Inc.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue