haml_lint 0.55.0 → 0.56.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0bb69db6857a5c9b072203e93e4c9964bd60a9f8e4f1024e4db31453deec8a6
|
4
|
+
data.tar.gz: 94fcce12ae043e72f638d532fcddccfad2de1c8af33a261c37920fa738c4609e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 973dd46634cfde27066acfcd5d44bebc538716f7ca0d34114b183c19808513fc397b688a66664f6bf1b5ae0367762d4daa7f203d894cd3eb068bcbcfdc12edc5
|
7
|
+
data.tar.gz: ac57887f196f37a3f2f40b77cc5c1e24dd2b29bc29a9d693fc4a675a69ced56f4a49386e2e7a8694cfa04ecbb3ac75bb4fb412c760a0a9fe83d2d20b7bdef40a
|
@@ -247,31 +247,29 @@ module HamlLint::RubyExtraction
|
|
247
247
|
def visit_tag(node)
|
248
248
|
indent = @original_haml_lines[node.line - 1].index(/\S/)
|
249
249
|
|
250
|
+
@ruby_chunks << PlaceholderMarkerChunk.new(node, 'tag', indent: indent)
|
251
|
+
|
252
|
+
current_line_index = visit_tag_attributes(node, indent: indent)
|
253
|
+
visit_tag_script(node, line_index: current_line_index, indent: indent)
|
254
|
+
|
250
255
|
# We don't want to use a block because assignments in a block are local to that block,
|
251
256
|
# so the semantics of the extracted ruby would be different from the one generated by
|
252
257
|
# Haml. Those differences can make some cops, such as UselessAssignment, have false
|
253
258
|
# positives
|
254
259
|
code = 'begin'
|
255
|
-
|
256
|
-
|
257
|
-
indent += 2
|
258
|
-
|
259
|
-
tag_chunk = PlaceholderMarkerChunk.new(node, 'tag', indent: indent)
|
260
|
-
@ruby_chunks << tag_chunk
|
260
|
+
begin_chunk = AdHocChunk.new(node, [' ' * indent + code])
|
261
|
+
@ruby_chunks << begin_chunk
|
261
262
|
|
262
|
-
|
263
|
-
visit_tag_script(node, line_index: current_line_index, indent: indent)
|
263
|
+
indent += 2
|
264
264
|
|
265
265
|
yield
|
266
266
|
|
267
267
|
indent -= 2
|
268
268
|
|
269
|
-
if @ruby_chunks.last.equal?(
|
269
|
+
if @ruby_chunks.last.equal?(begin_chunk)
|
270
270
|
# So there is nothing going "in" the tag, remove the wrapping "begin" and replace the PlaceholderMarkerChunk
|
271
271
|
# by one less indented
|
272
272
|
@ruby_chunks.pop
|
273
|
-
@ruby_chunks.pop
|
274
|
-
@ruby_chunks << PlaceholderMarkerChunk.new(node, 'tag', indent: indent)
|
275
273
|
else
|
276
274
|
@ruby_chunks << AdHocChunk.new(node,
|
277
275
|
[' ' * indent + 'ensure', ' ' * indent + ' HL.noop', ' ' * indent + 'end'],
|
@@ -600,9 +598,12 @@ module HamlLint::RubyExtraction
|
|
600
598
|
return [char_index, [haml_processed_ruby_code]]
|
601
599
|
end
|
602
600
|
|
603
|
-
|
601
|
+
# The +1 is for the closing brace, which we need
|
602
|
+
min_non_white_chars_to_add = haml_processed_ruby_code.scan(/\S/).size + 1
|
604
603
|
|
605
|
-
regexp = HamlLint::Utils.regexp_for_parts(
|
604
|
+
regexp = HamlLint::Utils.regexp_for_parts(
|
605
|
+
haml_processed_ruby_code.split(/\s+/), '\\s+', prefix: '\s*', suffix: '\s*(?=[)}])'
|
606
|
+
)
|
606
607
|
|
607
608
|
joined_lines = first_line.rstrip
|
608
609
|
process_multiline!(joined_lines)
|
@@ -624,7 +625,7 @@ module HamlLint::RubyExtraction
|
|
624
625
|
|
625
626
|
first_line_offset = match.begin(0)
|
626
627
|
raw_ruby = match[0]
|
627
|
-
ruby_lines = raw_ruby.split("\n")
|
628
|
+
ruby_lines = raw_ruby.split("\n", -1)
|
628
629
|
|
629
630
|
[first_line_offset, ruby_lines]
|
630
631
|
end
|
@@ -115,7 +115,7 @@ module HamlLint
|
|
115
115
|
|
116
116
|
syntax_lints = subject.lints.select { |lint| lint.message =~ %r{Lint/Syntax} }
|
117
117
|
|
118
|
-
if start_ruby.strip != 'SKIP' && subject.last_extracted_source
|
118
|
+
if start_ruby.strip != 'SKIP' && subject.last_extracted_source && ENV['UPDATE_EXAMPLES'] != '1'
|
119
119
|
matcher = eq(start_ruby)
|
120
120
|
subject.last_extracted_source.source.should(
|
121
121
|
matcher,
|
@@ -125,7 +125,7 @@ module HamlLint
|
|
125
125
|
|
126
126
|
syntax_lints.should(be_empty, "Generated Ruby has Syntax Lints:\n#{format_lints(syntax_lints)}")
|
127
127
|
|
128
|
-
if end_ruby.strip != 'SKIP' && subject.last_new_ruby_source
|
128
|
+
if end_ruby.strip != 'SKIP' && subject.last_new_ruby_source && ENV['UPDATE_EXAMPLES'] != '1'
|
129
129
|
matcher = eq(end_ruby)
|
130
130
|
subject.last_new_ruby_source.should(
|
131
131
|
matcher,
|
@@ -141,10 +141,40 @@ module HamlLint
|
|
141
141
|
-> { "Final HAML is different from expected. #{matcher.failure_message}\n#{format_lints}" }
|
142
142
|
)
|
143
143
|
|
144
|
-
if subject.last_extracted_source && start_ruby.strip != 'SKIP'
|
144
|
+
if subject.last_extracted_source && start_ruby.strip != 'SKIP' && ENV['UPDATE_EXAMPLES'] != '1'
|
145
145
|
subject.last_extracted_source.source_map.should == source_map
|
146
146
|
end
|
147
147
|
|
148
|
+
if ENV['UPDATE_EXAMPLES'] == '1' && respond_to?(:example_first_line_no) &&
|
149
|
+
start_ruby.strip != 'SKIP' && end_ruby.strip != 'SKIP'
|
150
|
+
original_content = File.read(example_path)
|
151
|
+
old_steps_string = '---' + steps_string.partition('---').last.rpartition('---').first + '---'
|
152
|
+
|
153
|
+
if old_steps_string.scan(/\$\$\d+/).tally.values.any? { |v| v > 1 }
|
154
|
+
# If the $$3 was there twice, let's not update the example
|
155
|
+
return
|
156
|
+
end
|
157
|
+
original_content.scan(old_steps_string).count
|
158
|
+
|
159
|
+
new_generated_ruby_lines = subject.last_extracted_source.source.split("\n", -1)
|
160
|
+
last_seen_haml_line_no = 1
|
161
|
+
subject.last_extracted_source.source_map.each do |ruby_line_no, haml_line_no|
|
162
|
+
if haml_line_no != last_seen_haml_line_no
|
163
|
+
last_seen_haml_line_no = haml_line_no
|
164
|
+
new_generated_ruby_lines[ruby_line_no - 1] += " $$#{haml_line_no}"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
new_steps_string = <<~NEW.chop # Chop to remove the added newlines
|
169
|
+
---
|
170
|
+
#{new_generated_ruby_lines.join("\n")}---
|
171
|
+
#{subject.last_new_ruby_source}---
|
172
|
+
NEW
|
173
|
+
|
174
|
+
new_content = original_content.gsub(old_steps_string, new_steps_string)
|
175
|
+
File.write(example_path, new_content)
|
176
|
+
end
|
177
|
+
|
148
178
|
haml_different = start_haml != end_haml
|
149
179
|
document.source_was_changed.should == haml_different
|
150
180
|
end
|
data/lib/haml_lint/utils.rb
CHANGED
@@ -277,8 +277,9 @@ module HamlLint
|
|
277
277
|
$stdin = original_stdin
|
278
278
|
end
|
279
279
|
|
280
|
-
def regexp_for_parts(parts, join_regexp)
|
280
|
+
def regexp_for_parts(parts, join_regexp, prefix: nil, suffix: nil)
|
281
281
|
regexp_code = parts.map { |c| Regexp.quote(c) }.join(join_regexp)
|
282
|
+
regexp_code = "#{prefix}#{regexp_code}#{suffix}"
|
282
283
|
Regexp.new(regexp_code)
|
283
284
|
end
|
284
285
|
end
|
data/lib/haml_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.56.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -200,7 +200,7 @@ homepage: https://github.com/sds/haml-lint
|
|
200
200
|
licenses:
|
201
201
|
- MIT
|
202
202
|
metadata: {}
|
203
|
-
post_install_message:
|
203
|
+
post_install_message:
|
204
204
|
rdoc_options: []
|
205
205
|
require_paths:
|
206
206
|
- lib
|
@@ -215,8 +215,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '0'
|
217
217
|
requirements: []
|
218
|
-
rubygems_version: 3.
|
219
|
-
signing_key:
|
218
|
+
rubygems_version: 3.4.10
|
219
|
+
signing_key:
|
220
220
|
specification_version: 4
|
221
221
|
summary: HAML lint tool
|
222
222
|
test_files: []
|