sevencop 0.34.0 → 0.35.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -3
- data/Gemfile.lock +18 -15
- data/README.md +0 -2
- data/config/default.yml +0 -11
- data/lib/rubocop/cop/sevencop/autoload_ordered.rb +2 -2
- data/lib/rubocop/cop/sevencop/factory_bot_association_option.rb +1 -1
- data/lib/rubocop/cop/sevencop/hash_element_ordered.rb +3 -3
- data/lib/rubocop/cop/sevencop/method_definition_arguments_multiline.rb +3 -3
- data/lib/rubocop/cop/sevencop/method_definition_in_included.rb +1 -3
- data/lib/rubocop/cop/sevencop/method_definition_keyword_argument_ordered.rb +2 -2
- data/lib/rubocop/cop/sevencop/rails_date_and_time_calculation.rb +1 -1
- data/lib/rubocop/cop/sevencop/rails_order_field_in_order_of.rb +1 -1
- data/lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb +2 -2
- data/lib/rubocop/cop/sevencop/rails_where_not.rb +4 -4
- data/lib/sevencop/cop_concerns/ordered.rb +1 -3
- data/lib/sevencop/version.rb +1 -1
- data/lib/sevencop.rb +0 -2
- metadata +1 -3
- data/lib/rubocop/cop/sevencop/constant_base.rb +0 -79
- data/lib/rubocop/cop/sevencop/require_ordered.rb +0 -94
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2931983d77f0150cab0d7dc492a651fb89ddf689138898445b92b8d355d58d09
|
4
|
+
data.tar.gz: f2b9309bb927cae02589660e9fa9d1d25713bd91b34937e721b80d505c0a819c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fd6884d56779944c0caf4c2fee1f860494629b5f34eb344bac567de7a02e268ca8e8cf13064df2c42288698a8c2b8f296540c6e3a9d4b8fdab2def647c410d9
|
7
|
+
data.tar.gz: 1dd9b63de192c1291ceafc4b72e12fae92274c4de86076d5756fda6046f3816811cd245c7a1f5fdce555b707c5fb63bb307a9d74e3e2f9fc37bcf2aafdd8271e
|
data/.rubocop.yml
CHANGED
@@ -58,11 +58,11 @@ Sevencop/MethodDefinitionKeywordArgumentOrdered:
|
|
58
58
|
Sevencop/MethodDefinitionOrdered:
|
59
59
|
Enabled: true
|
60
60
|
|
61
|
-
Sevencop/RequireOrdered:
|
62
|
-
Enabled: true
|
63
|
-
|
64
61
|
Style/Documentation:
|
65
62
|
Enabled: false
|
66
63
|
|
67
64
|
Style/MultilineBlockChain:
|
68
65
|
Enabled: false
|
66
|
+
|
67
|
+
Style/RequireOrder:
|
68
|
+
Enabled: true
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sevencop (0.
|
4
|
+
sevencop (0.35.0)
|
5
5
|
activesupport
|
6
6
|
rubocop
|
7
7
|
|
@@ -20,49 +20,52 @@ GEM
|
|
20
20
|
concurrent-ruby (~> 1.0)
|
21
21
|
json (2.6.3)
|
22
22
|
minitest (5.18.0)
|
23
|
-
parallel (1.
|
24
|
-
parser (3.2.
|
23
|
+
parallel (1.23.0)
|
24
|
+
parser (3.2.2.1)
|
25
25
|
ast (~> 2.4.1)
|
26
26
|
rainbow (3.1.1)
|
27
27
|
rake (13.0.6)
|
28
|
-
regexp_parser (2.
|
28
|
+
regexp_parser (2.8.0)
|
29
29
|
rexml (3.2.5)
|
30
30
|
rspec (3.12.0)
|
31
31
|
rspec-core (~> 3.12.0)
|
32
32
|
rspec-expectations (~> 3.12.0)
|
33
33
|
rspec-mocks (~> 3.12.0)
|
34
|
-
rspec-core (3.12.
|
34
|
+
rspec-core (3.12.2)
|
35
35
|
rspec-support (~> 3.12.0)
|
36
|
-
rspec-expectations (3.12.
|
36
|
+
rspec-expectations (3.12.3)
|
37
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
38
|
rspec-support (~> 3.12.0)
|
39
|
-
rspec-mocks (3.12.
|
39
|
+
rspec-mocks (3.12.5)
|
40
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
41
|
rspec-support (~> 3.12.0)
|
42
42
|
rspec-support (3.12.0)
|
43
|
-
rubocop (1.
|
43
|
+
rubocop (1.50.2)
|
44
44
|
json (~> 2.3)
|
45
45
|
parallel (~> 1.10)
|
46
46
|
parser (>= 3.2.0.0)
|
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.
|
50
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
51
51
|
ruby-progressbar (~> 1.7)
|
52
52
|
unicode-display_width (>= 2.4.0, < 3.0)
|
53
|
-
rubocop-ast (1.
|
54
|
-
parser (>= 3.
|
55
|
-
rubocop-capybara (2.
|
53
|
+
rubocop-ast (1.28.1)
|
54
|
+
parser (>= 3.2.1.0)
|
55
|
+
rubocop-capybara (2.18.0)
|
56
56
|
rubocop (~> 1.41)
|
57
|
-
rubocop-
|
57
|
+
rubocop-factory_bot (2.22.0)
|
58
|
+
rubocop (~> 1.33)
|
59
|
+
rubocop-performance (1.17.1)
|
58
60
|
rubocop (>= 1.7.0, < 2.0)
|
59
61
|
rubocop-ast (>= 0.4.0)
|
60
62
|
rubocop-rake (0.6.0)
|
61
63
|
rubocop (~> 1.0)
|
62
|
-
rubocop-rspec (2.
|
64
|
+
rubocop-rspec (2.22.0)
|
63
65
|
rubocop (~> 1.33)
|
64
66
|
rubocop-capybara (~> 2.17)
|
65
|
-
|
67
|
+
rubocop-factory_bot (~> 2.22)
|
68
|
+
ruby-progressbar (1.13.0)
|
66
69
|
tzinfo (2.0.6)
|
67
70
|
concurrent-ruby (~> 1.0)
|
68
71
|
unicode-display_width (2.4.2)
|
data/README.md
CHANGED
@@ -29,7 +29,6 @@ Note that all cops are `Enabled: false` by default.
|
|
29
29
|
## Cops
|
30
30
|
|
31
31
|
- [Sevencop/AutoloadOrdered](lib/rubocop/cop/sevencop/autoload_ordered.rb)
|
32
|
-
- [Sevencop/ConstantBase](lib/rubocop/cop/sevencop/constant_base.rb)
|
33
32
|
- [Sevencop/FactoryBotAssociationOption](lib/rubocop/cop/sevencop/factory_bot_association_option.rb)
|
34
33
|
- [Sevencop/FactoryBotAssociationStyle](lib/rubocop/cop/sevencop/factory_bot_association_style.rb)
|
35
34
|
- [Sevencop/HashElementOrdered](lib/rubocop/cop/sevencop/hash_element_ordered.rb)
|
@@ -44,7 +43,6 @@ Note that all cops are `Enabled: false` by default.
|
|
44
43
|
- [Sevencop/RailsSpecificActionName](lib/rubocop/cop/sevencop/rails_specific_action_name.rb)
|
45
44
|
- [Sevencop/RailsUniquenessValidatorExplicitCaseSensitivity](lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb)
|
46
45
|
- [Sevencop/RailsWhereNot](lib/rubocop/cop/sevencop/rails_where_not.rb)
|
47
|
-
- [Sevencop/RequireOrdered](lib/rubocop/cop/sevencop/require_ordered.rb)
|
48
46
|
- [Sevencop/RSpecDescribeHttpEndpoint](lib/rubocop/cop/sevencop/rspec_describe_http_endpoint.rb)
|
49
47
|
- [Sevencop/RSpecEmptyLineAfterLet](lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb)
|
50
48
|
- [Sevencop/RSpecExamplesInSameGroup](lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb)
|
data/config/default.yml
CHANGED
@@ -4,11 +4,6 @@ Sevencop/AutoloadOrdered:
|
|
4
4
|
Enabled: false
|
5
5
|
Safe: false
|
6
6
|
|
7
|
-
Sevencop/ConstantBase:
|
8
|
-
Description: |
|
9
|
-
Avoid unnecessary `::` prefix on constant.
|
10
|
-
Enabled: false
|
11
|
-
|
12
7
|
Sevencop/FactoryBotAssociationOption:
|
13
8
|
Description: |
|
14
9
|
Avoid redundant options on FactoryBot associations.
|
@@ -116,12 +111,6 @@ Sevencop/RailsWhereNot:
|
|
116
111
|
Enabled: false
|
117
112
|
Safe: false
|
118
113
|
|
119
|
-
Sevencop/RequireOrdered:
|
120
|
-
Description: |
|
121
|
-
Sort `require` and `require_relative` in alphabetical order.
|
122
|
-
Enabled: false
|
123
|
-
Safe: false
|
124
|
-
|
125
114
|
Sevencop/RSpecDescribeHttpEndpoint:
|
126
115
|
Description: |
|
127
116
|
Pass HTTP endpoint identifier (e.g. `GET /users`) to top-level `describe` on request-specs.
|
@@ -95,7 +95,7 @@ module RuboCop
|
|
95
95
|
def whitespace_between(node)
|
96
96
|
if node.pairs.length >= 2
|
97
97
|
processed_source.raw_source[
|
98
|
-
node.pairs[0].
|
98
|
+
node.pairs[0].source_range.end_pos + 1...node.pairs[1].source_range.begin_pos
|
99
99
|
]
|
100
100
|
else
|
101
101
|
' '
|
@@ -108,7 +108,7 @@ module RuboCop
|
|
108
108
|
# ^^^^
|
109
109
|
def whitespace_leading(node)
|
110
110
|
processed_source.raw_source[
|
111
|
-
node.
|
111
|
+
node.source_range.begin.end_pos + offset_for(node)...node.pairs[0].source_range.begin_pos
|
112
112
|
]
|
113
113
|
end
|
114
114
|
|
@@ -118,7 +118,7 @@ module RuboCop
|
|
118
118
|
# ^^
|
119
119
|
def whitespace_trailing(node)
|
120
120
|
processed_source.raw_source[
|
121
|
-
node.pairs[-1].
|
121
|
+
node.pairs[-1].source_range.end_pos...node.source_range.end.begin_pos - offset_for(node)
|
122
122
|
]
|
123
123
|
end
|
124
124
|
end
|
@@ -44,10 +44,10 @@ module RuboCop
|
|
44
44
|
corrector,
|
45
45
|
node
|
46
46
|
)
|
47
|
-
indent = ' ' * node.parent.
|
47
|
+
indent = ' ' * node.parent.source_range.column
|
48
48
|
|
49
49
|
corrector.replace(
|
50
|
-
node.
|
50
|
+
node.source_range.with(
|
51
51
|
begin_pos: node.parent.location.name.end_pos
|
52
52
|
),
|
53
53
|
[
|
@@ -67,7 +67,7 @@ module RuboCop
|
|
67
67
|
# @return [Boolean]
|
68
68
|
def multilined?(node)
|
69
69
|
node.children.map do |child|
|
70
|
-
child.
|
70
|
+
child.source_range.line
|
71
71
|
end.uniq.length == node.children.length
|
72
72
|
end
|
73
73
|
end
|
@@ -177,7 +177,7 @@ module RuboCop
|
|
177
177
|
# @param node [RuboCop::AST::SendNode]
|
178
178
|
# @return [Parser::Source::Range]
|
179
179
|
def convert_to_autocorrected_range(node)
|
180
|
-
node.
|
180
|
+
node.source_range.with(
|
181
181
|
begin_pos: node.location.selector.begin_pos
|
182
182
|
)
|
183
183
|
end
|
@@ -78,12 +78,12 @@ module RuboCop
|
|
78
78
|
add_offense(uniqueness_value) do |corrector|
|
79
79
|
if uniqueness_value.true_type?
|
80
80
|
corrector.replace(
|
81
|
-
uniqueness_value
|
81
|
+
uniqueness_value,
|
82
82
|
'{ case_sensitive: true }'
|
83
83
|
)
|
84
84
|
else
|
85
85
|
corrector.insert_after(
|
86
|
-
uniqueness_value.pairs.last
|
86
|
+
uniqueness_value.pairs.last,
|
87
87
|
', case_sensitive: true'
|
88
88
|
)
|
89
89
|
end
|
@@ -32,11 +32,11 @@ module RuboCop
|
|
32
32
|
|
33
33
|
add_offense(node) do |corrector|
|
34
34
|
pairs = node.children[2].children
|
35
|
-
last_end_pos = pairs[0].
|
35
|
+
last_end_pos = pairs[0].source_range.end_pos
|
36
36
|
pairs[1..].each do |pair|
|
37
|
-
corrector.remove(pair.
|
38
|
-
last_end_pos = pair.
|
39
|
-
corrector.insert_after(node
|
37
|
+
corrector.remove(pair.source_range.with(begin_pos: last_end_pos))
|
38
|
+
last_end_pos = pair.source_range.end_pos
|
39
|
+
corrector.insert_after(node, ".where.not(#{pair.source})")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/lib/sevencop/version.rb
CHANGED
data/lib/sevencop.rb
CHANGED
@@ -5,7 +5,6 @@ require_relative 'sevencop/rubocop_extension'
|
|
5
5
|
require_relative 'sevencop/version'
|
6
6
|
|
7
7
|
require_relative 'rubocop/cop/sevencop/autoload_ordered'
|
8
|
-
require_relative 'rubocop/cop/sevencop/constant_base'
|
9
8
|
require_relative 'rubocop/cop/sevencop/factory_bot_association_option'
|
10
9
|
require_relative 'rubocop/cop/sevencop/factory_bot_association_style'
|
11
10
|
require_relative 'rubocop/cop/sevencop/hash_element_ordered'
|
@@ -20,7 +19,6 @@ require_relative 'rubocop/cop/sevencop/rails_order_field_in_order_of'
|
|
20
19
|
require_relative 'rubocop/cop/sevencop/rails_specific_action_name'
|
21
20
|
require_relative 'rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity'
|
22
21
|
require_relative 'rubocop/cop/sevencop/rails_where_not'
|
23
|
-
require_relative 'rubocop/cop/sevencop/require_ordered'
|
24
22
|
require_relative 'rubocop/cop/sevencop/rspec_describe_http_endpoint'
|
25
23
|
require_relative 'rubocop/cop/sevencop/rspec_empty_line_after_let'
|
26
24
|
require_relative 'rubocop/cop/sevencop/rspec_examples_in_same_group'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sevencop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.35.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
@@ -57,7 +57,6 @@ files:
|
|
57
57
|
- config/default.yml
|
58
58
|
- data/reserved_words_mysql.txt
|
59
59
|
- lib/rubocop/cop/sevencop/autoload_ordered.rb
|
60
|
-
- lib/rubocop/cop/sevencop/constant_base.rb
|
61
60
|
- lib/rubocop/cop/sevencop/factory_bot_association_option.rb
|
62
61
|
- lib/rubocop/cop/sevencop/factory_bot_association_style.rb
|
63
62
|
- lib/rubocop/cop/sevencop/hash_element_ordered.rb
|
@@ -72,7 +71,6 @@ files:
|
|
72
71
|
- lib/rubocop/cop/sevencop/rails_specific_action_name.rb
|
73
72
|
- lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb
|
74
73
|
- lib/rubocop/cop/sevencop/rails_where_not.rb
|
75
|
-
- lib/rubocop/cop/sevencop/require_ordered.rb
|
76
74
|
- lib/rubocop/cop/sevencop/rspec_describe_http_endpoint.rb
|
77
75
|
- lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb
|
78
76
|
- lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module Sevencop
|
6
|
-
# Avoid unnecessary `::` prefix on constant.
|
7
|
-
#
|
8
|
-
# @example
|
9
|
-
# # bad
|
10
|
-
# ::Const
|
11
|
-
#
|
12
|
-
# # good
|
13
|
-
# Const
|
14
|
-
#
|
15
|
-
# # bad
|
16
|
-
# class << self
|
17
|
-
# ::Const
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
# # good
|
21
|
-
# class << self
|
22
|
-
# Const
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
# # good
|
26
|
-
# class A
|
27
|
-
# ::Const
|
28
|
-
# end
|
29
|
-
#
|
30
|
-
# # good
|
31
|
-
# class A
|
32
|
-
# ::Const
|
33
|
-
# end
|
34
|
-
class ConstantBase < Base
|
35
|
-
extend AutoCorrector
|
36
|
-
|
37
|
-
MSG = 'Avoid unnecessary `::` prefix on constant.'
|
38
|
-
|
39
|
-
# @param node [RuboCop::AST::CbaseNode]
|
40
|
-
# @return [void]
|
41
|
-
def on_cbase(node)
|
42
|
-
return unless bad?(node)
|
43
|
-
|
44
|
-
add_offense(node) do |corrector|
|
45
|
-
corrector.remove(node)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
# @param node [RuboCop::AST::CbaseNode]
|
52
|
-
# @return [Boolean]
|
53
|
-
def bad?(node)
|
54
|
-
module_nesting_ancestors_of(node).none?
|
55
|
-
end
|
56
|
-
|
57
|
-
# @param node [RuboCop::AST::Node]
|
58
|
-
# @return [Enumerable<RuboCop::AST::Node>]
|
59
|
-
def module_nesting_ancestors_of(node)
|
60
|
-
node.each_ancestor(:class, :module).reject do |ancestor|
|
61
|
-
ancestor.class_type? && used_in_super_class_part?(node, class_node: ancestor)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# @param class_node [RuboCop::AST::Node]
|
66
|
-
# @param node [RuboCop::AST::CbaseNode]
|
67
|
-
# @return [Boolean]
|
68
|
-
def used_in_super_class_part?(
|
69
|
-
node,
|
70
|
-
class_node:
|
71
|
-
)
|
72
|
-
class_node.parent_class&.each_descendant(:cbase)&.any? do |descendant|
|
73
|
-
descendant.equal?(node)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module Sevencop
|
6
|
-
# Sort `require` and `require_relative` in alphabetical order.
|
7
|
-
#
|
8
|
-
# @example
|
9
|
-
# # bad
|
10
|
-
# require 'b'
|
11
|
-
# require 'a'
|
12
|
-
#
|
13
|
-
# # good
|
14
|
-
# require 'a'
|
15
|
-
# require 'b'
|
16
|
-
#
|
17
|
-
# # bad
|
18
|
-
# require_relative 'b'
|
19
|
-
# require_relative 'a'
|
20
|
-
#
|
21
|
-
# # good
|
22
|
-
# require_relative 'a'
|
23
|
-
# require_relative 'b'
|
24
|
-
#
|
25
|
-
# # good
|
26
|
-
# require 'a'
|
27
|
-
# require 'd'
|
28
|
-
#
|
29
|
-
# require 'b'
|
30
|
-
# require 'c'
|
31
|
-
#
|
32
|
-
# # good
|
33
|
-
# require 'b'
|
34
|
-
# require_relative 'c'
|
35
|
-
# require 'a'
|
36
|
-
class RequireOrdered < Base
|
37
|
-
extend AutoCorrector
|
38
|
-
|
39
|
-
include RangeHelp
|
40
|
-
|
41
|
-
include ::Sevencop::CopConcerns::Ordered
|
42
|
-
|
43
|
-
RESTRICT_ON_SEND = %i[
|
44
|
-
require
|
45
|
-
require_relative
|
46
|
-
].freeze
|
47
|
-
|
48
|
-
# @param node [RuboCop::AST::SendNode]
|
49
|
-
# @return [void]
|
50
|
-
def on_send(node)
|
51
|
-
previous_older_sibling = find_previous_older_sibling(node)
|
52
|
-
return unless previous_older_sibling
|
53
|
-
|
54
|
-
add_offense(
|
55
|
-
node,
|
56
|
-
message: "Sort `#{node.method_name}` in alphabetical order."
|
57
|
-
) do |corrector|
|
58
|
-
swap(
|
59
|
-
range_with_comments_and_lines(previous_older_sibling),
|
60
|
-
range_with_comments_and_lines(node),
|
61
|
-
corrector: corrector
|
62
|
-
)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
# @param node [RuboCop::AST::SendNode]
|
69
|
-
# @return [RuboCop::AST::SendNode, nil]
|
70
|
-
def find_previous_older_sibling(node)
|
71
|
-
node.left_siblings.reverse.find do |sibling|
|
72
|
-
break unless sibling.send_type?
|
73
|
-
break if sibling.method_name != node.method_name
|
74
|
-
break unless in_same_section?(sibling, node)
|
75
|
-
|
76
|
-
node.first_argument.source < sibling.first_argument.source
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# @param node1 [RuboCop::AST::SendNode]
|
81
|
-
# @param node2 [RuboCop::AST::SendNode]
|
82
|
-
# @return [Boolean]
|
83
|
-
def in_same_section?(
|
84
|
-
node1,
|
85
|
-
node2
|
86
|
-
)
|
87
|
-
!node1.location.expression.with(
|
88
|
-
end_pos: node2.location.expression.end_pos
|
89
|
-
).source.include?("\n\n")
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|