rubocop-nueca 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/default.yml +6 -2
- data/lib/rubocop/cop/rails/model_association_sorting.rb +4 -5
- data/lib/rubocop/nueca/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec8137f1dc94ea82c488b598bef4742c1274123b950f1b31d407c05f9a62a657
|
|
4
|
+
data.tar.gz: 6e63b2765a397fdd83d6cc275bd5b54a6ae9e728e7482df01ae0502dc1b0efdb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad1cc7f722ca78c9611e34a749b16389d2385f95f9819314655f9a7d683f045d5a8606a0a4e01d8db8131b24d88c2658f59f92d15c30f4fd67d2e9fea348765f
|
|
7
|
+
data.tar.gz: 8c84dd737a4d078510f196274065192b55262470e9299ee4d3131991c9058e57fcd04dd418f1332c49bd73232ca0d7132e80eb37c72ea2c92d104093d5a7ff1e
|
data/config/default.yml
CHANGED
|
@@ -30,14 +30,14 @@ Metrics/ClassLength:
|
|
|
30
30
|
CountComments: false
|
|
31
31
|
CountAsOne: [array, hash, heredoc, method_call]
|
|
32
32
|
Exclude:
|
|
33
|
-
- 'db
|
|
33
|
+
- 'db/*migrate/**/*'
|
|
34
34
|
|
|
35
35
|
Metrics/MethodLength:
|
|
36
36
|
Max: 20
|
|
37
37
|
CountComments: false
|
|
38
38
|
CountAsOne: [array, hash, heredoc, method_call]
|
|
39
39
|
Exclude:
|
|
40
|
-
- 'db
|
|
40
|
+
- 'db/*migrate/**/*'
|
|
41
41
|
|
|
42
42
|
Metrics/ModuleLength:
|
|
43
43
|
CountComments: false
|
|
@@ -191,3 +191,7 @@ Style/TopLevelMethodDefinition:
|
|
|
191
191
|
Style/TrailingCommaInBlockArgs:
|
|
192
192
|
Enabled: true
|
|
193
193
|
EnforcedStyleForMultiline: no_comma
|
|
194
|
+
|
|
195
|
+
RSpec/ExpectInHook:
|
|
196
|
+
Exclude:
|
|
197
|
+
- 'spec/features/**/*_spec.rb'
|
|
@@ -93,8 +93,7 @@ module RuboCop
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def check_group_sorting(group_associations)
|
|
96
|
-
through_associations = group_associations.
|
|
97
|
-
regular_associations = group_associations.reject { |assoc| assoc[:through] }
|
|
96
|
+
through_associations, regular_associations = group_associations.partition { |assoc| assoc[:through] }
|
|
98
97
|
|
|
99
98
|
regular_sorted = regular_associations.sort_by { |assoc| assoc[:name] }
|
|
100
99
|
|
|
@@ -118,11 +117,11 @@ module RuboCop
|
|
|
118
117
|
end
|
|
119
118
|
|
|
120
119
|
def build_association_lookup(associations)
|
|
121
|
-
associations.
|
|
120
|
+
associations.to_h { |assoc| [assoc[:name], assoc] } # rubocop:disable Rails/IndexBy
|
|
122
121
|
end
|
|
123
122
|
|
|
124
123
|
def build_dependency_graph(associations, lookup)
|
|
125
|
-
graph = associations.
|
|
124
|
+
graph = associations.to_h { |assoc| [assoc[:name], []] }
|
|
126
125
|
|
|
127
126
|
associations.each do |assoc|
|
|
128
127
|
graph[assoc[:through]] << assoc[:name] if assoc[:through] && lookup[assoc[:through]]
|
|
@@ -147,7 +146,7 @@ module RuboCop
|
|
|
147
146
|
end
|
|
148
147
|
|
|
149
148
|
def calculate_in_degrees(dependency_graph, all_nodes)
|
|
150
|
-
in_degrees = all_nodes.
|
|
149
|
+
in_degrees = all_nodes.to_h { |node| [node, 0] }
|
|
151
150
|
|
|
152
151
|
dependency_graph.each_value do |dependents|
|
|
153
152
|
dependents.each { |dependent| in_degrees[dependent] += 1 }
|