rubocop-rspec 2.29.1 → 2.31.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2976f1fdb5dd0fd25296bbe1047e74370ab9b55e19253c07bb539ea6a0e9f4af
4
- data.tar.gz: 8dd9818e414fcb26a04b0dfd434d2f13840784e159245c5c76dc0a4367b1ee96
3
+ metadata.gz: 02d59aeeb5798d5e90e8c397e253429236f3a7e179112db482611d4f08fcea3e
4
+ data.tar.gz: 2374b303560842bb66b37d7e0020fcaa00d0ec60d83cb506376f82df8af3584d
5
5
  SHA512:
6
- metadata.gz: c12a53d2803229bbee98f80fc966fb2899d563d6b82fa4bef3dfcd7b8a571a9831fdeb2c6fff121c8b994ed28aeb5785e829aba5c709ede5afba20622b8dca54
7
- data.tar.gz: 796c6ad8481aafcff4f7f1b9b0ae789dbd9df4ea54b70f166171579e5d0f15e333c8c627b9979e7c2f9fcc5d89195f84c31db4ae28922bd8207f1f8c341335d7
6
+ metadata.gz: d55127e8cb4d7370dce4b87139e6341e1838f5ddbb4f0571619b632ed61176a879c693f8366f5c6446bcc333f35059cd6382b71eac013f46b63f8d642b186d5c
7
+ data.tar.gz: 4036baa0cda4333da829fa39398434131bd74d93bd0e86cc3322919a7fe1a8d02288473dc087b0508284c3bb15f8496ab9d87e55b0cd9a9875cb513e8ebdea1e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## Master (Unreleased)
4
4
 
5
+ ## 2.31.0 (2024-06-07)
6
+
7
+ - Support `AutoCorrect: contextual` option for LSP. ([@ydah])
8
+
9
+ ## 2.30.0 (2024-06-03)
10
+
11
+ - Add new `RSpec/ExpectInLet` cop. ([@yasu551])
12
+
13
+ ## 2.29.2 (2024-05-02)
14
+
15
+ - Fix beginless and endless range bug for RepeatedIncludeExample cop. ([@hasghari])
16
+ - Fix a false positive for `RSpec/RepeatedSubjectCall` when subject is used as argument to function call. ([@K-S-A])
17
+
5
18
  ## 2.29.1 (2024-04-05)
6
19
 
7
20
  - Fix an error in the default configuration. ([@ydah])
@@ -895,6 +908,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
895
908
  [@gsamokovarov]: https://github.com/gsamokovarov
896
909
  [@harry-graham]: https://github.com/harry-graham
897
910
  [@harrylewis]: https://github.com/harrylewis
911
+ [@hasghari]: https://github.com/hasghari
898
912
  [@hosamaly]: https://github.com/hosamaly
899
913
  [@ignaciovillaverde]: https://github.com/ignaciovillaverde
900
914
  [@jaredbeck]: https://github.com/jaredbeck
@@ -907,6 +921,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
907
921
  [@jojos003]: https://github.com/jojos003
908
922
  [@jonatas]: https://github.com/jonatas
909
923
  [@jtannas]: https://github.com/jtannas
924
+ [@k-s-a]: https://github.com/K-S-A
910
925
  [@kellysutton]: https://github.com/kellysutton
911
926
  [@koic]: https://github.com/koic
912
927
  [@kuahyeow]: https://github.com/kuahyeow
@@ -969,6 +984,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
969
984
  [@twalpole]: https://github.com/twalpole
970
985
  [@vzvu3k6k]: https://github.com/vzvu3k6k
971
986
  [@walf443]: https://github.com/walf443
987
+ [@yasu551]: https://github.com/yasu551
972
988
  [@ybiquitous]: https://github.com/ybiquitous
973
989
  [@ydah]: https://github.com/ydah
974
990
  [@yevhene]: https://github.com/yevhene
data/config/default.yml CHANGED
@@ -147,7 +147,9 @@ RSpec/Be:
147
147
  RSpec/BeEmpty:
148
148
  Description: Prefer using `be_empty` when checking for an empty array.
149
149
  Enabled: pending
150
+ AutoCorrect: contextual
150
151
  VersionAdded: '2.20'
152
+ VersionChanged: '2.31'
151
153
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeEmpty
152
154
 
153
155
  RSpec/BeEq:
@@ -311,15 +313,18 @@ RSpec/DuplicatedMetadata:
311
313
  RSpec/EmptyExampleGroup:
312
314
  Description: Checks if an example group does not include any tests.
313
315
  Enabled: true
316
+ AutoCorrect: contextual
314
317
  SafeAutoCorrect: false
315
318
  VersionAdded: '1.7'
316
- VersionChanged: '2.13'
319
+ VersionChanged: '2.31'
317
320
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyExampleGroup
318
321
 
319
322
  RSpec/EmptyHook:
320
323
  Description: Checks for empty before and after hooks.
321
324
  Enabled: true
325
+ AutoCorrect: contextual
322
326
  VersionAdded: '1.39'
327
+ VersionChanged: '2.31'
323
328
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyHook
324
329
 
325
330
  RSpec/EmptyLineAfterExample:
@@ -363,7 +368,9 @@ RSpec/EmptyLineAfterSubject:
363
368
  RSpec/EmptyMetadata:
364
369
  Description: Avoid empty metadata hash.
365
370
  Enabled: pending
371
+ AutoCorrect: contextual
366
372
  VersionAdded: '2.24'
373
+ VersionChanged: '2.31'
367
374
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyMetadata
368
375
 
369
376
  RSpec/EmptyOutput:
@@ -447,6 +454,12 @@ RSpec/ExpectInHook:
447
454
  VersionAdded: '1.16'
448
455
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectInHook
449
456
 
457
+ RSpec/ExpectInLet:
458
+ Description: Do not use `expect` in let.
459
+ Enabled: pending
460
+ VersionAdded: '2.30'
461
+ Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectInLet
462
+
450
463
  RSpec/ExpectOutput:
451
464
  Description: Checks for opportunities to use `expect { ... }.to output`.
452
465
  Enabled: true
@@ -471,8 +484,9 @@ RSpec/FilePath:
471
484
  RSpec/Focus:
472
485
  Description: Checks if examples are focused.
473
486
  Enabled: true
487
+ AutoCorrect: contextual
474
488
  VersionAdded: '1.5'
475
- VersionChanged: '2.1'
489
+ VersionChanged: '2.31'
476
490
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Focus
477
491
 
478
492
  RSpec/HookArgument:
@@ -490,7 +504,9 @@ RSpec/HookArgument:
490
504
  RSpec/HooksBeforeExamples:
491
505
  Description: Checks for before/around/after hooks that come after an example.
492
506
  Enabled: true
507
+ AutoCorrect: contextual
493
508
  VersionAdded: '1.29'
509
+ VersionChanged: '2.31'
494
510
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HooksBeforeExamples
495
511
 
496
512
  RSpec/IdenticalEqualityAssertion:
@@ -596,8 +612,9 @@ RSpec/LeakyConstantDeclaration:
596
612
  RSpec/LetBeforeExamples:
597
613
  Description: Checks for `let` definitions that come after an example.
598
614
  Enabled: true
615
+ AutoCorrect: contextual
599
616
  VersionAdded: '1.16'
600
- VersionChanged: '1.22'
617
+ VersionChanged: '2.31'
601
618
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetBeforeExamples
602
619
 
603
620
  RSpec/LetSetup:
@@ -847,14 +864,17 @@ RSpec/ReturnFromStub:
847
864
  RSpec/ScatteredLet:
848
865
  Description: Checks for let scattered across the example group.
849
866
  Enabled: true
867
+ AutoCorrect: contextual
850
868
  VersionAdded: '1.14'
851
- VersionChanged: '1.39'
869
+ VersionChanged: '2.31'
852
870
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet
853
871
 
854
872
  RSpec/ScatteredSetup:
855
873
  Description: Checks for setup scattered across multiple hooks in an example group.
856
874
  Enabled: true
875
+ AutoCorrect: contextual
857
876
  VersionAdded: '1.10'
877
+ VersionChanged: '2.31'
858
878
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredSetup
859
879
 
860
880
  RSpec/SharedContext:
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module RSpec
6
+ # Do not use `expect` in let.
7
+ #
8
+ # @example
9
+ # # bad
10
+ # let(:foo) do
11
+ # expect(something).to eq 'foo'
12
+ # end
13
+ #
14
+ # # good
15
+ # it do
16
+ # expect(something).to eq 'foo'
17
+ # end
18
+ #
19
+ class ExpectInLet < Base
20
+ MSG = 'Do not use `%<expect>s` in let'
21
+
22
+ # @!method expectation(node)
23
+ def_node_search :expectation, '(send nil? #Expectations.all ...)'
24
+
25
+ def on_block(node)
26
+ return unless let?(node)
27
+ return if node.body.nil?
28
+
29
+ expectation(node.body) do |expect|
30
+ add_offense(expect.loc.selector, message: message(expect))
31
+ end
32
+ end
33
+
34
+ alias on_numblock on_block
35
+
36
+ private
37
+
38
+ def message(expect)
39
+ format(MSG, expect: expect.method_name)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -72,7 +72,7 @@ module RuboCop
72
72
  MSG = 'Example has too many expectations [%<total>d/%<max>d].'
73
73
 
74
74
  ANYTHING = ->(_node) { true }
75
- TRUE = ->(node) { node.true_type? }
75
+ TRUE = lambda(&:true_type?)
76
76
 
77
77
  # @!method aggregate_failures?(node)
78
78
  def_node_matcher :aggregate_failures?, <<~PATTERN
@@ -72,6 +72,7 @@ module RuboCop
72
72
 
73
73
  def detect_offense(subject_node)
74
74
  return if subject_node.chained?
75
+ return if subject_node.parent.send_type?
75
76
  return unless (block_node = expect_block(subject_node))
76
77
 
77
78
  add_offense(block_node)
@@ -63,6 +63,7 @@ require_relative 'rspec/excessive_docstring_spacing'
63
63
  require_relative 'rspec/expect_actual'
64
64
  require_relative 'rspec/expect_change'
65
65
  require_relative 'rspec/expect_in_hook'
66
+ require_relative 'rspec/expect_in_let'
66
67
  require_relative 'rspec/expect_output'
67
68
  require_relative 'rspec/file_path'
68
69
  require_relative 'rspec/focus'
@@ -9,7 +9,7 @@ module RuboCop
9
9
  def recursive_literal_or_const?
10
10
  case type
11
11
  when :begin, :pair, *AST::Node::COMPOSITE_LITERALS
12
- children.all?(&:recursive_literal_or_const?)
12
+ children.compact.all?(&:recursive_literal_or_const?)
13
13
  else
14
14
  literal? || const_type?
15
15
  end
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module RSpec
5
5
  # Version information for the RSpec RuboCop plugin.
6
6
  module Version
7
- STRING = '2.29.1'
7
+ STRING = '2.31.0'
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.29.1
4
+ version: 2.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Backus
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-04-04 00:00:00.000000000 Z
13
+ date: 2024-06-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -136,6 +136,7 @@ files:
136
136
  - lib/rubocop/cop/rspec/expect_actual.rb
137
137
  - lib/rubocop/cop/rspec/expect_change.rb
138
138
  - lib/rubocop/cop/rspec/expect_in_hook.rb
139
+ - lib/rubocop/cop/rspec/expect_in_let.rb
139
140
  - lib/rubocop/cop/rspec/expect_output.rb
140
141
  - lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb
141
142
  - lib/rubocop/cop/rspec/factory_bot/consistent_parentheses_style.rb
@@ -269,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
270
  - !ruby/object:Gem::Version
270
271
  version: '0'
271
272
  requirements: []
272
- rubygems_version: 3.5.3
273
+ rubygems_version: 3.5.9
273
274
  signing_key:
274
275
  specification_version: 4
275
276
  summary: Code style checking for RSpec files