haml_lint 0.57.0 → 0.58.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '092e548aae63e23d9c6a5c3c11087590219e52792459ee548a5802503e80f6ec'
4
- data.tar.gz: 120a88fbfb5b78e5d08724dffc9c7cf22292e391633c780da94161295ea745e0
3
+ metadata.gz: 6962d4b0d9f7f60b473641303f1ef1b8962797bf7abdeb8db4e57b36df65f7d3
4
+ data.tar.gz: 214c0ccb902d9c742af8df5f4e65fc221f6ae9bec572b7a535df0ee682b5dfac
5
5
  SHA512:
6
- metadata.gz: 5123d876bb4b79d4fbf14fae8acef295993c909baaee63975f899571fe450cf67f503c761b2628ddb96874f39a4be51a8c489ddb94a87eb95034e3a05ba44431
7
- data.tar.gz: 152d02d1daa2f51e9c0ddca5602d74642b324e860daa33aeec715ff4e2be297054abaf0d35dd9d15cfafcf15955bfce48823575643b18c4375707f172621eb66
6
+ metadata.gz: b161dc044d6a5a22be918384f7cde7b0fd9b20dc2f4408f4a535ae72ed0b7fab75b96f885db83e92ae4cce769b811118978412bbba819e6f38178fb261f040f1
7
+ data.tar.gz: fb2af5b891147f8588cf9ffcd17fccc7ef0674bf11127327addbca55c9a8c094c6e53f8f268550dc160955d4c1c889948d7285fc39027287781d3abba7f66873
@@ -6,7 +6,7 @@ module HamlLint
6
6
  include LinterRegistry
7
7
 
8
8
  def visit_silent_script(node)
9
- return unless node.script =~ /\A\s*\Z/
9
+ return unless /\A\s*\Z/.match?(node.script)
10
10
 
11
11
  record_lint(node, 'Empty script should be removed')
12
12
  end
@@ -24,7 +24,7 @@ module HamlLint
24
24
 
25
25
  style = config['style'] || 'lisp_case'
26
26
  matcher = STYLES[style]
27
- record_lint(node, "`id` attribute must be in #{STYLIZED_NAMES[style]}") unless id =~ matcher
27
+ record_lint(node, "`id` attribute must be in #{STYLIZED_NAMES[style]}") unless id&.match?(matcher)
28
28
  end
29
29
  end
30
30
  end
@@ -30,7 +30,7 @@ module HamlLint
30
30
  dummy_node = Struct.new(:line)
31
31
 
32
32
  document.source_lines.each_with_index do |line, index|
33
- next if line =~ regex
33
+ next if line&.match?(regex)
34
34
 
35
35
  unless root.node_for_line(index).disabled?(self)
36
36
  record_lint dummy_node.new(index + 1), "Line contains #{wrong_characters} in indentation"
@@ -8,7 +8,7 @@ module HamlLint
8
8
  def visit_haml_comment(node)
9
9
  # Skip if the node spans multiple lines starting on the second line,
10
10
  # or starts with a space
11
- return if node.text =~ /\A#*(\s*|\s+\S.*)$/
11
+ return if /\A#*(\s*|\s+\S.*)$/.match?(node.text)
12
12
 
13
13
  record_lint(node, 'Comment should have a space after the `#`')
14
14
  end
@@ -27,8 +27,8 @@ module HamlLint
27
27
  style = STYLE[config['style'] == 'no_space' ? 'no_space' : 'space']
28
28
  source = node.hash_attributes_source
29
29
 
30
- record_lint(node, style[:start_message]) unless source =~ style[:start_regex]
31
- record_lint(node, style[:end_message]) unless source =~ style[:end_regex]
30
+ record_lint(node, style[:start_message]) unless source&.match?(style[:start_regex])
31
+ record_lint(node, style[:end_message]) unless source&.match?(style[:end_regex])
32
32
  end
33
33
  end
34
34
  end
@@ -7,7 +7,7 @@ module HamlLint
7
7
 
8
8
  def visit_tag(node)
9
9
  tag = node.tag_name
10
- return unless tag =~ /[A-Z]/
10
+ return unless /[A-Z]/.match?(tag)
11
11
 
12
12
  record_lint(node, "`#{tag}` should be written in lowercase as `#{tag.downcase}`")
13
13
  end
@@ -9,7 +9,7 @@ module HamlLint
9
9
 
10
10
  def visit_root(root)
11
11
  document.source_lines.each_with_index do |line, index|
12
- next unless line =~ /\s+$/
12
+ next unless /\s+$/.match?(line)
13
13
 
14
14
  node = root.node_for_line(index + 1)
15
15
  unless node.disabled?(self)
@@ -22,7 +22,7 @@ module HamlLint
22
22
  def visit_script(node)
23
23
  # Some script nodes created by the HAML parser aren't actually script
24
24
  # nodes declared via the `=` marker. Check for it.
25
- return if node.source_code !~ /\A\s*=/
25
+ return unless /\A\s*=/.match?(node.source_code)
26
26
 
27
27
  if outputs_string_literal?(node)
28
28
  record_lint(node, MESSAGE)
@@ -37,7 +37,7 @@ module HamlLint
37
37
  :error
38
38
  )
39
39
  rescue StandardError => e
40
- msg = "Couldn't process the file".dup
40
+ msg = +"Couldn't process the file"
41
41
  if @autocorrect
42
42
  # Those lints related to auto-correction were not saved, so don't display them
43
43
  @lints = []
@@ -231,7 +231,7 @@ module HamlLint
231
231
  # excess whitespace
232
232
  @document.source_lines[(tag_node.line - 1)...(following_node_line(tag_node) - 1)]
233
233
  .map do |line|
234
- line.strip.gsub(/\|\z/, '').rstrip
234
+ line.strip.delete_suffix('|').rstrip
235
235
  end.join(' ')
236
236
  end
237
237
  end
@@ -17,6 +17,10 @@ module HamlLint::RubyExtraction
17
17
  ::Haml::Parser.new('', {})
18
18
  end
19
19
 
20
+ # HAML strips newlines when handling multi-line statements (using pipes or trailing comma)
21
+ # We don't. So the regex must be fixed to correctly detect the start of the string.
22
+ BLOCK_KEYWORD_REGEX = Regexp.new(Haml::Parser::BLOCK_KEYWORD_REGEX.source.sub('^', '\A'))
23
+
20
24
  def initialize(document, script_output_prefix:)
21
25
  @document = document
22
26
  @script_output_prefix = script_output_prefix
@@ -390,7 +394,7 @@ module HamlLint::RubyExtraction
390
394
  # is indented by 0.
391
395
  lines = node.text.split("\n")
392
396
  lines.map! do |line|
393
- if line !~ /\S/
397
+ if !/\S/.match?(line)
394
398
  # whitespace or empty
395
399
  ''
396
400
  else
@@ -546,7 +550,7 @@ module HamlLint::RubyExtraction
546
550
  joined_lines = lines.join("\n")
547
551
 
548
552
  if haml_processed_ruby_code.include?("\n")
549
- haml_processed_ruby_code = haml_processed_ruby_code.gsub("\n", ' ')
553
+ haml_processed_ruby_code = haml_processed_ruby_code.tr("\n", ' ')
550
554
  end
551
555
 
552
556
  haml_processed_ruby_code.split(/[, ]/)
@@ -692,7 +696,7 @@ module HamlLint::RubyExtraction
692
696
  return keyword
693
697
  end
694
698
 
695
- return unless keyword = code.scan(Haml::Parser::BLOCK_KEYWORD_REGEX)[0]
699
+ return unless keyword = code.scan(BLOCK_KEYWORD_REGEX)[0]
696
700
  keyword[0] || keyword[1]
697
701
  end
698
702
  end
@@ -14,7 +14,7 @@ module HamlLint::RubyExtraction
14
14
  to_content_lines = to_ruby_lines[1...-1]
15
15
 
16
16
  to_haml_lines = to_content_lines.map do |line|
17
- if line !~ /\S/
17
+ if !/\S/.match?(line)
18
18
  # whitespace or empty
19
19
  ''
20
20
  else
@@ -19,7 +19,7 @@ module HamlLint::RubyExtraction
19
19
  haml_lines[@haml_line_index - 1] = HamlLint::Utils.indent(haml_lines[@haml_line_index - 1], delta_indent)
20
20
 
21
21
  to_haml_lines = to_ruby_lines.map do |line|
22
- if line !~ /\S/
22
+ if !/\S/.match?(line)
23
23
  # whitespace or empty
24
24
  ''
25
25
  else
@@ -113,7 +113,7 @@ module HamlLint::RubyExtraction
113
113
  line_start_indexes_that_need_pipes = []
114
114
  haml_output_prefix = first_output_haml_prefix
115
115
  to_haml_lines = to_ruby_lines.map.with_index do |line, i| # rubocop:disable Metrics/BlockLength
116
- if line !~ /\S/
116
+ if !/\S/.match?(line)
117
117
  # whitespace or empty lines, we don't want any indentation
118
118
  ''
119
119
  elsif statement_start_line_indexes.include?(i)
@@ -74,7 +74,7 @@ module HamlLint
74
74
  current_matching_line = 1
75
75
  @source_map = {}
76
76
  lines.each.with_index do |line, i|
77
- next unless line =~ /\S/
77
+ next unless /\S/.match?(line)
78
78
  mo = line.match(/^(.*?)\$?\s*\$\$(\d+)$/)
79
79
  if mo
80
80
  lines[i] = mo[1]
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module HamlLint
5
- VERSION = '0.57.0'
5
+ VERSION = '0.58.0'
6
6
  end
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.57.0
4
+ version: 0.58.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-13 00:00:00.000000000 Z
11
+ date: 2024-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  - !ruby/object:Gem::Version
217
217
  version: '0'
218
218
  requirements: []
219
- rubygems_version: 3.4.10
219
+ rubygems_version: 3.5.9
220
220
  signing_key:
221
221
  specification_version: 4
222
222
  summary: HAML lint tool