immosquare-cleaner 0.1.82 → 0.1.84
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/lib/immosquare-cleaner/version.rb +1 -1
- data/linters/erb-lint-3.4.1.yml +0 -2
- data/linters/erb-lint.yml +0 -2
- data/linters/erb_lint/custom_html_to_content_tag.rb +105 -9
- data/linters/rubocop/cop/custom_cops/style/comment_normalization.rb +15 -2
- data/linters/rubocop/cop/custom_cops/style/font_awesome_normalization.rb +25 -19
- data/linters/rubocop-3.4.1.yml +92 -0
- data/linters/rubocop.yml +63 -1
- metadata +1 -2
- data/linters/erb_lint/custom_normalize_attribute_spaces.rb +0 -63
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5db4cb8de23d20003df752fda8dc72588776050a743e6c4f24cfaf9004e1a975
|
|
4
|
+
data.tar.gz: 94dd38d03de54e6a216a83eec05f4ee92ddf8154e2552ec8b1930a53d8c4a295
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86c068a18ff2ef426704c1585d940f9ce702f026b98c37e67797b8a12fe93a5232ad21cadf1cbebdb5b6fcd7ca678a8956747e1d4c547710ec9a672106b7325a
|
|
7
|
+
data.tar.gz: fae01ff6fb1c24ec38f95ca92095b17e85d8024f9fd35372941ce14a862a0a7dc00db3361545f6199620ebefdceb735cbd42c772d96bc7bbada453a575bb409f
|
data/linters/erb-lint-3.4.1.yml
CHANGED
data/linters/erb-lint.yml
CHANGED
|
@@ -26,7 +26,23 @@ module ERBLint
|
|
|
26
26
|
## Void elements that cannot have content (self-closing tags)
|
|
27
27
|
##============================================================##
|
|
28
28
|
VOID_ELEMENTS = [
|
|
29
|
-
"area",
|
|
29
|
+
"area",
|
|
30
|
+
"base",
|
|
31
|
+
"br",
|
|
32
|
+
"col",
|
|
33
|
+
"command",
|
|
34
|
+
"embed",
|
|
35
|
+
"hr",
|
|
36
|
+
"img",
|
|
37
|
+
"input",
|
|
38
|
+
"keygen",
|
|
39
|
+
"link",
|
|
40
|
+
"menuitem",
|
|
41
|
+
"meta",
|
|
42
|
+
"param",
|
|
43
|
+
"source",
|
|
44
|
+
"track",
|
|
45
|
+
"wbr"
|
|
30
46
|
].freeze
|
|
31
47
|
|
|
32
48
|
##============================================================##
|
|
@@ -44,7 +60,70 @@ module ERBLint
|
|
|
44
60
|
##============================================================##
|
|
45
61
|
EXCLUDED_METHODS = [
|
|
46
62
|
"render",
|
|
47
|
-
"content_tag"
|
|
63
|
+
"content_tag",
|
|
64
|
+
"image_tag"
|
|
65
|
+
].freeze
|
|
66
|
+
|
|
67
|
+
##============================================================##
|
|
68
|
+
## HTML tags that should not be converted to content_tag
|
|
69
|
+
## These tags are more readable as HTML (tables, etc.)
|
|
70
|
+
##============================================================##
|
|
71
|
+
EXCLUDED_TAGS = [
|
|
72
|
+
"th",
|
|
73
|
+
"td",
|
|
74
|
+
"tr",
|
|
75
|
+
"thead",
|
|
76
|
+
"tbody",
|
|
77
|
+
"tfoot",
|
|
78
|
+
"table",
|
|
79
|
+
"caption",
|
|
80
|
+
"colgroup"
|
|
81
|
+
].freeze
|
|
82
|
+
|
|
83
|
+
##============================================================##
|
|
84
|
+
## Form builder methods - if called on a receiver, skip conversion
|
|
85
|
+
## This detects form builders regardless of variable name (f, form, etc.)
|
|
86
|
+
## Example: <div><%= f.input(:name) %></div> should stay as-is
|
|
87
|
+
##============================================================##
|
|
88
|
+
FORM_BUILDER_METHODS = [
|
|
89
|
+
"input",
|
|
90
|
+
"label",
|
|
91
|
+
"text_field",
|
|
92
|
+
"text_area",
|
|
93
|
+
"password_field",
|
|
94
|
+
"hidden_field",
|
|
95
|
+
"file_field",
|
|
96
|
+
"check_box",
|
|
97
|
+
"radio_button",
|
|
98
|
+
"select",
|
|
99
|
+
"collection_select",
|
|
100
|
+
"collection_check_boxes",
|
|
101
|
+
"collection_radio_buttons",
|
|
102
|
+
"grouped_collection_select",
|
|
103
|
+
"date_select",
|
|
104
|
+
"time_select",
|
|
105
|
+
"datetime_select",
|
|
106
|
+
"date_field",
|
|
107
|
+
"time_field",
|
|
108
|
+
"datetime_field",
|
|
109
|
+
"datetime_local_field",
|
|
110
|
+
"month_field",
|
|
111
|
+
"week_field",
|
|
112
|
+
"url_field",
|
|
113
|
+
"email_field",
|
|
114
|
+
"number_field",
|
|
115
|
+
"range_field",
|
|
116
|
+
"search_field",
|
|
117
|
+
"telephone_field",
|
|
118
|
+
"phone_field",
|
|
119
|
+
"color_field",
|
|
120
|
+
"submit",
|
|
121
|
+
"button",
|
|
122
|
+
"association",
|
|
123
|
+
"input_field",
|
|
124
|
+
"error",
|
|
125
|
+
"hint",
|
|
126
|
+
"full_error"
|
|
48
127
|
].freeze
|
|
49
128
|
|
|
50
129
|
def run(processed_source)
|
|
@@ -61,6 +140,7 @@ module ERBLint
|
|
|
61
140
|
tag_name = extract_tag_name(child)
|
|
62
141
|
next if tag_name.nil?
|
|
63
142
|
next if VOID_ELEMENTS.include?(tag_name.downcase)
|
|
143
|
+
next if EXCLUDED_TAGS.include?(tag_name.downcase)
|
|
64
144
|
|
|
65
145
|
##============================================================##
|
|
66
146
|
## Check if next child is text containing only ERB output
|
|
@@ -165,29 +245,45 @@ module ERBLint
|
|
|
165
245
|
end
|
|
166
246
|
|
|
167
247
|
##============================================================##
|
|
168
|
-
## Check if the ERB code calls an excluded method
|
|
248
|
+
## Check if the ERB code calls an excluded method or form builder
|
|
169
249
|
## Uses Prism parser for proper Ruby AST analysis
|
|
170
250
|
##============================================================##
|
|
171
251
|
def excluded_method?(erb_code)
|
|
172
252
|
return false unless erb_code
|
|
173
253
|
|
|
174
|
-
|
|
175
|
-
return false unless
|
|
254
|
+
call_node = extract_call_node(erb_code)
|
|
255
|
+
return false unless call_node
|
|
176
256
|
|
|
177
|
-
|
|
257
|
+
method_name = call_node.name.to_s
|
|
258
|
+
return true if EXCLUDED_METHODS.include?(method_name)
|
|
259
|
+
|
|
260
|
+
##============================================================##
|
|
261
|
+
## If method is a form builder method called on a receiver,
|
|
262
|
+
## skip conversion (e.g., f.input, form.text_field, etc.)
|
|
263
|
+
##============================================================##
|
|
264
|
+
return true if call_node.receiver && FORM_BUILDER_METHODS.include?(method_name)
|
|
265
|
+
|
|
266
|
+
false
|
|
178
267
|
end
|
|
179
268
|
|
|
180
269
|
##============================================================##
|
|
181
|
-
## Extract the
|
|
270
|
+
## Extract the CallNode from Ruby code using Prism parser
|
|
271
|
+
## Handles both direct calls and calls with if/unless modifiers
|
|
182
272
|
##============================================================##
|
|
183
|
-
def
|
|
273
|
+
def extract_call_node(erb_code)
|
|
184
274
|
result = Prism.parse(erb_code)
|
|
185
275
|
return nil unless result.success?
|
|
186
276
|
|
|
187
277
|
node = result.value.statements.body.first
|
|
278
|
+
|
|
279
|
+
##============================================================##
|
|
280
|
+
## Handle if/unless modifiers: `render(...) if condition`
|
|
281
|
+
##============================================================##
|
|
282
|
+
node = node.statements&.body&.first if node.is_a?(Prism::IfNode) || node.is_a?(Prism::UnlessNode)
|
|
283
|
+
|
|
188
284
|
return nil unless node.is_a?(Prism::CallNode)
|
|
189
285
|
|
|
190
|
-
node
|
|
286
|
+
node
|
|
191
287
|
rescue StandardError
|
|
192
288
|
nil
|
|
193
289
|
end
|
|
@@ -71,9 +71,22 @@ module RuboCop
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
standalone_comments.each_with_index do |comment, index|
|
|
74
|
-
next_comment
|
|
74
|
+
next_comment = standalone_comments[index + 1]
|
|
75
|
+
comment_text = comment.text.strip
|
|
76
|
+
next_comment_text = next_comment&.text&.strip
|
|
77
|
+
is_double_hash = comment_text.start_with?("##")
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
##============================================================##
|
|
80
|
+
## On vérifie si le prochain commentaire est sur la ligne suivante
|
|
81
|
+
## ET si les deux commentaires sont du même "type" (## ou #)
|
|
82
|
+
## Cela permet de ne pas fusionner les commentaires temporaires
|
|
83
|
+
## (# x = 1) avec les vrais commentaires (##)
|
|
84
|
+
##============================================================##
|
|
85
|
+
next_is_double_hash = next_comment_text&.start_with?("##")
|
|
86
|
+
same_type = is_double_hash == next_is_double_hash
|
|
87
|
+
next_line_contiguous = next_comment && next_comment.location.line == comment.location.line + 1
|
|
88
|
+
|
|
89
|
+
if next_line_contiguous && same_type
|
|
77
90
|
current_block << comment
|
|
78
91
|
else
|
|
79
92
|
current_block << comment
|
|
@@ -2,28 +2,32 @@ module RuboCop
|
|
|
2
2
|
module Cop
|
|
3
3
|
module CustomCops
|
|
4
4
|
module Style
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
##============================================================##
|
|
6
|
+
## This cop identifies usage of short Font Awesome prefix styles (e.g., 'fas', 'far', 'fal')
|
|
7
|
+
## and suggests replacing them with the long version style (which is the standard since v6).
|
|
8
|
+
##
|
|
9
|
+
## Doc : https://docs.fontawesome.com/web/setup/upgrade/whats-changed#full-style-names
|
|
10
|
+
##
|
|
11
|
+
## @example
|
|
12
|
+
## bad
|
|
13
|
+
## font_awesome_icon("fas fa-user")
|
|
14
|
+
## font_awesome_icon("far fa-circle-info")
|
|
15
|
+
## font_awesome_icon("fal fa-bell")
|
|
16
|
+
##
|
|
17
|
+
## good
|
|
18
|
+
## font_awesome_icon("fa-solid fa-user")
|
|
19
|
+
## font_awesome_icon("fa-regular fa-circle-info")
|
|
20
|
+
## font_awesome_icon("fa-light fa-bell")
|
|
21
|
+
##============================================================##
|
|
20
22
|
class FontAwesomeNormalization < RuboCop::Cop::Base
|
|
21
23
|
|
|
22
24
|
extend AutoCorrector
|
|
23
25
|
|
|
24
26
|
MSG = "Use long version Font Awesome style prefix instead of short version.".freeze
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
##============================================================##
|
|
29
|
+
## Mapping from short prefixes to long prefixes
|
|
30
|
+
##============================================================##
|
|
27
31
|
FA_PREFIX_MAP = {
|
|
28
32
|
"fas" => "fa-solid",
|
|
29
33
|
"far" => "fa-regular",
|
|
@@ -44,11 +48,11 @@ module RuboCop
|
|
|
44
48
|
"fab" => "fa-brands"
|
|
45
49
|
}.freeze
|
|
46
50
|
|
|
47
|
-
def_node_matcher
|
|
51
|
+
def_node_matcher(:font_awesome_icon_call?, <<~PATTERN)
|
|
48
52
|
(send nil? :font_awesome_icon $...)
|
|
49
53
|
PATTERN
|
|
50
54
|
|
|
51
|
-
def_node_matcher
|
|
55
|
+
def_node_matcher(:string_argument?, <<~PATTERN)
|
|
52
56
|
(str $_)
|
|
53
57
|
PATTERN
|
|
54
58
|
|
|
@@ -93,7 +97,9 @@ module RuboCop
|
|
|
93
97
|
corrector.replace(node, replacement)
|
|
94
98
|
end
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
##============================================================##
|
|
101
|
+
## Once we've found a match, no need to check other prefixes
|
|
102
|
+
##============================================================##
|
|
97
103
|
break
|
|
98
104
|
end
|
|
99
105
|
end
|
data/linters/rubocop-3.4.1.yml
CHANGED
|
@@ -107,12 +107,104 @@ Style/MethodCallWithArgsParentheses:
|
|
|
107
107
|
- raise
|
|
108
108
|
- fail
|
|
109
109
|
- gem
|
|
110
|
+
- group
|
|
110
111
|
- source
|
|
111
112
|
- ruby
|
|
112
113
|
- desc
|
|
113
114
|
- task
|
|
114
115
|
- namespace
|
|
115
116
|
- yield
|
|
117
|
+
- install_plugin
|
|
118
|
+
- before_action
|
|
119
|
+
- after_action
|
|
120
|
+
- skip_before_action
|
|
121
|
+
- around_action
|
|
122
|
+
- before_filter
|
|
123
|
+
- after_filter
|
|
124
|
+
- around_filter
|
|
125
|
+
- validates
|
|
126
|
+
- validates_presence_of
|
|
127
|
+
- validates_uniqueness_of
|
|
128
|
+
- validates_length_of
|
|
129
|
+
- validates_format_of
|
|
130
|
+
- validates_numericality_of
|
|
131
|
+
- validates_inclusion_of
|
|
132
|
+
- validates_exclusion_of
|
|
133
|
+
- validates_confirmation_of
|
|
134
|
+
- validates_acceptance_of
|
|
135
|
+
- validates_absence_of
|
|
136
|
+
- validates_associated
|
|
137
|
+
- validates_each
|
|
138
|
+
- validates_with
|
|
139
|
+
- validates_with_method
|
|
140
|
+
- validates_with_method_name
|
|
141
|
+
- validates_with_method_name_and_arguments
|
|
142
|
+
- validates_with_method_name_and_arguments_and_options
|
|
143
|
+
- belongs_to
|
|
144
|
+
- has_many
|
|
145
|
+
- has_one
|
|
146
|
+
- has_many_through
|
|
147
|
+
- has_one_through
|
|
148
|
+
- has_many_and_belongs_to_many
|
|
149
|
+
- has_many_and_belongs_to_many_through
|
|
150
|
+
- has_many_and_belongs_to_many_through_through
|
|
151
|
+
- has_many_and_belongs_to_many_through_through_through
|
|
152
|
+
- has_many_and_belongs_to_many_through_through_through_through
|
|
153
|
+
- before_validation
|
|
154
|
+
- after_validation
|
|
155
|
+
- around_validation
|
|
156
|
+
- before_save
|
|
157
|
+
- after_save
|
|
158
|
+
- around_save
|
|
159
|
+
- before_create
|
|
160
|
+
- after_create
|
|
161
|
+
- around_create
|
|
162
|
+
- before_update
|
|
163
|
+
- after_update
|
|
164
|
+
- around_update
|
|
165
|
+
- before_destroy
|
|
166
|
+
- after_destroy
|
|
167
|
+
- around_destroy
|
|
168
|
+
- before_commit
|
|
169
|
+
- after_commit
|
|
170
|
+
- around_commit
|
|
171
|
+
- before_validation
|
|
172
|
+
- after_validation
|
|
173
|
+
- around_validation
|
|
174
|
+
- before_save
|
|
175
|
+
- after_save
|
|
176
|
+
- around_save
|
|
177
|
+
- before_create
|
|
178
|
+
- after_create
|
|
179
|
+
- around_create
|
|
180
|
+
- before_update
|
|
181
|
+
- after_update
|
|
182
|
+
- around_update
|
|
183
|
+
- before_destroy
|
|
184
|
+
- after_destroy
|
|
185
|
+
- around_destroy
|
|
186
|
+
- before_commit
|
|
187
|
+
- after_commit
|
|
188
|
+
- around_commit
|
|
189
|
+
- before_validation
|
|
190
|
+
- after_validation
|
|
191
|
+
- around_validation
|
|
192
|
+
- before_save
|
|
193
|
+
- after_save
|
|
194
|
+
- around_save
|
|
195
|
+
- before_create
|
|
196
|
+
- after_create
|
|
197
|
+
- around_create
|
|
198
|
+
- before_update
|
|
199
|
+
- after_update
|
|
200
|
+
- around_update
|
|
201
|
+
- before_destroy
|
|
202
|
+
- after_destroy
|
|
203
|
+
- around_destroy
|
|
204
|
+
- before_commit
|
|
205
|
+
- after_commit
|
|
206
|
+
- around_commit
|
|
207
|
+
- serialize
|
|
116
208
|
CustomCops/Style/CommentNormalization:
|
|
117
209
|
Enabled: true
|
|
118
210
|
CustomCops/Style/FontAwesomeNormalization:
|
data/linters/rubocop.yml
CHANGED
|
@@ -111,6 +111,7 @@ Style/MethodCallWithArgsParentheses:
|
|
|
111
111
|
EnforcedStyle: require_parentheses
|
|
112
112
|
IgnoreMacros: false
|
|
113
113
|
AllowedMethods:
|
|
114
|
+
## Ruby core
|
|
114
115
|
- require
|
|
115
116
|
- require_relative
|
|
116
117
|
- include
|
|
@@ -118,13 +119,74 @@ Style/MethodCallWithArgsParentheses:
|
|
|
118
119
|
- prepend
|
|
119
120
|
- raise
|
|
120
121
|
- fail
|
|
122
|
+
- yield
|
|
123
|
+
- attr_accessor
|
|
124
|
+
- attr_reader
|
|
125
|
+
- attr_writer
|
|
126
|
+
## Bundler / Gemfile
|
|
121
127
|
- gem
|
|
128
|
+
- group
|
|
122
129
|
- source
|
|
123
130
|
- ruby
|
|
131
|
+
- install_plugin
|
|
132
|
+
## Rake
|
|
124
133
|
- desc
|
|
125
134
|
- task
|
|
126
135
|
- namespace
|
|
127
|
-
|
|
136
|
+
## Rails Controller
|
|
137
|
+
- before_action
|
|
138
|
+
- after_action
|
|
139
|
+
- around_action
|
|
140
|
+
- skip_before_action
|
|
141
|
+
- prepend_before_action
|
|
142
|
+
- append_before_action
|
|
143
|
+
- helper_method
|
|
144
|
+
- layout
|
|
145
|
+
- rescue_from
|
|
146
|
+
## Rails Model - Associations
|
|
147
|
+
- belongs_to
|
|
148
|
+
- has_many
|
|
149
|
+
- has_one
|
|
150
|
+
- has_and_belongs_to_many
|
|
151
|
+
## Rails Model - Validations
|
|
152
|
+
- validates
|
|
153
|
+
- validate
|
|
154
|
+
- validates_presence_of
|
|
155
|
+
- validates_uniqueness_of
|
|
156
|
+
- validates_length_of
|
|
157
|
+
- validates_format_of
|
|
158
|
+
- validates_numericality_of
|
|
159
|
+
- validates_inclusion_of
|
|
160
|
+
- validates_exclusion_of
|
|
161
|
+
- validates_confirmation_of
|
|
162
|
+
- validates_acceptance_of
|
|
163
|
+
- validates_absence_of
|
|
164
|
+
- validates_associated
|
|
165
|
+
- validates_each
|
|
166
|
+
- validates_with
|
|
167
|
+
## Rails Model - Callbacks
|
|
168
|
+
- after_initialize
|
|
169
|
+
- after_find
|
|
170
|
+
- before_validation
|
|
171
|
+
- after_validation
|
|
172
|
+
- before_save
|
|
173
|
+
- after_save
|
|
174
|
+
- around_save
|
|
175
|
+
- before_create
|
|
176
|
+
- after_create
|
|
177
|
+
- around_create
|
|
178
|
+
- before_update
|
|
179
|
+
- after_update
|
|
180
|
+
- around_update
|
|
181
|
+
- before_destroy
|
|
182
|
+
- after_destroy
|
|
183
|
+
- around_destroy
|
|
184
|
+
- after_touch
|
|
185
|
+
- after_commit
|
|
186
|
+
- after_rollback
|
|
187
|
+
## Rails Model - Other
|
|
188
|
+
- delegate
|
|
189
|
+
- enum
|
|
128
190
|
|
|
129
191
|
#################### CUSTOMS ###########################
|
|
130
192
|
CustomCops/Style/CommentNormalization:
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: immosquare-cleaner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.84
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- immosquare
|
|
@@ -150,7 +150,6 @@ files:
|
|
|
150
150
|
- linters/erb-lint-3.4.1.yml
|
|
151
151
|
- linters/erb-lint.yml
|
|
152
152
|
- linters/erb_lint/custom_html_to_content_tag.rb
|
|
153
|
-
- linters/erb_lint/custom_normalize_attribute_spaces.rb
|
|
154
153
|
- linters/erb_lint/custom_single_line_if_modifier.rb
|
|
155
154
|
- linters/eslint.config.mjs
|
|
156
155
|
- linters/prettier.yml
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module ERBLint
|
|
4
|
-
module Linters
|
|
5
|
-
##============================================================##
|
|
6
|
-
## This linter detects and removes multiple consecutive spaces
|
|
7
|
-
## in HTML attribute values.
|
|
8
|
-
##
|
|
9
|
-
## @example
|
|
10
|
-
## bad
|
|
11
|
-
## <div class="flex grow items-center">
|
|
12
|
-
##
|
|
13
|
-
## good
|
|
14
|
-
## <div class="flex grow items-center">
|
|
15
|
-
##
|
|
16
|
-
##============================================================##
|
|
17
|
-
class CustomNormalizeAttributeSpaces < Linter
|
|
18
|
-
|
|
19
|
-
include LinterRegistry
|
|
20
|
-
|
|
21
|
-
MSG = "Remove multiple consecutive spaces in attribute value."
|
|
22
|
-
|
|
23
|
-
def run(processed_source)
|
|
24
|
-
process_node(processed_source, processed_source.ast)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def autocorrect(_processed_source, offense)
|
|
28
|
-
lambda do |corrector|
|
|
29
|
-
corrector.replace(offense.source_range, offense.context[:new_value])
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
##============================================================##
|
|
36
|
-
## Recursively process all nodes in the AST
|
|
37
|
-
##============================================================##
|
|
38
|
-
def process_node(processed_source, node)
|
|
39
|
-
return unless node
|
|
40
|
-
|
|
41
|
-
##============================================================##
|
|
42
|
-
## Check attribute values for multiple spaces
|
|
43
|
-
##============================================================##
|
|
44
|
-
if node.respond_to?(:type) && node.type == :attribute_value
|
|
45
|
-
value_source = node.loc.source
|
|
46
|
-
if value_source.match?(/ +/)
|
|
47
|
-
normalized = value_source.gsub(/ +/, " ")
|
|
48
|
-
range = processed_source.to_source_range(node.loc.begin_pos...node.loc.end_pos)
|
|
49
|
-
add_offense(range, MSG, {:new_value => normalized})
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
##============================================================##
|
|
54
|
-
## Recurse into children
|
|
55
|
-
##============================================================##
|
|
56
|
-
return unless node.respond_to?(:children)
|
|
57
|
-
|
|
58
|
-
node.children.each {|child| process_node(processed_source, child) }
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|