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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bb85fc163eb8e9fc141bb81dbd7d7c2d0327ec605c4aa4dcc41a1bd4bf0e841
4
- data.tar.gz: 45987a7e1a5dc366a0c16ab841a863cc2f7866a9a8cba77e58b2a0924aaddcc1
3
+ metadata.gz: 9a5c117626f22cbe451b7044b247be8b9be8aecaa460f64ea87eb948d54cb6f5
4
+ data.tar.gz: eff63053af204522a4c23f814c4be844ffb985daf357751a7b411ad35b2051ec
5
5
  SHA512:
6
- metadata.gz: b8ebe6d629b4f2e22a081b095abe1e2e1dc34c032e4be26b9338385e7d37c7097fe85dad3ebb03e1706594becaa680b27b1119fd6e9ab661a96aaa61a9c4cbf3
7
- data.tar.gz: b6d6fede91a931b79919d1ae081b848787de025edd2651205d83d3de641e66fe71c417c082cc79307f4661b7065105694facbf3fe0bbfbd6eeb9ba06808f03be
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?(node)
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
- DEFAULT_NON_IMPLICIT_ASSOCIATION_METHOD_NAMES +
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 = node.ancestors.reverse.find do |ancestor|
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
@@ -81,7 +81,7 @@ module RuboCop
81
81
  #factory_call? %FACTORY_CALLS
82
82
  {sym str send lvar} _*
83
83
  (hash
84
- <value_omission? ...>
84
+ <[!kwsplat value_omission?] ...>
85
85
  )
86
86
  )
87
87
  PATTERN
@@ -99,19 +99,9 @@ module RuboCop
99
99
  end
100
100
 
101
101
  def inside_example_group?(node)
102
- return spec_group?(node) if example_group_root?(node)
103
-
104
- root = node.ancestors.find { |parent| example_group_root?(parent) }
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
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module FactoryBot
5
5
  # Version information for the factory_bot RuboCop plugin.
6
6
  module Version
7
- STRING = '2.27.0'
7
+ STRING = '2.28.0'
8
8
  end
9
9
  end
10
10
  end
@@ -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.27.0
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: 2025-03-06 00:00:00.000000000 Z
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.2
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: []