sevencop 0.29.0 → 0.30.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: d415f24d882b17eb832c22fa9a17d40ebf1ea91fda15e5a25e8e5ceea6824633
4
- data.tar.gz: b770d04a2620d1ef6e5f7a0e0b0cd1e6f440b44a5173bd8c26890f0707a4e9b5
3
+ metadata.gz: 04df97299a228e2e8e8204799cb0b3d0c643a79c97ed4ec45f76f01b227e7e58
4
+ data.tar.gz: 9515ca6115c293425384b9b25ab4b7e554e54b2bbef00407b3aa194d69bb8be5
5
5
  SHA512:
6
- metadata.gz: ddd45cdafff3edc2512a962f32d817cd5836f5435547d987c76f96a0d3a873f8398506dc567caea00ed165f7bd206378bcdbea71eec0516fe05ce7249a2b88e9
7
- data.tar.gz: 737bd07f00679aa77fce2209f9692b5babff560362a03c412f228584f74d4cd213bbfc5a1223ed999e3ba66abb3f6f7cd7cfcd1d702ee4fed7f8f80d4940e0a3
6
+ metadata.gz: 8e3ba17d74c6144d551fccab790249ccc242731f213b04016d0aabb4774281ae205c6807fee8527f4388bc2f29352a19925796393432392b81aa19d8940d0b63
7
+ data.tar.gz: 6aaacdd215db0d477d1470eac9622d09c968fbba8d1eae8de96ef68baeea9a806bdd17bd9b7c8dff55814221cb282e0413aaa09ff4d51c542c3d5aa01f42d206
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sevencop (0.29.0)
4
+ sevencop (0.30.0)
5
5
  activesupport
6
6
  rubocop
7
7
 
@@ -25,39 +25,39 @@ GEM
25
25
  ast (~> 2.4.1)
26
26
  rainbow (3.1.1)
27
27
  rake (13.0.6)
28
- regexp_parser (2.5.0)
28
+ regexp_parser (2.6.0)
29
29
  rexml (3.2.5)
30
- rspec (3.11.0)
31
- rspec-core (~> 3.11.0)
32
- rspec-expectations (~> 3.11.0)
33
- rspec-mocks (~> 3.11.0)
34
- rspec-core (3.11.0)
35
- rspec-support (~> 3.11.0)
36
- rspec-expectations (3.11.1)
30
+ rspec (3.12.0)
31
+ rspec-core (~> 3.12.0)
32
+ rspec-expectations (~> 3.12.0)
33
+ rspec-mocks (~> 3.12.0)
34
+ rspec-core (3.12.0)
35
+ rspec-support (~> 3.12.0)
36
+ rspec-expectations (3.12.0)
37
37
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.11.0)
39
- rspec-mocks (3.11.1)
38
+ rspec-support (~> 3.12.0)
39
+ rspec-mocks (3.12.0)
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.11.0)
42
- rspec-support (3.11.1)
43
- rubocop (1.36.0)
41
+ rspec-support (~> 3.12.0)
42
+ rspec-support (3.12.0)
43
+ rubocop (1.38.0)
44
44
  json (~> 2.3)
45
45
  parallel (~> 1.10)
46
46
  parser (>= 3.1.2.1)
47
47
  rainbow (>= 2.2.2, < 4.0)
48
48
  regexp_parser (>= 1.8, < 3.0)
49
49
  rexml (>= 3.2.5, < 4.0)
50
- rubocop-ast (>= 1.20.1, < 2.0)
50
+ rubocop-ast (>= 1.23.0, < 2.0)
51
51
  ruby-progressbar (~> 1.7)
52
52
  unicode-display_width (>= 1.4.0, < 3.0)
53
- rubocop-ast (1.21.0)
53
+ rubocop-ast (1.23.0)
54
54
  parser (>= 3.1.1.0)
55
55
  rubocop-performance (1.15.0)
56
56
  rubocop (>= 1.7.0, < 2.0)
57
57
  rubocop-ast (>= 0.4.0)
58
58
  rubocop-rake (0.6.0)
59
59
  rubocop (~> 1.0)
60
- rubocop-rspec (2.13.1)
60
+ rubocop-rspec (2.15.0)
61
61
  rubocop (~> 1.33)
62
62
  ruby-progressbar (1.11.0)
63
63
  tzinfo (2.0.5)
data/README.md CHANGED
@@ -38,7 +38,6 @@ Note that all cops are `Enabled: false` by default.
38
38
  - [Sevencop/MethodDefinitionOrdered](lib/rubocop/cop/sevencop/method_definition_ordered.rb)
39
39
  - [Sevencop/RailsBelongsToOptional](lib/rubocop/cop/sevencop/rails_belongs_to_optional.rb)
40
40
  - [Sevencop/RailsDateAndTimeCalculation](lib/rubocop/cop/sevencop/rails_date_and_time_calculation.rb)
41
- - [Sevencop/RailsInferredSpecType](lib/rubocop/cop/sevencop/rails_inferred_spec_type.rb)
42
41
  - [Sevencop/RailsOrderField](lib/rubocop/cop/sevencop/rails_order_field.rb)
43
42
  - [Sevencop/RailsSpecificActionName](lib/rubocop/cop/sevencop/rails_specific_action_name.rb)
44
43
  - [Sevencop/RailsUniquenessValidatorExplicitCaseSensitivity](lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb)
data/config/default.yml CHANGED
@@ -82,13 +82,6 @@ Sevencop/RailsDateAndTimeCalculation:
82
82
  Safe: false
83
83
  VersionAdded: '0.26'
84
84
 
85
- Sevencop/RailsInferredSpecType:
86
- Description: |
87
- Identifies redundant spec type.
88
- Enabled: false
89
- Safe: false
90
- VersionAdded: '0.9'
91
-
92
85
  Sevencop/RailsOrderField:
93
86
  Description: |
94
87
  Wrap safe SQL String by `Arel.sql`.
@@ -148,6 +148,7 @@ module RuboCop
148
148
  block = node.parent
149
149
  return [] unless block
150
150
  return [] unless block.block_type?
151
+ return [] unless block.body
151
152
 
152
153
  if block.body.begin_type?
153
154
  block.body.children
@@ -37,8 +37,8 @@ module RuboCop
37
37
  (send
38
38
  _ _
39
39
  {
40
- (str /field\(.+\)/i) |
41
- (dstr <(str /field\(.+\)/i) ...>)
40
+ (str /field(.+)/i) |
41
+ (dstr <(str /field(.+)/i) ...>)
42
42
  }
43
43
  ...
44
44
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sevencop
4
- VERSION = '0.29.0'
4
+ VERSION = '0.30.0'
5
5
  end
data/lib/sevencop.rb CHANGED
@@ -14,7 +14,6 @@ require_relative 'rubocop/cop/sevencop/method_definition_keyword_argument_ordere
14
14
  require_relative 'rubocop/cop/sevencop/method_definition_ordered'
15
15
  require_relative 'rubocop/cop/sevencop/rails_belongs_to_optional'
16
16
  require_relative 'rubocop/cop/sevencop/rails_date_and_time_calculation'
17
- require_relative 'rubocop/cop/sevencop/rails_inferred_spec_type'
18
17
  require_relative 'rubocop/cop/sevencop/rails_order_field'
19
18
  require_relative 'rubocop/cop/sevencop/rails_specific_action_name'
20
19
  require_relative 'rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity'
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.29.0
4
+ version: 0.30.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: 2022-11-09 00:00:00.000000000 Z
11
+ date: 2022-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -66,7 +66,6 @@ files:
66
66
  - lib/rubocop/cop/sevencop/method_definition_ordered.rb
67
67
  - lib/rubocop/cop/sevencop/rails_belongs_to_optional.rb
68
68
  - lib/rubocop/cop/sevencop/rails_date_and_time_calculation.rb
69
- - lib/rubocop/cop/sevencop/rails_inferred_spec_type.rb
70
69
  - lib/rubocop/cop/sevencop/rails_order_field.rb
71
70
  - lib/rubocop/cop/sevencop/rails_specific_action_name.rb
72
71
  - lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module Sevencop
6
- # Identifies redundant spec type.
7
- # This is automatically set by `config.infer_spec_type_from_file_location!`.
8
- #
9
- # @example
10
- #
11
- # # bad
12
- # # spec/models/user_spec.rb
13
- # RSpec.describe User, type: :model
14
- #
15
- # # good
16
- # # spec/models/user_spec.rb
17
- # RSpec.describe User
18
- #
19
- # # good
20
- # # spec/models/user_spec.rb
21
- # RSpec.describe User, type: :request
22
- #
23
- class RailsInferredSpecType < Base
24
- extend AutoCorrector
25
-
26
- # @return [Array<Hash>]
27
- INFERENCES = [
28
- { prefix: 'spec/channels/', type: :channel },
29
- { prefix: 'spec/controllers/', type: :controller },
30
- { prefix: 'spec/features/', type: :feature },
31
- { prefix: 'spec/generator/', type: :generator },
32
- { prefix: 'spec/helpers/', type: :helper },
33
- { prefix: 'spec/jobs/', type: :job },
34
- { prefix: 'spec/mailboxes/', type: :mailbox },
35
- { prefix: 'spec/mailers/', type: :mailer },
36
- { prefix: 'spec/models/', type: :model },
37
- { prefix: 'spec/requests/', type: :request },
38
- { prefix: 'spec/integration/', type: :request },
39
- { prefix: 'spec/api/', type: :request },
40
- { prefix: 'spec/routing/', type: :routing },
41
- { prefix: 'spec/system/', type: :system },
42
- { prefix: 'spec/views/', type: :view }
43
- ].freeze
44
-
45
- MSG = 'Remove redundant spec type.'
46
-
47
- RESTRICT_ON_SEND = %i[
48
- describe
49
- ].freeze
50
-
51
- # @param [RuboCop::AST::SendNode] node
52
- def on_send(node)
53
- pair_node = describe_with_type(node)
54
- return unless pair_node
55
- return unless inferred_type?(pair_node)
56
-
57
- removable_node = detect_removable_node(pair_node)
58
- add_offense(removable_node) do |corrector|
59
- autocorrect(corrector, removable_node)
60
- end
61
- end
62
-
63
- private
64
-
65
- # @!method describe_with_type(node)
66
- # @param [RuboCop::AST::SendNode] node
67
- # @return [RuboCop::AST::PairNode, nil]
68
- def_node_matcher :describe_with_type, <<~PATTERN
69
- (send
70
- { (const nil? :RSpec) | nil? }
71
- _
72
- _
73
- _*
74
- (hash
75
- (pair ...)*
76
- $(pair (sym :type) sym)
77
- (pair ...)*
78
- )
79
- )
80
- PATTERN
81
-
82
- # @param [RuboCop::AST::Corrector] corrector
83
- # @param [RuboCop::AST::Node] node
84
- def autocorrect(
85
- corrector,
86
- node
87
- )
88
- corrector.remove(
89
- node.location.expression.with(
90
- begin_pos: node.left_sibling.location.expression.end_pos
91
- )
92
- )
93
- end
94
-
95
- # @param [RuboCop::AST::PairNode] node
96
- # @return [RuboCop::AST::Node]
97
- def detect_removable_node(node)
98
- if node.parent.pairs.size == 1
99
- node.parent
100
- else
101
- node
102
- end
103
- end
104
-
105
- # @return [String]
106
- def file_path
107
- processed_source.file_path
108
- end
109
-
110
- # @param [RuboCop::AST::PairNode] node
111
- # @return [Boolean]
112
- def inferred_type?(node)
113
- inferred_type_from_file_path.inspect == node.value.source
114
- end
115
-
116
- # @return [Symbol, nil]
117
- def inferred_type_from_file_path
118
- INFERENCES.find do |inference|
119
- break inference[:type] if file_path.include?(inference[:prefix])
120
- end
121
- end
122
- end
123
- end
124
- end
125
- end