Skip to content

Commit 1126d68

Browse files
committed
[Fix #234] Use globs that are compatible with Engine or Packwerk.
1 parent e97c93f commit 1126d68

File tree

3 files changed

+68
-47
lines changed

3 files changed

+68
-47
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#234](https://github.com/rubocop/rubocop-rails/issues/234): Use globs that are compatible with Engine or Packwerk. ([@tdeo][])

config/default.yml

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ inherit_mode:
66

77
AllCops:
88
Exclude:
9-
- app/assets/**/*
9+
- '**/app/assets/**/*'
1010
- bin/*
1111
# Exclude db/schema.rb and db/[CONFIGURATION_NAMESPACE]_schema.rb by default.
1212
# See: https://guides.rubyonrails.org/active_record_multiple_databases.html#setting-up-your-application
@@ -121,8 +121,8 @@ Rails/ActionFilter:
121121
- action
122122
- filter
123123
Include:
124-
- app/controllers/**/*.rb
125-
- app/mailers/**/*.rb
124+
- '**/app/controllers/**/*.rb'
125+
- '**/app/mailers/**/*.rb'
126126

127127
Rails/ActionOrder:
128128
Description: 'Enforce consistent ordering of controller actions.'
@@ -137,7 +137,7 @@ Rails/ActionOrder:
137137
- update
138138
- destroy
139139
Include:
140-
- app/controllers/**/*.rb
140+
- '**/app/controllers/**/*.rb'
141141

142142
Rails/ActiveRecordAliases:
143143
Description: >-
@@ -154,7 +154,7 @@ Rails/ActiveRecordCallbacksOrder:
154154
Enabled: 'pending'
155155
VersionAdded: '2.7'
156156
Include:
157-
- app/models/**/*.rb
157+
- '**/app/models/**/*.rb'
158158

159159
Rails/ActiveRecordOverride:
160160
Description: >-
@@ -165,7 +165,7 @@ Rails/ActiveRecordOverride:
165165
VersionAdded: '0.67'
166166
VersionChanged: '2.18'
167167
Include:
168-
- app/models/**/*.rb
168+
- '**/app/models/**/*.rb'
169169

170170
Rails/ActiveSupportAliases:
171171
Description: >-
@@ -252,7 +252,7 @@ Rails/AttributeDefaultBlockValue:
252252
Enabled: pending
253253
VersionAdded: '2.9'
254254
Include:
255-
- 'app/models/**/*'
255+
- '**/app/models/**/*'
256256

257257
Rails/BelongsTo:
258258
Description: >-
@@ -311,8 +311,8 @@ Rails/ContentTag:
311311
# https://puma.io/puma/Puma/DSL.html#tag-instance_method
312312
# No helpers are used in normal models and configs.
313313
Exclude:
314-
- app/models/**/*.rb
315-
- config/**/*.rb
314+
- '**/app/models/**/*.rb'
315+
- '**/config/**/*.rb'
316316

317317
Rails/CreateTableWithTimestamps:
318318
Description: >-
@@ -373,7 +373,7 @@ Rails/Delegate:
373373
# violation. When set to false, this case is legal.
374374
EnforceForPrefixed: true
375375
Exclude:
376-
- app/controllers/**/*.rb
376+
- '**/app/controllers/**/*.rb'
377377

378378
Rails/DelegateAllowBlank:
379379
Description: 'Do not use allow_blank as an option to delegate.'
@@ -444,22 +444,22 @@ Rails/EnumHash:
444444
Enabled: true
445445
VersionAdded: '2.3'
446446
Include:
447-
- app/models/**/*.rb
447+
- '**/app/models/**/*.rb'
448448

449449
Rails/EnumSyntax:
450450
Description: 'Use positional arguments over keyword arguments when defining enums.'
451451
Enabled: pending
452452
Severity: warning
453453
VersionAdded: '2.26'
454454
Include:
455-
- app/models/**/*.rb
455+
- '**/app/models/**/*.rb'
456456

457457
Rails/EnumUniqueness:
458458
Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
459459
Enabled: true
460460
VersionAdded: '0.46'
461461
Include:
462-
- app/models/**/*.rb
462+
- '**/app/models/**/*.rb'
463463

464464
Rails/EnvLocal:
465465
Description: 'Use `Rails.env.local?` instead of `Rails.env.development? || Rails.env.test?`.'
@@ -478,11 +478,11 @@ Rails/EnvironmentVariableAccess:
478478
VersionAdded: '2.10'
479479
VersionChanged: '2.24'
480480
Include:
481-
- app/**/*.rb
482-
- config/initializers/**/*.rb
483-
- lib/**/*.rb
481+
- '**/app/**/*.rb'
482+
- '**/config/initializers/**/*.rb'
483+
- '**/lib/**/*.rb'
484484
Exclude:
485-
- lib/**/*.rake
485+
- '**/lib/**/*.rake'
486486
AllowReads: false
487487
AllowWrites: false
488488

@@ -494,11 +494,11 @@ Rails/Exit:
494494
Enabled: true
495495
VersionAdded: '0.41'
496496
Include:
497-
- app/**/*.rb
498-
- config/**/*.rb
499-
- lib/**/*.rb
497+
- '**/app/**/*.rb'
498+
- '**/config/**/*.rb'
499+
- '**/lib/**/*.rb'
500500
Exclude:
501-
- lib/**/*.rake
501+
- '**/lib/**/*.rake'
502502

503503
Rails/ExpandedDateRange:
504504
Description: 'Checks for expanded date range.'
@@ -560,22 +560,22 @@ Rails/HasAndBelongsToMany:
560560
Enabled: true
561561
VersionAdded: '0.12'
562562
Include:
563-
- app/models/**/*.rb
563+
- '**/app/models/**/*.rb'
564564

565565
Rails/HasManyOrHasOneDependent:
566566
Description: 'Define the dependent option to the has_many and has_one associations.'
567567
StyleGuide: 'https://rails.rubystyle.guide#has_many-has_one-dependent-option'
568568
Enabled: true
569569
VersionAdded: '0.50'
570570
Include:
571-
- app/models/**/*.rb
571+
- '**/app/models/**/*.rb'
572572

573573
Rails/HelperInstanceVariable:
574574
Description: 'Do not use instance variables in helpers.'
575575
Enabled: true
576576
VersionAdded: '2.0'
577577
Include:
578-
- app/helpers/**/*.rb
578+
- '**/app/helpers/**/*.rb'
579579

580580
Rails/HttpPositionalArguments:
581581
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
@@ -606,7 +606,7 @@ Rails/I18nLazyLookup:
606606
- lazy
607607
- explicit
608608
Include:
609-
- 'app/controllers/**/*.rb'
609+
- '**/app/controllers/**/*.rb'
610610

611611
Rails/I18nLocaleAssignment:
612612
Description: 'Prefer the usage of `I18n.with_locale` instead of manually updating `I18n.locale` value.'
@@ -635,8 +635,8 @@ Rails/IgnoredSkipActionFilterOption:
635635
Enabled: true
636636
VersionAdded: '0.63'
637637
Include:
638-
- app/controllers/**/*.rb
639-
- app/mailers/**/*.rb
638+
- '**/app/controllers/**/*.rb'
639+
- '**/app/mailers/**/*.rb'
640640

641641
Rails/IndexBy:
642642
Description: 'Prefer `index_by` over `each_with_object`, `to_h`, or `map`.'
@@ -665,7 +665,7 @@ Rails/InverseOf:
665665
VersionAdded: '0.52'
666666
IgnoreScopes: false
667667
Include:
668-
- app/models/**/*.rb
668+
- '**/app/models/**/*.rb'
669669

670670
Rails/LexicallyScopedActionFilter:
671671
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the class."
@@ -674,8 +674,8 @@ Rails/LexicallyScopedActionFilter:
674674
Safe: false
675675
VersionAdded: '0.52'
676676
Include:
677-
- app/controllers/**/*.rb
678-
- app/mailers/**/*.rb
677+
- '**/app/controllers/**/*.rb'
678+
- '**/app/mailers/**/*.rb'
679679

680680
Rails/LinkToBlank:
681681
Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
@@ -693,7 +693,7 @@ Rails/MailerName:
693693
SafeAutoCorrect: false
694694
VersionAdded: '2.7'
695695
Include:
696-
- app/mailers/**/*.rb
696+
- '**/app/mailers/**/*.rb'
697697

698698
Rails/MatchRoute:
699699
Description: >-
@@ -703,8 +703,8 @@ Rails/MatchRoute:
703703
Enabled: 'pending'
704704
VersionAdded: '2.7'
705705
Include:
706-
- config/routes.rb
707-
- config/routes/**/*.rb
706+
- '**/config/routes.rb'
707+
- '**/config/routes/**/*.rb'
708708

709709
Rails/MigrationClassName:
710710
Description: 'The class name of the migration should match its file name.'
@@ -720,8 +720,8 @@ Rails/MultipleRoutePaths:
720720
Severity: warning
721721
VersionAdded: '2.29'
722722
Include:
723-
- config/routes.rb
724-
- config/routes/**/*.rb
723+
- '**/config/routes.rb'
724+
- '**/config/routes/**/*.rb'
725725

726726
Rails/NegateInclude:
727727
Description: 'Prefer `collection.exclude?(obj)` over `!collection.include?(obj)`.'
@@ -757,10 +757,10 @@ Rails/Output:
757757
VersionAdded: '0.15'
758758
VersionChanged: '0.19'
759759
Include:
760-
- app/**/*.rb
761-
- config/**/*.rb
760+
- '**/app/**/*.rb'
761+
- '**/config/**/*.rb'
762762
- db/**/*.rb
763-
- lib/**/*.rb
763+
- '**/lib/**/*.rb'
764764

765765
Rails/OutputSafety:
766766
Description: 'The use of `html_safe` or `raw` may be a security risk.'
@@ -832,7 +832,7 @@ Rails/RakeEnvironment:
832832
- '**/Rakefile'
833833
- '**/*.rake'
834834
Exclude:
835-
- 'lib/capistrano/tasks/**/*.rake'
835+
- '**/lib/capistrano/tasks/**/*.rake'
836836

837837
Rails/ReadWriteAttribute:
838838
Description: >-
@@ -843,7 +843,7 @@ Rails/ReadWriteAttribute:
843843
VersionAdded: '0.20'
844844
VersionChanged: '0.29'
845845
Include:
846-
- app/models/**/*.rb
846+
- '**/app/models/**/*.rb'
847847

848848
Rails/RedundantActiveRecordAllMethod:
849849
Description: Detect redundant `all` used as a receiver for Active Record query methods.
@@ -862,7 +862,7 @@ Rails/RedundantAllowNil:
862862
Enabled: true
863863
VersionAdded: '0.67'
864864
Include:
865-
- app/models/**/*.rb
865+
- '**/app/models/**/*.rb'
866866

867867
Rails/RedundantForeignKey:
868868
Description: 'Checks for associations where the `:foreign_key` option is redundant.'
@@ -1033,7 +1033,7 @@ Rails/ScopeArgs:
10331033
VersionAdded: '0.19'
10341034
VersionChanged: '2.12'
10351035
Include:
1036-
- app/models/**/*.rb
1036+
- '**/app/models/**/*.rb'
10371037

10381038
Rails/SelectMap:
10391039
Description: 'Checks for uses of `select(:column_name)` with `map(&:column_name)`.'
@@ -1102,7 +1102,7 @@ Rails/StrongParametersExpect:
11021102
Reference: 'https://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-expect'
11031103
Enabled: pending
11041104
Include:
1105-
- app/controllers/**/*.rb
1105+
- '**/app/controllers/**/*.rb'
11061106
SafeAutoCorrect: false
11071107
VersionAdded: '2.29'
11081108

@@ -1113,7 +1113,7 @@ Rails/TableNameAssignment:
11131113
Enabled: false
11141114
VersionAdded: '2.14'
11151115
Include:
1116-
- app/models/**/*.rb
1116+
- '**/app/models/**/*.rb'
11171117

11181118
Rails/ThreeStateBooleanColumn:
11191119
Description: 'Add a default value and a `NOT NULL` constraint to boolean columns.'
@@ -1197,7 +1197,7 @@ Rails/UniqueValidationWithoutIndex:
11971197
Enabled: true
11981198
VersionAdded: '2.5'
11991199
Include:
1200-
- app/models/**/*.rb
1200+
- '**/app/models/**/*.rb'
12011201

12021202
Rails/UnknownEnv:
12031203
Description: 'Use correct environment name.'
@@ -1216,7 +1216,7 @@ Rails/UnusedIgnoredColumns:
12161216
VersionAdded: '2.11'
12171217
VersionChanged: '2.25'
12181218
Include:
1219-
- app/models/**/*.rb
1219+
- '**/app/models/**/*.rb'
12201220

12211221
Rails/UnusedRenderContent:
12221222
Description: 'Do not specify body content for a response with a non-content status code.'
@@ -1230,7 +1230,7 @@ Rails/Validation:
12301230
VersionAdded: '0.9'
12311231
VersionChanged: '0.41'
12321232
Include:
1233-
- app/models/**/*.rb
1233+
- '**/app/models/**/*.rb'
12341234

12351235
Rails/WhereEquals:
12361236
Description: 'Pass conditions to `where` and `where.not` as a hash instead of manually constructing SQL.'

spec/project_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,26 @@
151151
previous_key = key
152152
end
153153
end
154+
155+
it 'has clusivity patterns compatible with engines and packwerk', :aggregate_failures do
156+
%w[Include Exclude].each do |clusivity_key|
157+
cop_names.each do |name|
158+
next if config[name][clusivity_key].nil?
159+
160+
config[name][clusivity_key].each do |clusivity_pattern|
161+
expect(clusivity_pattern).to match(%r{\*\*/app/}), <<~ERROR if clusivity_pattern.match?(%r{\bapp/})
162+
Invalid pattern for #{name} #{clusivity_key}: #{clusivity_pattern}
163+
ERROR
164+
expect(clusivity_pattern).to match(%r{\*\*/config/}), <<~ERROR if clusivity_pattern.match?(%r{\bconfig/})
165+
Invalid pattern for #{name} #{clusivity_key}: #{clusivity_pattern}
166+
ERROR
167+
expect(clusivity_pattern).to match(%r{\*\*/lib/}), <<~ERROR if clusivity_pattern.match?(%r{\blib/})
168+
Invalid pattern for #{name} #{clusivity_key}: #{clusivity_pattern}
169+
ERROR
170+
end
171+
end
172+
end
173+
end
154174
end
155175

156176
shared_examples 'has Changelog format' do

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy