sevencop 0.39.0 → 0.40.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: b16f92849b05ffb094bc39ced3a930c21cdbabc4aa95f5d0e40d2a6222969322
4
- data.tar.gz: 24f48910c8cfab40c780c1685cf4198134cbf3cfae0ef922805edea702885318
3
+ metadata.gz: 01427c343e05de1b3f41b169f44ab8e7343cbff90b7d843281f5b2a8f9ea1485
4
+ data.tar.gz: b5ba91998a6cd7f993c44205d553227e5f146c51bafe73cd0210b7a4a90dbb52
5
5
  SHA512:
6
- metadata.gz: 5384a17f52b51e66f0309da2c9041e3e65fb6c7c95a8efec3d818832a70702a9e03b6be84d80b6e8af3e0686c0189b49efbad604405fe08553677f14547955b2
7
- data.tar.gz: 5fa205dc8e7db998e2dff519cfec07efb7853dfa6b273e4022b704f55c73d20211cf0c8d755226b476415bafb88b2b092dc356c7aea348d0171a92429e69e659
6
+ metadata.gz: ff51acef6e03fcb4da1d5e53802150e055f8066270e742691920a66f42b3245d62689fe76c680930d53a1361741733132653ce1f134cc1ecbcbc9185367f92f8
7
+ data.tar.gz: 20dc6769ffeb7b03dc262aa720120d2b1f35de0c61b8617dafbdc7d54f8b25085118b3b01d97630525064befc99126be4d8224474a28d7c888a830e9ff5f3986
data/.rubocop.yml CHANGED
@@ -39,6 +39,7 @@ RSpec/FilePath:
39
39
  RSpecDescribeHttpEndpoint: rspec_describe_http_endpoint
40
40
  RSpecEmptyLineAfterLet: rspec_empty_line_after_let
41
41
  RSpecExamplesInSameGroup: rspec_examples_in_same_group
42
+ RSpecMatcherConsistentParentheses: rspec_matcher_consistent_parentheses
42
43
  RSpecMemoizedHelperBlockDelimiter: rspec_memoized_helper_block_delimiter
43
44
  RSpecRailsHaveHttpStatus: rspec_rails_have_http_status
44
45
 
@@ -50,6 +51,7 @@ RSpec/SpecFilePathFormat:
50
51
  RSpecDescribeHttpEndpoint: rspec_describe_http_endpoint
51
52
  RSpecEmptyLineAfterLet: rspec_empty_line_after_let
52
53
  RSpecExamplesInSameGroup: rspec_examples_in_same_group
54
+ RSpecMatcherConsistentParentheses: rspec_matcher_consistent_parentheses
53
55
  RSpecMemoizedHelperBlockDelimiter: rspec_memoized_helper_block_delimiter
54
56
  RSpecRailsHaveHttpStatus: rspec_rails_have_http_status
55
57
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sevencop (0.39.0)
4
+ sevencop (0.40.0)
5
5
  activesupport
6
6
  rubocop
7
7
 
@@ -20,12 +20,12 @@ GEM
20
20
  tzinfo (~> 2.0)
21
21
  ast (2.4.2)
22
22
  base64 (0.2.0)
23
- bigdecimal (3.1.7)
23
+ bigdecimal (3.1.8)
24
24
  concurrent-ruby (1.2.3)
25
25
  connection_pool (2.4.1)
26
26
  diff-lcs (1.5.0)
27
27
  drb (2.2.1)
28
- i18n (1.14.4)
28
+ i18n (1.14.5)
29
29
  concurrent-ruby (~> 1.0)
30
30
  json (2.7.1)
31
31
  language_server-protocol (3.17.0.3)
data/README.md CHANGED
@@ -47,6 +47,7 @@ Note that all cops are `Enabled: false` by default.
47
47
  - [Sevencop/RSpecDescribeHttpEndpoint](lib/rubocop/cop/sevencop/rspec_describe_http_endpoint.rb)
48
48
  - [Sevencop/RSpecEmptyLineAfterLet](lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb)
49
49
  - [Sevencop/RSpecExamplesInSameGroup](lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb)
50
+ - [Sevencop/RSpecMatcherConsistentParentheses](lib/rubocop/cop/sevencop/rspec_matcher_consistent_parentheses.rb)
50
51
  - [Sevencop/RSpecMemoizedHelperBlockDelimiter](lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb)
51
52
  - [Sevencop/RSpecRailsHaveHttpStatus](lib/rubocop/cop/sevencop/rspec_rails_have_http_status.rb)
52
53
 
data/config/default.yml CHANGED
@@ -137,6 +137,13 @@ Sevencop/RSpecExamplesInSameGroup:
137
137
  - "**/spec/controllers/**/*.rb"
138
138
  - "**/spec/requests/**/*.rb"
139
139
 
140
+ Sevencop/RSpecMatcherConsistentParentheses:
141
+ Description: |
142
+ Keep RSpec matcher parentheses style consistent.
143
+ Enabled: false
144
+ Include:
145
+ - "**/spec/**/*.rb"
146
+
140
147
  Sevencop/RSpecMemoizedHelperBlockDelimiter:
141
148
  Description: |
142
149
  Use do-end block delimiter on RSpec memoized helper.
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Sevencop
6
+ # Keep RSpec matcher parentheses style consistent.
7
+ #
8
+ # @example
9
+ # # bad
10
+ # is_expected.to eq 1
11
+ #
12
+ # # good
13
+ # is_expected.to eq(1)
14
+ class RSpecMatcherConsistentParentheses < Base
15
+ extend AutoCorrector
16
+
17
+ MSG = 'Keep matcher parentheses style consistent.'
18
+
19
+ RESTRICT_ON_SEND = %i[to].freeze
20
+
21
+ # @param [RuboCop::AST::SendNode] node
22
+ # @return [void]
23
+ def on_send(node)
24
+ return unless to?(node)
25
+
26
+ first_argument = node.first_argument
27
+ return unless inconsistent?(first_argument)
28
+
29
+ add_offense(first_argument) do |corrector|
30
+ add_parentheses(first_argument, corrector)
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ # @!method expectation?(node)
37
+ # @param [RuboCop::AST::SendNode] node
38
+ # @return [Boolean]
39
+ def_node_matcher :expectation?, <<~PATTERN
40
+ (send nil? { :is_expected :expect } ...)
41
+ PATTERN
42
+
43
+ # @param [RuboCop::AST::Node, nil] node
44
+ # @return [Boolean]
45
+ def inconsistent?(node)
46
+ node.send_type? && missing_parentheses?(node)
47
+ end
48
+
49
+ # @param [RuboCop::AST::SendNode] node
50
+ # @return [Boolean]
51
+ def missing_parentheses?(node)
52
+ !node.arguments.empty? &&
53
+ !node.operator_method? &&
54
+ !node.parenthesized?
55
+ end
56
+
57
+ # @param [RuboCop::AST::SendNode] node
58
+ # @return [Boolean]
59
+ def to?(node)
60
+ expectation?(node.receiver)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sevencop
4
- VERSION = '0.39.0'
4
+ VERSION = '0.40.0'
5
5
  end
data/lib/sevencop.rb CHANGED
@@ -23,5 +23,6 @@ require_relative 'rubocop/cop/sevencop/rails_where_not'
23
23
  require_relative 'rubocop/cop/sevencop/rspec_describe_http_endpoint'
24
24
  require_relative 'rubocop/cop/sevencop/rspec_empty_line_after_let'
25
25
  require_relative 'rubocop/cop/sevencop/rspec_examples_in_same_group'
26
+ require_relative 'rubocop/cop/sevencop/rspec_matcher_consistent_parentheses'
26
27
  require_relative 'rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter'
27
28
  require_relative 'rubocop/cop/sevencop/rspec_rails_have_http_status'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sevencop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.39.0
4
+ version: 0.40.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-24 00:00:00.000000000 Z
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -75,6 +75,7 @@ files:
75
75
  - lib/rubocop/cop/sevencop/rspec_describe_http_endpoint.rb
76
76
  - lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb
77
77
  - lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb
78
+ - lib/rubocop/cop/sevencop/rspec_matcher_consistent_parentheses.rb
78
79
  - lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb
79
80
  - lib/rubocop/cop/sevencop/rspec_rails_have_http_status.rb
80
81
  - lib/sevencop.rb