rubocop-factory_bot 2.27.0 → 2.28.0
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/CHANGELOG.md +13 -0
- data/lib/rubocop/cop/factory_bot/association_style.rb +10 -14
- data/lib/rubocop/cop/factory_bot/consistent_parentheses_style.rb +1 -1
- data/lib/rubocop/cop/factory_bot/syntax_methods.rb +3 -13
- data/lib/rubocop/factory_bot/version.rb +1 -1
- data/lib/rubocop-factory_bot.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a5c117626f22cbe451b7044b247be8b9be8aecaa460f64ea87eb948d54cb6f5
|
|
4
|
+
data.tar.gz: eff63053af204522a4c23f814c4be844ffb985daf357751a7b411ad35b2051ec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef628bbb79001d540c0f21ff8d978b05bf37d3a7f9942f4a75d6348589d4c9349b5ce86406123cbc2e4c2aaa276aad488dc31c4f2058ed3d3c7f1be24604bdbb
|
|
7
|
+
data.tar.gz: 57f5195ad3056db88fe3f5c76f2085b16db8c3ba65bc27357042e22be9c7d421621fc6fefcb5be3be6380e9e70e3401230e0218e1199c567989b1cf6af8426d6
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Master (Unreleased)
|
|
4
4
|
|
|
5
|
+
## 2.28.0 (2025-11-12)
|
|
6
|
+
|
|
7
|
+
- Fix an error for `FactoryBot/AssociationStyle` cop when `trait` is not inside `factory` block. ([@viralpraxis])
|
|
8
|
+
- Fix an error for `FactoryBot/ConsistentParenthesesStyle` cop when using keyword splat argument. ([@viralpraxis])
|
|
9
|
+
- Fix a false negative for `FactoryBot/SyntaxMethods` when method is used inside a module. ([@lovro-bikic])
|
|
10
|
+
|
|
11
|
+
## 2.27.1 (2025-03-12)
|
|
12
|
+
|
|
13
|
+
- Fix incorrect plugin version. ([@koic])
|
|
14
|
+
|
|
5
15
|
## 2.27.0 (2025-03-06)
|
|
6
16
|
|
|
7
17
|
- Fix a false positive for `FactoryBot/ConsistentParenthesesStyle` when using traits and omitting hash values. ([@thejonroberts])
|
|
@@ -105,8 +115,10 @@
|
|
|
105
115
|
[@jaydorsey]: https://github.com/jaydorsey
|
|
106
116
|
[@jfragoulis]: https://github.com/jfragoulis
|
|
107
117
|
[@jonatas]: https://github.com/jonatas
|
|
118
|
+
[@koic]: https://github.com/koic
|
|
108
119
|
[@leoarnold]: https://github.com/leoarnold
|
|
109
120
|
[@liberatys]: https://github.com/Liberatys
|
|
121
|
+
[@lovro-bikic]: https://github.com/lovro-bikic
|
|
110
122
|
[@morissetcl]: https://github.com/morissetcl
|
|
111
123
|
[@ngouy]: https://github.com/ngouy
|
|
112
124
|
[@owst]: https://github.com/owst
|
|
@@ -116,6 +128,7 @@
|
|
|
116
128
|
[@tdeo]: https://github.com/tdeo
|
|
117
129
|
[@tejasbubane]: https://github.com/tejasbubane
|
|
118
130
|
[@thejonroberts]: https://github.com/thejonroberts
|
|
131
|
+
[@viralpraxis]: https://github.com/viralpraxis
|
|
119
132
|
[@vzvu3k6k]: https://github.com/vzvu3k6k
|
|
120
133
|
[@walf443]: https://github.com/walf443
|
|
121
134
|
[@ybiquitous]: https://github.com/ybiquitous
|
|
@@ -65,14 +65,6 @@ module RuboCop
|
|
|
65
65
|
|
|
66
66
|
include ConfigurableEnforcedStyle
|
|
67
67
|
|
|
68
|
-
DEFAULT_NON_IMPLICIT_ASSOCIATION_METHOD_NAMES = %w[
|
|
69
|
-
association
|
|
70
|
-
factory
|
|
71
|
-
sequence
|
|
72
|
-
skip_create
|
|
73
|
-
traits_for_enum
|
|
74
|
-
].freeze
|
|
75
|
-
|
|
76
68
|
RESTRICT_ON_SEND = %i[factory trait].freeze
|
|
77
69
|
KEYWORDS = %i[alias and begin break case class def defined? do
|
|
78
70
|
else elsif end ensure false for if in module
|
|
@@ -175,7 +167,9 @@ module RuboCop
|
|
|
175
167
|
def bad?(node)
|
|
176
168
|
if style == :explicit
|
|
177
169
|
implicit_association?(node) &&
|
|
178
|
-
!trait_within_trait?(
|
|
170
|
+
(factory_node = trait_factory_node(node)) && !trait_within_trait?(
|
|
171
|
+
node, factory_node
|
|
172
|
+
)
|
|
179
173
|
else
|
|
180
174
|
explicit_association?(node) &&
|
|
181
175
|
!with_strategy_build_option?(node) &&
|
|
@@ -226,7 +220,7 @@ module RuboCop
|
|
|
226
220
|
end
|
|
227
221
|
|
|
228
222
|
def non_implicit_association_method_names
|
|
229
|
-
|
|
223
|
+
RuboCop::FactoryBot.reserved_methods.map(&:to_s) +
|
|
230
224
|
(cop_config['NonImplicitAssociationMethodNames'] || [])
|
|
231
225
|
end
|
|
232
226
|
|
|
@@ -247,12 +241,14 @@ module RuboCop
|
|
|
247
241
|
options
|
|
248
242
|
end
|
|
249
243
|
|
|
250
|
-
def trait_within_trait?(node)
|
|
251
|
-
factory_node
|
|
244
|
+
def trait_within_trait?(node, factory_node)
|
|
245
|
+
trait_name(factory_node).include?(node.method_name)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def trait_factory_node(node)
|
|
249
|
+
node.ancestors.reverse.find do |ancestor|
|
|
252
250
|
ancestor.method?(:factory) if ancestor.block_type?
|
|
253
251
|
end
|
|
254
|
-
|
|
255
|
-
trait_name(factory_node).include?(node.method_name)
|
|
256
252
|
end
|
|
257
253
|
end
|
|
258
254
|
end
|
|
@@ -99,19 +99,9 @@ module RuboCop
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
def inside_example_group?(node)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
spec_group?(root)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def example_group_root?(node)
|
|
110
|
-
node.parent.nil? || example_group_root_with_siblings?(node.parent)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def example_group_root_with_siblings?(node)
|
|
114
|
-
node.begin_type? && node.parent.nil?
|
|
102
|
+
spec_group?(node) || node.each_ancestor.any? do |parent|
|
|
103
|
+
spec_group?(parent)
|
|
104
|
+
end
|
|
115
105
|
end
|
|
116
106
|
end
|
|
117
107
|
end
|
data/lib/rubocop-factory_bot.rb
CHANGED
|
@@ -8,6 +8,7 @@ require 'rubocop'
|
|
|
8
8
|
require_relative 'rubocop/factory_bot/factory_bot'
|
|
9
9
|
require_relative 'rubocop/factory_bot/language'
|
|
10
10
|
require_relative 'rubocop/factory_bot/plugin'
|
|
11
|
+
require_relative 'rubocop/factory_bot/version'
|
|
11
12
|
|
|
12
13
|
require_relative 'rubocop/cop/factory_bot/mixin/configurable_explicit_only'
|
|
13
14
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-factory_bot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.28.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Backus
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
- Andrew Bromwich
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date:
|
|
14
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: lint_roller
|
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
104
104
|
- !ruby/object:Gem::Version
|
|
105
105
|
version: '0'
|
|
106
106
|
requirements: []
|
|
107
|
-
rubygems_version: 3.6.
|
|
107
|
+
rubygems_version: 3.6.9
|
|
108
108
|
specification_version: 4
|
|
109
109
|
summary: Code style checking for factory_bot files
|
|
110
110
|
test_files: []
|