rubocop-pixelforce 1.1 → 2.1.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 +57 -30
- data/default.yml +8 -6
- data/lib/rubocop/cop/pixelforce/empty_line_between_categories.rb +30 -43
- data/lib/rubocop/pixelforce/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5dc1398a26eafed01afb1086e384b88c2517c59aea472adf10bf00fa7a926b32
|
|
4
|
+
data.tar.gz: d34ff5b7a043877d940f5ab0a6ff23b6f6912d3107ab7dc26f0b9b3950a1b4d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba321811d6aea779cb44df0d90043a710b0c2d59def640d93b04a41bf4556694e82492223b9cb5c2945f9ea0a11736607785a7f048b81045cdc8e72f3f3e1cc7
|
|
7
|
+
data.tar.gz: 2714bc7fda30fd45e994616096752dd2549e92dd114fd022a7d6f4c53f298973e4dee549071ce1a227210082bdfa054eea37b17a0f81f458418d28b3543a29f7
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rubocop-pixelforce (1.
|
|
4
|
+
rubocop-pixelforce (2.1.0)
|
|
5
5
|
rubocop (~> 1.21)
|
|
6
6
|
rubocop-performance
|
|
7
7
|
rubocop-rails
|
|
@@ -9,26 +9,45 @@ PATH
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
activesupport (
|
|
12
|
+
activesupport (7.1.5.1)
|
|
13
|
+
base64
|
|
14
|
+
benchmark (>= 0.3)
|
|
15
|
+
bigdecimal
|
|
13
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
17
|
+
connection_pool (>= 2.2.5)
|
|
18
|
+
drb
|
|
14
19
|
i18n (>= 1.6, < 2)
|
|
20
|
+
logger (>= 1.4.2)
|
|
15
21
|
minitest (>= 5.1)
|
|
22
|
+
mutex_m
|
|
23
|
+
securerandom (>= 0.3)
|
|
16
24
|
tzinfo (~> 2.0)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
ast (2.4.3)
|
|
26
|
+
base64 (0.2.0)
|
|
27
|
+
benchmark (0.4.0)
|
|
28
|
+
bigdecimal (3.1.9)
|
|
29
|
+
concurrent-ruby (1.3.5)
|
|
30
|
+
connection_pool (2.5.3)
|
|
20
31
|
diff-lcs (1.3)
|
|
21
|
-
|
|
32
|
+
drb (2.2.3)
|
|
33
|
+
i18n (1.14.7)
|
|
22
34
|
concurrent-ruby (~> 1.0)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
json (2.12.2)
|
|
36
|
+
language_server-protocol (3.17.0.5)
|
|
37
|
+
lint_roller (1.1.0)
|
|
38
|
+
logger (1.7.0)
|
|
39
|
+
minitest (5.25.5)
|
|
40
|
+
mutex_m (0.3.0)
|
|
41
|
+
parallel (1.27.0)
|
|
42
|
+
parser (3.3.8.0)
|
|
26
43
|
ast (~> 2.4.1)
|
|
27
|
-
|
|
28
|
-
|
|
44
|
+
racc
|
|
45
|
+
prism (1.4.0)
|
|
46
|
+
racc (1.8.1)
|
|
47
|
+
rack (3.1.15)
|
|
48
|
+
rainbow (3.1.1)
|
|
29
49
|
rake (13.0.1)
|
|
30
|
-
regexp_parser (2.
|
|
31
|
-
rexml (3.2.5)
|
|
50
|
+
regexp_parser (2.10.0)
|
|
32
51
|
rspec (3.9.0)
|
|
33
52
|
rspec-core (~> 3.9.0)
|
|
34
53
|
rspec-expectations (~> 3.9.0)
|
|
@@ -42,29 +61,37 @@ GEM
|
|
|
42
61
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
43
62
|
rspec-support (~> 3.9.0)
|
|
44
63
|
rspec-support (3.9.0)
|
|
45
|
-
rubocop (1.
|
|
64
|
+
rubocop (1.75.7)
|
|
65
|
+
json (~> 2.3)
|
|
66
|
+
language_server-protocol (~> 3.17.0.2)
|
|
67
|
+
lint_roller (~> 1.1.0)
|
|
46
68
|
parallel (~> 1.10)
|
|
47
|
-
parser (>= 3.
|
|
69
|
+
parser (>= 3.3.0.2)
|
|
48
70
|
rainbow (>= 2.2.2, < 4.0)
|
|
49
|
-
regexp_parser (>=
|
|
50
|
-
|
|
51
|
-
rubocop-ast (>= 1.9.1, < 2.0)
|
|
71
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
72
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
|
52
73
|
ruby-progressbar (~> 1.7)
|
|
53
|
-
unicode-display_width (>=
|
|
54
|
-
rubocop-ast (1.
|
|
55
|
-
parser (>= 3.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
74
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
75
|
+
rubocop-ast (1.44.1)
|
|
76
|
+
parser (>= 3.3.7.2)
|
|
77
|
+
prism (~> 1.4)
|
|
78
|
+
rubocop-performance (1.25.0)
|
|
79
|
+
lint_roller (~> 1.1)
|
|
80
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
81
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
|
82
|
+
rubocop-rails (2.32.0)
|
|
60
83
|
activesupport (>= 4.2.0)
|
|
84
|
+
lint_roller (~> 1.1)
|
|
61
85
|
rack (>= 1.1)
|
|
62
|
-
rubocop (>= 1.
|
|
63
|
-
|
|
64
|
-
|
|
86
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
87
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
|
88
|
+
ruby-progressbar (1.13.0)
|
|
89
|
+
securerandom (0.3.2)
|
|
90
|
+
tzinfo (2.0.6)
|
|
65
91
|
concurrent-ruby (~> 1.0)
|
|
66
|
-
unicode-display_width (
|
|
67
|
-
|
|
92
|
+
unicode-display_width (3.1.4)
|
|
93
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
|
94
|
+
unicode-emoji (4.0.4)
|
|
68
95
|
|
|
69
96
|
PLATFORMS
|
|
70
97
|
ruby
|
data/default.yml
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
plugins:
|
|
2
2
|
- rubocop-performance
|
|
3
3
|
- rubocop-rails
|
|
4
|
+
|
|
5
|
+
require:
|
|
4
6
|
- rubocop-pixelforce
|
|
5
7
|
|
|
6
8
|
AllCops:
|
|
@@ -19,7 +21,7 @@ Rails/UnknownEnv:
|
|
|
19
21
|
- staging
|
|
20
22
|
|
|
21
23
|
Rails/HasManyOrHasOneDependent:
|
|
22
|
-
|
|
24
|
+
Enabled: false
|
|
23
25
|
|
|
24
26
|
Rails/FilePath:
|
|
25
27
|
Enabled: false
|
|
@@ -78,7 +80,7 @@ Layout/ClassStructure: &class_structures
|
|
|
78
80
|
- prepend
|
|
79
81
|
- extend
|
|
80
82
|
|
|
81
|
-
Pixelforce/
|
|
83
|
+
Pixelforce/EmptyLineBetweenCategories:
|
|
82
84
|
<<: *class_structures
|
|
83
85
|
Enabled: true
|
|
84
86
|
|
|
@@ -94,10 +96,10 @@ Style/NestedTernaryOperator:
|
|
|
94
96
|
Style/FrozenStringLiteralComment:
|
|
95
97
|
Enabled: false
|
|
96
98
|
|
|
97
|
-
Documentation:
|
|
99
|
+
Style/Documentation:
|
|
98
100
|
Enabled: false
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
Layout/LineLength:
|
|
101
103
|
Enabled: false
|
|
102
104
|
|
|
103
105
|
Metrics/MethodLength:
|
|
@@ -140,4 +142,4 @@ Style/GlobalVars:
|
|
|
140
142
|
Enabled: false
|
|
141
143
|
|
|
142
144
|
Metrics/ParameterLists:
|
|
143
|
-
Enabled: false
|
|
145
|
+
Enabled: false
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
module RuboCop
|
|
2
2
|
module Cop
|
|
3
3
|
module Pixelforce
|
|
4
|
-
class
|
|
4
|
+
class EmptyLineBetweenCategories < Base
|
|
5
5
|
include RangeHelp
|
|
6
|
+
extend AutoCorrector
|
|
6
7
|
|
|
7
8
|
HUMANIZED_NODE_TYPE = {
|
|
8
9
|
casgn: :constants,
|
|
9
10
|
defs: :class_methods,
|
|
10
11
|
def: :public_methods,
|
|
11
|
-
sclass: :class_singleton
|
|
12
|
+
sclass: :class_singleton,
|
|
13
|
+
send: :method_calls
|
|
12
14
|
}.freeze
|
|
13
15
|
|
|
14
16
|
VISIBILITY_SCOPES = %i[private protected public].freeze
|
|
15
|
-
|
|
17
|
+
MSG_EMPTY_LINE_BETWEEN_CATEGORIES = 'Use empty lines between categories.'.freeze
|
|
18
|
+
MSG_EMPTY_LINE_BETWEEN_SAME_CATEGORIES = "Don't Use empty lines between same categories.".freeze
|
|
16
19
|
|
|
17
20
|
def_node_matcher :visibility_block?, <<~PATTERN
|
|
18
21
|
(send nil? { :private :protected :public })
|
|
@@ -22,35 +25,33 @@ module RuboCop
|
|
|
22
25
|
# Add offense when find a node out of expected order.
|
|
23
26
|
def on_class(class_node)
|
|
24
27
|
previous_category = nil
|
|
25
|
-
|
|
26
|
-
previous_method_name = nil
|
|
28
|
+
|
|
27
29
|
walk_over_nested_class_definition(class_node) do |node, category|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
if previous_category && previous_category != category
|
|
31
|
+
count = blank_lines_count_between(prev_node(node), node)
|
|
32
|
+
if count < 2
|
|
33
|
+
add_offense(node, message: MSG_EMPTY_LINE_BETWEEN_CATEGORIES) do |corrector|
|
|
34
|
+
prev_category = prev_node(node)
|
|
35
|
+
end_pos = end_position_for(prev_category)
|
|
36
|
+
newline_pos = buffer.source.index("\n", end_pos)
|
|
37
|
+
where_to_insert = range_between(newline_pos, newline_pos + 1)
|
|
38
|
+
corrector.insert_after(where_to_insert, "\n")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
elsif previous_category && previous_category == category
|
|
42
|
+
count = blank_lines_count_between(prev_node(node), node)
|
|
43
|
+
if count > 1
|
|
44
|
+
add_offense(node, message: MSG_EMPTY_LINE_BETWEEN_SAME_CATEGORIES) do |corrector|
|
|
45
|
+
prev_category = prev_node(node)
|
|
46
|
+
end_pos = end_position_for(prev_category)
|
|
47
|
+
newline_pos = buffer.source.index("\n", end_pos)
|
|
48
|
+
range_to_remove = range_between(newline_pos, newline_pos + 1)
|
|
49
|
+
corrector.remove(range_to_remove)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
31
52
|
end
|
|
32
53
|
|
|
33
|
-
if previous_method_name && previous_method_name == node.method_name && node.loc.first_line - previous_node_end_line > 1
|
|
34
|
-
add_offense(node, message: "Don't Use empty lines between same categories.")
|
|
35
|
-
end
|
|
36
54
|
previous_category = category
|
|
37
|
-
previous_node_end_line = node.loc.last_line
|
|
38
|
-
previous_method_name = node.method_name
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def autocorrect(node)
|
|
43
|
-
prev_category = prev_node(node)
|
|
44
|
-
# finds position of first newline
|
|
45
|
-
end_pos = end_position_for(prev_category)
|
|
46
|
-
newline_pos = buffer.source.index("\n", end_pos)
|
|
47
|
-
|
|
48
|
-
count = blank_lines_count_between(prev_category, node)
|
|
49
|
-
|
|
50
|
-
if count > 1
|
|
51
|
-
autocorrect_remove_lines(newline_pos, count)
|
|
52
|
-
else
|
|
53
|
-
autocorrect_insert_lines(newline_pos, count)
|
|
54
55
|
end
|
|
55
56
|
end
|
|
56
57
|
|
|
@@ -220,21 +221,7 @@ module RuboCop
|
|
|
220
221
|
def categories
|
|
221
222
|
cop_config['Categories']
|
|
222
223
|
end
|
|
223
|
-
|
|
224
|
-
def autocorrect_remove_lines(newline_pos, count)
|
|
225
|
-
range_to_remove = range_between(newline_pos, newline_pos + 1)
|
|
226
|
-
lambda do |corrector|
|
|
227
|
-
corrector.remove(range_to_remove)
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
def autocorrect_insert_lines(newline_pos, count)
|
|
232
|
-
where_to_insert = range_between(newline_pos, newline_pos + 1)
|
|
233
|
-
lambda do |corrector|
|
|
234
|
-
corrector.insert_after(where_to_insert, "\n")
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
224
|
end
|
|
238
225
|
end
|
|
239
226
|
end
|
|
240
|
-
end
|
|
227
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-pixelforce
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Zhang
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-05-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
138
138
|
- !ruby/object:Gem::Version
|
|
139
139
|
version: '0'
|
|
140
140
|
requirements: []
|
|
141
|
-
rubygems_version: 3.2.
|
|
141
|
+
rubygems_version: 3.2.33
|
|
142
142
|
signing_key:
|
|
143
143
|
specification_version: 4
|
|
144
144
|
summary: Custom Rubocop cop for PixelForce.
|