rubocop-erb 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 742cdbab5d75368c8a97e45b610809a11ee36a806b7a6eea84e85b9f5810cd9e
4
- data.tar.gz: 10da21545ab9f73ada119f5cb2a54dda6e297bbc5660325fa098aa0e92c83787
3
+ metadata.gz: 8dd1a38dc89ce7ae5d7234726efd075da3475197ef392869ce3a6c3091049829
4
+ data.tar.gz: '016658e07334e120f4b3a5a099df1533ca5dc806106d66a4dcb883852ba0812f'
5
5
  SHA512:
6
- metadata.gz: 585098a85e2b0d6c4b3cd286014a2f2e1578e6744241f3cc3f098f2533f6346268c3e207937f359385b882db3ec4e189d8d680b787d28839c98c72881dbb617d
7
- data.tar.gz: 21cdb3c2918b0d01eee173e24dafbedde1340459e7c884ca7e62e3688e85b53faf576ac883753774738b9b9f7cc62c2901c21150af092b02a1e44492e0a90ab5
6
+ metadata.gz: 660537eddd2dbfddde1f6f318b086eaa99ff567f7b90998947efcdc5cdbeea05c9ab97e87263aa0a2b15f4eec35996f9c9e95576bd2711047acc6300a6dd075b
7
+ data.tar.gz: 6756de8632f08c1640735251bd3225ead59072aea590f234caf7fca37ca888212eacfedc44228b51508357536b6dbda99cc5585f3e1e9775ee0cde1b7e51083a
data/Gemfile.lock CHANGED
@@ -1,25 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-erb (0.3.0)
4
+ rubocop-erb (0.3.1)
5
5
  better_html
6
6
  rubocop (~> 1.45)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionview (7.0.4.2)
12
- activesupport (= 7.0.4.2)
11
+ actionview (7.1.2)
12
+ activesupport (= 7.1.2)
13
13
  builder (~> 3.1)
14
- erubi (~> 1.4)
15
- rails-dom-testing (~> 2.0)
16
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
17
- activesupport (7.0.4.2)
14
+ erubi (~> 1.11)
15
+ rails-dom-testing (~> 2.2)
16
+ rails-html-sanitizer (~> 1.6)
17
+ activesupport (7.1.2)
18
+ base64
19
+ bigdecimal
18
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ connection_pool (>= 2.2.5)
22
+ drb
19
23
  i18n (>= 1.6, < 2)
20
24
  minitest (>= 5.1)
25
+ mutex_m
21
26
  tzinfo (~> 2.0)
22
27
  ast (2.4.2)
28
+ base64 (0.2.0)
23
29
  better_html (2.0.2)
24
30
  actionview (>= 6.0)
25
31
  activesupport (>= 6.0)
@@ -27,25 +33,32 @@ GEM
27
33
  erubi (~> 1.4)
28
34
  parser (>= 2.4)
29
35
  smart_properties
36
+ bigdecimal (3.1.5)
30
37
  builder (3.2.4)
31
- concurrent-ruby (1.2.0)
38
+ concurrent-ruby (1.2.2)
39
+ connection_pool (2.4.1)
32
40
  crass (1.0.6)
33
41
  diff-lcs (1.5.0)
42
+ drb (2.2.0)
43
+ ruby2_keywords
34
44
  erubi (1.12.0)
35
- i18n (1.12.0)
45
+ i18n (1.14.1)
36
46
  concurrent-ruby (~> 1.0)
37
- json (2.6.3)
38
- loofah (2.21.3)
47
+ json (2.7.1)
48
+ language_server-protocol (3.17.0.3)
49
+ loofah (2.22.0)
39
50
  crass (~> 1.0.2)
40
51
  nokogiri (>= 1.12.0)
41
- minitest (5.17.0)
42
- nokogiri (1.15.3-x86_64-linux)
52
+ minitest (5.20.0)
53
+ mutex_m (0.2.0)
54
+ nokogiri (1.16.0-x86_64-linux)
43
55
  racc (~> 1.4)
44
- parallel (1.22.1)
45
- parser (3.2.0.0)
56
+ parallel (1.24.0)
57
+ parser (3.3.0.2)
46
58
  ast (~> 2.4.1)
47
- racc (1.7.1)
48
- rails-dom-testing (2.1.1)
59
+ racc
60
+ racc (1.7.3)
61
+ rails-dom-testing (2.2.0)
49
62
  activesupport (>= 5.0.0)
50
63
  minitest
51
64
  nokogiri (>= 1.6)
@@ -53,49 +66,54 @@ GEM
53
66
  loofah (~> 2.21)
54
67
  nokogiri (~> 1.14)
55
68
  rainbow (3.1.1)
56
- rake (13.0.6)
57
- regexp_parser (2.6.2)
58
- rexml (3.2.5)
69
+ rake (13.1.0)
70
+ regexp_parser (2.8.3)
71
+ rexml (3.2.6)
59
72
  rspec (3.12.0)
60
73
  rspec-core (~> 3.12.0)
61
74
  rspec-expectations (~> 3.12.0)
62
75
  rspec-mocks (~> 3.12.0)
63
- rspec-core (3.12.1)
76
+ rspec-core (3.12.2)
64
77
  rspec-support (~> 3.12.0)
65
- rspec-expectations (3.12.2)
78
+ rspec-expectations (3.12.3)
66
79
  diff-lcs (>= 1.2.0, < 2.0)
67
80
  rspec-support (~> 3.12.0)
68
- rspec-mocks (3.12.3)
81
+ rspec-mocks (3.12.6)
69
82
  diff-lcs (>= 1.2.0, < 2.0)
70
83
  rspec-support (~> 3.12.0)
71
- rspec-support (3.12.0)
72
- rubocop (1.45.0)
84
+ rspec-support (3.12.1)
85
+ rubocop (1.59.0)
73
86
  json (~> 2.3)
87
+ language_server-protocol (>= 3.17.0)
74
88
  parallel (~> 1.10)
75
- parser (>= 3.2.0.0)
89
+ parser (>= 3.2.2.4)
76
90
  rainbow (>= 2.2.2, < 4.0)
77
91
  regexp_parser (>= 1.8, < 3.0)
78
92
  rexml (>= 3.2.5, < 4.0)
79
- rubocop-ast (>= 1.24.1, < 2.0)
93
+ rubocop-ast (>= 1.30.0, < 2.0)
80
94
  ruby-progressbar (~> 1.7)
81
95
  unicode-display_width (>= 2.4.0, < 3.0)
82
- rubocop-ast (1.24.1)
83
- parser (>= 3.1.1.0)
84
- rubocop-capybara (2.17.0)
96
+ rubocop-ast (1.30.0)
97
+ parser (>= 3.2.1.0)
98
+ rubocop-capybara (2.20.0)
99
+ rubocop (~> 1.41)
100
+ rubocop-factory_bot (2.25.1)
85
101
  rubocop (~> 1.41)
86
102
  rubocop-rake (0.6.0)
87
103
  rubocop (~> 1.0)
88
- rubocop-rspec (2.18.1)
89
- rubocop (~> 1.33)
104
+ rubocop-rspec (2.26.1)
105
+ rubocop (~> 1.40)
90
106
  rubocop-capybara (~> 2.17)
91
- ruby-progressbar (1.11.0)
92
- sevencop (0.33.0)
107
+ rubocop-factory_bot (~> 2.22)
108
+ ruby-progressbar (1.13.0)
109
+ ruby2_keywords (0.0.5)
110
+ sevencop (0.35.1)
93
111
  activesupport
94
112
  rubocop
95
113
  smart_properties (1.17.0)
96
114
  tzinfo (2.0.6)
97
115
  concurrent-ruby (~> 1.0)
98
- unicode-display_width (2.4.2)
116
+ unicode-display_width (2.5.0)
99
117
 
100
118
  PLATFORMS
101
119
  x86_64-linux
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec path: '..'
6
+
7
+ gem 'nokogiri', '~> 1.15.0'
8
+ gem 'rake'
9
+ gem 'rspec'
10
+ gem 'rubocop-rake'
11
+ gem 'rubocop-rspec'
12
+ gem 'sevencop'
@@ -0,0 +1,131 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rubocop-erb (0.3.0)
5
+ better_html
6
+ rubocop (~> 1.45)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionview (7.1.2)
12
+ activesupport (= 7.1.2)
13
+ builder (~> 3.1)
14
+ erubi (~> 1.11)
15
+ rails-dom-testing (~> 2.2)
16
+ rails-html-sanitizer (~> 1.6)
17
+ activesupport (7.1.2)
18
+ base64
19
+ bigdecimal
20
+ concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ connection_pool (>= 2.2.5)
22
+ drb
23
+ i18n (>= 1.6, < 2)
24
+ minitest (>= 5.1)
25
+ mutex_m
26
+ tzinfo (~> 2.0)
27
+ ast (2.4.2)
28
+ base64 (0.2.0)
29
+ better_html (2.0.2)
30
+ actionview (>= 6.0)
31
+ activesupport (>= 6.0)
32
+ ast (~> 2.0)
33
+ erubi (~> 1.4)
34
+ parser (>= 2.4)
35
+ smart_properties
36
+ bigdecimal (3.1.5)
37
+ builder (3.2.4)
38
+ concurrent-ruby (1.2.2)
39
+ connection_pool (2.4.1)
40
+ crass (1.0.6)
41
+ diff-lcs (1.5.0)
42
+ drb (2.2.0)
43
+ ruby2_keywords
44
+ erubi (1.12.0)
45
+ i18n (1.14.1)
46
+ concurrent-ruby (~> 1.0)
47
+ json (2.7.1)
48
+ language_server-protocol (3.17.0.3)
49
+ loofah (2.22.0)
50
+ crass (~> 1.0.2)
51
+ nokogiri (>= 1.12.0)
52
+ minitest (5.20.0)
53
+ mutex_m (0.2.0)
54
+ nokogiri (1.15.5-x86_64-linux)
55
+ racc (~> 1.4)
56
+ parallel (1.24.0)
57
+ parser (3.3.0.2)
58
+ ast (~> 2.4.1)
59
+ racc
60
+ racc (1.7.3)
61
+ rails-dom-testing (2.2.0)
62
+ activesupport (>= 5.0.0)
63
+ minitest
64
+ nokogiri (>= 1.6)
65
+ rails-html-sanitizer (1.6.0)
66
+ loofah (~> 2.21)
67
+ nokogiri (~> 1.14)
68
+ rainbow (3.1.1)
69
+ rake (13.1.0)
70
+ regexp_parser (2.8.3)
71
+ rexml (3.2.6)
72
+ rspec (3.12.0)
73
+ rspec-core (~> 3.12.0)
74
+ rspec-expectations (~> 3.12.0)
75
+ rspec-mocks (~> 3.12.0)
76
+ rspec-core (3.12.2)
77
+ rspec-support (~> 3.12.0)
78
+ rspec-expectations (3.12.3)
79
+ diff-lcs (>= 1.2.0, < 2.0)
80
+ rspec-support (~> 3.12.0)
81
+ rspec-mocks (3.12.6)
82
+ diff-lcs (>= 1.2.0, < 2.0)
83
+ rspec-support (~> 3.12.0)
84
+ rspec-support (3.12.1)
85
+ rubocop (1.59.0)
86
+ json (~> 2.3)
87
+ language_server-protocol (>= 3.17.0)
88
+ parallel (~> 1.10)
89
+ parser (>= 3.2.2.4)
90
+ rainbow (>= 2.2.2, < 4.0)
91
+ regexp_parser (>= 1.8, < 3.0)
92
+ rexml (>= 3.2.5, < 4.0)
93
+ rubocop-ast (>= 1.30.0, < 2.0)
94
+ ruby-progressbar (~> 1.7)
95
+ unicode-display_width (>= 2.4.0, < 3.0)
96
+ rubocop-ast (1.30.0)
97
+ parser (>= 3.2.1.0)
98
+ rubocop-capybara (2.20.0)
99
+ rubocop (~> 1.41)
100
+ rubocop-factory_bot (2.25.1)
101
+ rubocop (~> 1.41)
102
+ rubocop-rake (0.6.0)
103
+ rubocop (~> 1.0)
104
+ rubocop-rspec (2.26.1)
105
+ rubocop (~> 1.40)
106
+ rubocop-capybara (~> 2.17)
107
+ rubocop-factory_bot (~> 2.22)
108
+ ruby-progressbar (1.13.0)
109
+ ruby2_keywords (0.0.5)
110
+ sevencop (0.35.1)
111
+ activesupport
112
+ rubocop
113
+ smart_properties (1.17.0)
114
+ tzinfo (2.0.6)
115
+ concurrent-ruby (~> 1.0)
116
+ unicode-display_width (2.5.0)
117
+
118
+ PLATFORMS
119
+ x86_64-linux
120
+
121
+ DEPENDENCIES
122
+ nokogiri (~> 1.15.0)
123
+ rake
124
+ rspec
125
+ rubocop-erb!
126
+ rubocop-rake
127
+ rubocop-rspec
128
+ sevencop
129
+
130
+ BUNDLED WITH
131
+ 2.3.19
@@ -21,6 +21,9 @@ module RuboCop
21
21
  def call
22
22
  [
23
23
  PrecedingKeywordRemover,
24
+ PrecedingBraceRemover,
25
+ TrailingBraceRemover,
26
+ TrailingThenRemover,
24
27
  TrailingDoRemover
25
28
  ].reduce(@ruby_clip) do |previous, callable|
26
29
  result = callable.call(previous.code)
@@ -31,29 +34,7 @@ module RuboCop
31
34
  end
32
35
  end
33
36
 
34
- # Remove preceding keyword.
35
- class PrecedingKeywordRemover
36
- REGEXP = /
37
- \A
38
- \s*
39
- (?:
40
- begin
41
- | case
42
- | else
43
- | elsif
44
- | end
45
- | ensure
46
- | if
47
- | rescue
48
- | unless
49
- | until
50
- | when
51
- | while
52
- | for[ \t]+\w+[ \t]+in
53
- )
54
- \b[ \t]*
55
- /x.freeze
56
-
37
+ class PrecedingSourceRemover
57
38
  class << self
58
39
  # @param [String] code
59
40
  # @return [RubyClip]
@@ -69,7 +50,7 @@ module RuboCop
69
50
 
70
51
  # @return [Hash]
71
52
  def call
72
- data = @code.match(REGEXP)
53
+ data = @code.match(self.class::REGEXP)
73
54
  if data
74
55
  offset = data[0].length
75
56
  RubyClip.new(
@@ -85,17 +66,40 @@ module RuboCop
85
66
  end
86
67
  end
87
68
 
88
- # Remove trailing `do`.
89
- class TrailingDoRemover
69
+ # Remove preceding keyword.
70
+ class PrecedingKeywordRemover < PrecedingSourceRemover
90
71
  REGEXP = /
91
- [ \t]
92
- do
93
- [ \t]*
94
- (\|[^|]*\|)?
95
- [ \t]*
96
- \Z
72
+ \A
73
+ \s*
74
+ (?:
75
+ begin
76
+ | case
77
+ | else
78
+ | elsif
79
+ | end
80
+ | ensure
81
+ | if
82
+ | rescue
83
+ | unless
84
+ | until
85
+ | when
86
+ | while
87
+ | for[ \t]+\w+[ \t]+in
88
+ )
89
+ \b[ \t]*
97
90
  /x.freeze
91
+ end
98
92
 
93
+ # Remove preceding `}`.
94
+ class PrecedingBraceRemover < PrecedingSourceRemover
95
+ REGEXP = /
96
+ \A
97
+ \s*
98
+ }
99
+ /x.freeze
100
+ end
101
+
102
+ class TrailingSourceRemover
99
103
  class << self
100
104
  # @param [String] code
101
105
  # @return [RubyClip]
@@ -112,11 +116,44 @@ module RuboCop
112
116
  # @return [Hash]
113
117
  def call
114
118
  RubyClip.new(
115
- code: @code.sub(REGEXP, ''),
119
+ code: @code.sub(self.class::REGEXP, ''),
116
120
  offset: 0
117
121
  )
118
122
  end
119
123
  end
124
+
125
+ # Remove trailing `{`.
126
+ class TrailingBraceRemover < TrailingSourceRemover
127
+ REGEXP = /
128
+ {
129
+ [ \t]*
130
+ (?:\|[^|]*\|)?
131
+ \s*
132
+ \z
133
+ /x.freeze
134
+ end
135
+
136
+ # Remove trailing `then`.
137
+ class TrailingThenRemover < TrailingSourceRemover
138
+ REGEXP = /
139
+ [ \t]*\b
140
+ then
141
+ \s*
142
+ \z
143
+ /x.freeze
144
+ end
145
+
146
+ # Remove trailing `do`.
147
+ class TrailingDoRemover < TrailingSourceRemover
148
+ REGEXP = /
149
+ [ \t]
150
+ do
151
+ [ \t]*
152
+ (?:\|[^|]*\|)?
153
+ \s*
154
+ \z
155
+ /x.freeze
156
+ end
120
157
  end
121
158
  end
122
159
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Erb
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-erb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-20 00:00:00.000000000 Z
11
+ date: 2024-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: better_html
@@ -54,6 +54,8 @@ files:
54
54
  - README.md
55
55
  - Rakefile
56
56
  - config/default.yml
57
+ - gemfiles/ruby_2.7.gemfile
58
+ - gemfiles/ruby_2.7.gemfile.lock
57
59
  - lib/rubocop/erb.rb
58
60
  - lib/rubocop/erb/config_loader.rb
59
61
  - lib/rubocop/erb/keyword_remover.rb