sevencop 0.29.1 → 0.30.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/Gemfile.lock +1 -1
- data/README.md +0 -1
- data/config/default.yml +0 -7
- data/lib/sevencop/version.rb +1 -1
- data/lib/sevencop.rb +0 -1
- metadata +2 -3
- data/lib/rubocop/cop/sevencop/rails_inferred_spec_type.rb +0 -125
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 04df97299a228e2e8e8204799cb0b3d0c643a79c97ed4ec45f76f01b227e7e58
|
|
4
|
+
data.tar.gz: 9515ca6115c293425384b9b25ab4b7e554e54b2bbef00407b3aa194d69bb8be5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e3ba17d74c6144d551fccab790249ccc242731f213b04016d0aabb4774281ae205c6807fee8527f4388bc2f29352a19925796393432392b81aa19d8940d0b63
|
|
7
|
+
data.tar.gz: 6aaacdd215db0d477d1470eac9622d09c968fbba8d1eae8de96ef68baeea9a806bdd17bd9b7c8dff55814221cb282e0413aaa09ff4d51c542c3d5aa01f42d206
|
data/Gemfile.lock
CHANGED
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`.
|
data/lib/sevencop/version.rb
CHANGED
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.
|
|
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-
|
|
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
|