Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 56 additions & 56 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inherit_mode:

AllCops:
Exclude:
- '**/app/assets/**/*'
- '{,./**/}app/assets/**/*'
- bin/*
# Exclude db/schema.rb and db/[CONFIGURATION_NAMESPACE]_schema.rb by default.
# See: https://guides.rubyonrails.org/active_record_multiple_databases.html#setting-up-your-application
Expand Down Expand Up @@ -94,8 +94,8 @@ Lint/UselessAccessModifier:
Lint/UselessMethodDefinition:
# Avoids conflict with `Rails/LexicallyScopedActionFilter` cop.
Exclude:
- '**/app/controllers/**/*.rb'
- '**/app/mailers/**/*.rb'
- '{,./**/}app/controllers/**/*.rb'
- '{,./**/}app/mailers/**/*.rb'

Rails:
Enabled: true
Expand All @@ -115,7 +115,7 @@ Rails/ActionControllerTestCase:
SafeAutoCorrect: false
VersionAdded: '2.14'
Include:
- '**/test/**/*.rb'
- '{,./**/}test/**/*.rb'

Rails/ActionFilter:
Description: 'Enforces consistent use of action filter methods.'
Expand All @@ -127,8 +127,8 @@ Rails/ActionFilter:
- action
- filter
Include:
- '**/app/controllers/**/*.rb'
- '**/app/mailers/**/*.rb'
- '{,./**/}app/controllers/**/*.rb'
- '{,./**/}app/mailers/**/*.rb'

Rails/ActionOrder:
Description: 'Enforce consistent ordering of controller actions.'
Expand All @@ -143,7 +143,7 @@ Rails/ActionOrder:
- update
- destroy
Include:
- '**/app/controllers/**/*.rb'
- '{,./**/}app/controllers/**/*.rb'

Rails/ActiveRecordAliases:
Description: >-
Expand All @@ -160,7 +160,7 @@ Rails/ActiveRecordCallbacksOrder:
Enabled: 'pending'
VersionAdded: '2.7'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/ActiveRecordOverride:
Description: >-
Expand All @@ -171,7 +171,7 @@ Rails/ActiveRecordOverride:
VersionAdded: '0.67'
VersionChanged: '2.18'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/ActiveSupportAliases:
Description: >-
Expand Down Expand Up @@ -251,14 +251,14 @@ Rails/AssertNot:
Enabled: true
VersionAdded: '0.56'
Include:
- '**/test/**/*'
- '{,./**/}test/**/*'

Rails/AttributeDefaultBlockValue:
Description: 'Pass method call in block for attribute option `default`.'
Enabled: pending
VersionAdded: '2.9'
Include:
- '**/app/models/**/*'
- '{,./**/}app/models/**/*'

Rails/BelongsTo:
Description: >-
Expand Down Expand Up @@ -317,8 +317,8 @@ Rails/ContentTag:
# https://puma.io/puma/Puma/DSL.html#tag-instance_method
# No helpers are used in normal models and configs.
Exclude:
- '**/app/models/**/*.rb'
- '**/config/**/*.rb'
- '{,./**/}app/models/**/*.rb'
- '{,./**/}config/**/*.rb'

Rails/CreateTableWithTimestamps:
Description: >-
Expand Down Expand Up @@ -379,7 +379,7 @@ Rails/Delegate:
# violation. When set to false, this case is legal.
EnforceForPrefixed: true
Exclude:
- '**/app/controllers/**/*.rb'
- '{,./**/}app/controllers/**/*.rb'

Rails/DelegateAllowBlank:
Description: 'Do not use allow_blank as an option to delegate.'
Expand Down Expand Up @@ -450,23 +450,23 @@ Rails/EnumHash:
Enabled: true
VersionAdded: '2.3'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/EnumSyntax:
Description: 'Use positional arguments over keyword arguments when defining enums.'
Enabled: pending
Severity: warning
VersionAdded: '2.26'
Include:
- '**/app/models/**/*.rb'
- '**/lib/**/*.rb'
- '{,./**/}app/models/**/*.rb'
- '{,./**/}lib/**/*.rb'

Rails/EnumUniqueness:
Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
Enabled: true
VersionAdded: '0.46'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/EnvLocal:
Description: 'Use `Rails.env.local?` instead of `Rails.env.development? || Rails.env.test?`.'
Expand All @@ -485,11 +485,11 @@ Rails/EnvironmentVariableAccess:
VersionAdded: '2.10'
VersionChanged: '2.24'
Include:
- '**/app/**/*.rb'
- '**/config/initializers/**/*.rb'
- '**/lib/**/*.rb'
- '{,./**/}app/**/*.rb'
- '{,./**/}config/initializers/**/*.rb'
- '{,./**/}lib/**/*.rb'
Exclude:
- '**/lib/**/*.rake'
- '{,./**/}lib/**/*.rake'
AllowReads: false
AllowWrites: false

Expand All @@ -501,11 +501,11 @@ Rails/Exit:
Enabled: true
VersionAdded: '0.41'
Include:
- '**/app/**/*.rb'
- '**/config/**/*.rb'
- '**/lib/**/*.rb'
- '{,./**/}app/**/*.rb'
- '{,./**/}config/**/*.rb'
- '{,./**/}lib/**/*.rb'
Exclude:
- '**/lib/**/*.rake'
- '{,./**/}lib/**/*.rake'

Rails/ExpandedDateRange:
Description: 'Checks for expanded date range.'
Expand Down Expand Up @@ -574,22 +574,22 @@ Rails/HasAndBelongsToMany:
Enabled: true
VersionAdded: '0.12'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/HasManyOrHasOneDependent:
Description: 'Define the dependent option to the has_many and has_one associations.'
StyleGuide: 'https://rails.rubystyle.guide#has_many-has_one-dependent-option'
Enabled: true
VersionAdded: '0.50'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/HelperInstanceVariable:
Description: 'Do not use instance variables in helpers.'
Enabled: true
VersionAdded: '2.0'
Include:
- '**/app/helpers/**/*.rb'
- '{,./**/}app/helpers/**/*.rb'

Rails/HttpPositionalArguments:
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
Expand Down Expand Up @@ -620,7 +620,7 @@ Rails/I18nLazyLookup:
- lazy
- explicit
Include:
- '**/app/controllers/**/*.rb'
- '{,./**/}app/controllers/**/*.rb'

Rails/I18nLocaleAssignment:
Description: 'Prefer the usage of `I18n.with_locale` instead of manually updating `I18n.locale` value.'
Expand Down Expand Up @@ -649,8 +649,8 @@ Rails/IgnoredSkipActionFilterOption:
Enabled: true
VersionAdded: '0.63'
Include:
- '**/app/controllers/**/*.rb'
- '**/app/mailers/**/*.rb'
- '{,./**/}app/controllers/**/*.rb'
- '{,./**/}app/mailers/**/*.rb'

Rails/IndexBy:
Description: 'Prefer `index_by` over `each_with_object`, `to_h`, or `map`.'
Expand Down Expand Up @@ -680,7 +680,7 @@ Rails/InverseOf:
VersionAdded: '0.52'
IgnoreScopes: false
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/LexicallyScopedActionFilter:
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the class."
Expand All @@ -689,8 +689,8 @@ Rails/LexicallyScopedActionFilter:
Safe: false
VersionAdded: '0.52'
Include:
- '**/app/controllers/**/*.rb'
- '**/app/mailers/**/*.rb'
- '{,./**/}app/controllers/**/*.rb'
- '{,./**/}app/mailers/**/*.rb'

Rails/LinkToBlank:
Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
Expand All @@ -708,7 +708,7 @@ Rails/MailerName:
SafeAutoCorrect: false
VersionAdded: '2.7'
Include:
- '**/app/mailers/**/*.rb'
- '{,./**/}app/mailers/**/*.rb'

Rails/MatchRoute:
Description: >-
Expand All @@ -718,8 +718,8 @@ Rails/MatchRoute:
Enabled: 'pending'
VersionAdded: '2.7'
Include:
- '**/config/routes.rb'
- '**/config/routes/**/*.rb'
- '{,./**/}config/routes.rb'
- '{,./**/}config/routes/**/*.rb'

Rails/MigrationClassName:
Description: 'The class name of the migration should match its file name.'
Expand All @@ -735,8 +735,8 @@ Rails/MultipleRoutePaths:
Severity: warning
VersionAdded: '2.29'
Include:
- '**/config/routes.rb'
- '**/config/routes/**/*.rb'
- '{,./**/}config/routes.rb'
- '{,./**/}config/routes/**/*.rb'

Rails/NegateInclude:
Description: 'Prefer `collection.exclude?(obj)` over `!collection.include?(obj)`.'
Expand Down Expand Up @@ -779,10 +779,10 @@ Rails/Output:
VersionAdded: '0.15'
VersionChanged: '0.19'
Include:
- '**/app/**/*.rb'
- '**/config/**/*.rb'
- '{,./**/}app/**/*.rb'
- '{,./**/}config/**/*.rb'
- db/**/*.rb
- '**/lib/**/*.rb'
- '{,./**/}lib/**/*.rb'

Rails/OutputSafety:
Description: 'The use of `html_safe` or `raw` may be a security risk.'
Expand Down Expand Up @@ -851,10 +851,10 @@ Rails/RakeEnvironment:
VersionAdded: '2.4'
VersionChanged: '2.6'
Include:
- '**/Rakefile'
- '**/*.rake'
- '{,./**/}Rakefile'
- '{,./**/}*.rake'
Exclude:
- '**/lib/capistrano/tasks/**/*.rake'
- '{,./**/}lib/capistrano/tasks/**/*.rake'

Rails/ReadWriteAttribute:
Description: >-
Expand All @@ -865,7 +865,7 @@ Rails/ReadWriteAttribute:
VersionAdded: '0.20'
VersionChanged: '0.29'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/RedundantActiveRecordAllMethod:
Description: Detect redundant `all` used as a receiver for Active Record query methods.
Expand All @@ -884,7 +884,7 @@ Rails/RedundantAllowNil:
Enabled: true
VersionAdded: '0.67'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/RedundantForeignKey:
Description: 'Checks for associations where the `:foreign_key` option is redundant.'
Expand Down Expand Up @@ -926,7 +926,7 @@ Rails/RefuteMethods:
- assert_not
- refute
Include:
- '**/test/**/*'
- '{,./**/}test/**/*'

Rails/RelativeDateConstant:
Description: 'Do not assign relative date to constants.'
Expand Down Expand Up @@ -1055,7 +1055,7 @@ Rails/ScopeArgs:
VersionAdded: '0.19'
VersionChanged: '2.12'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/SelectMap:
Description: 'Checks for uses of `select(:column_name)` with `map(&:column_name)`.'
Expand Down Expand Up @@ -1124,7 +1124,7 @@ Rails/StrongParametersExpect:
Reference: 'https://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-expect'
Enabled: pending
Include:
- '**/app/controllers/**/*.rb'
- '{,./**/}app/controllers/**/*.rb'
SafeAutoCorrect: false
VersionAdded: '2.29'

Expand All @@ -1135,7 +1135,7 @@ Rails/TableNameAssignment:
Enabled: false
VersionAdded: '2.14'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/ThreeStateBooleanColumn:
Description: 'Add a default value and a `NOT NULL` constraint to boolean columns.'
Expand All @@ -1160,7 +1160,7 @@ Rails/TimeZone:
- strict
- flexible
Exclude:
- '**/*.gemspec'
- '{,./**/}*.gemspec'

Rails/TimeZoneAssignment:
Description: 'Prefer the usage of `Time.use_zone` instead of manually updating `Time.zone` value.'
Expand Down Expand Up @@ -1219,7 +1219,7 @@ Rails/UniqueValidationWithoutIndex:
Enabled: true
VersionAdded: '2.5'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/UnknownEnv:
Description: 'Use correct environment name.'
Expand All @@ -1238,7 +1238,7 @@ Rails/UnusedIgnoredColumns:
VersionAdded: '2.11'
VersionChanged: '2.25'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/UnusedRenderContent:
Description: 'Do not specify body content for a response with a non-content status code.'
Expand All @@ -1252,7 +1252,7 @@ Rails/Validation:
VersionAdded: '0.9'
VersionChanged: '0.41'
Include:
- '**/app/models/**/*.rb'
- '{,./**/}app/models/**/*.rb'

Rails/WhereEquals:
Description: 'Pass conditions to `where` and `where.not` as a hash instead of manually constructing SQL.'
Expand Down
12 changes: 7 additions & 5 deletions spec/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,15 @@
next if config[name][clusivity_key].nil?

config[name][clusivity_key].each do |clusivity_pattern|
expect(clusivity_pattern).to match(%r{\*\*/app/}), <<~ERROR if clusivity_pattern.match?(%r{\bapp/})
expect(clusivity_pattern).to match(%r{\{,./\*\*/\}app/}), <<~ERROR if clusivity_pattern.match?(%r{\bapp/})
Invalid pattern for #{name} #{clusivity_key}: #{clusivity_pattern}
ERROR
expect(clusivity_pattern).to match(%r{\*\*/config/}), <<~ERROR if clusivity_pattern.match?(%r{\bconfig/})
Invalid pattern for #{name} #{clusivity_key}: #{clusivity_pattern}
ERROR
expect(clusivity_pattern).to match(%r{\*\*/lib/}), <<~ERROR if clusivity_pattern.match?(%r{\blib/})
if clusivity_pattern.match?(%r{\bconfig/})
expect(clusivity_pattern).to match(%r{\{,./\*\*/\}config/}), <<~ERROR
Invalid pattern for #{name} #{clusivity_key}: #{clusivity_pattern}
ERROR
end
expect(clusivity_pattern).to match(%r{\{,./\*\*/\}lib/}), <<~ERROR if clusivity_pattern.match?(%r{\blib/})
Invalid pattern for #{name} #{clusivity_key}: #{clusivity_pattern}
ERROR
end
Expand Down