haml_lint 0.52.0 → 0.53.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: 24f37fc2b314359fb58b5209e58399fa01f53d51c977a4c60b66d9497e2acde5
4
- data.tar.gz: afb033a6021882a269ec1fdf989d06c83c6df8047a3f60233ac83ac9f234469d
3
+ metadata.gz: 49bb0bec15e96c047439560e80f83eaf6f4c3baec24a12b1f10248f1d2f347d3
4
+ data.tar.gz: 153f65eda76c5751bbae1d02fc49d0d4477f401bb273096ad9308868b9d21288
5
5
  SHA512:
6
- metadata.gz: abb4758509d1aca40826e598c8d1bdfb7daffbbbeb9d1955c18463e44c4799ce5102151ae34b58799198336d87ba2c4e922a699b8f9c28b13f94479d80f4607a
7
- data.tar.gz: f585fb701da7d6ca46ab9612055a25be83c640c97da530fa19ca20684e27056955ca80714a666fef1568fb8fa4bceba5830005167b3f4a76dc575732876d125e
6
+ metadata.gz: a4d2c2682e7b12d9aaf8164054f3533c0667f5f6035bfbf5ef6bbb694a40f9a70d9d13a9aa56dabf27131be27e74d346c9eff642a65d0e2aac8992ebc1999fba
7
+ data.tar.gz: 343aee9ed9bf4a766640aabbbaf96af9a5c36261fb6e6943b9a0b9eadcb5c75bc5a15665cae30c3c4c8925b307ecca837130fb04cf1d14a74549978db235f60c
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'haml_lint/adapter/haml_4'
4
3
  require 'haml_lint/adapter/haml_5'
5
4
  require 'haml_lint/adapter/haml_6'
6
5
  require 'haml_lint/exceptions'
@@ -19,7 +18,6 @@ module HamlLint
19
18
  def self.detect_class
20
19
  version = haml_version
21
20
  case version
22
- when '~> 4.0' then HamlLint::Adapter::Haml4
23
21
  when '~> 5.0', '~> 5.1', '~> 5.2' then HamlLint::Adapter::Haml5
24
22
  when '~> 6.0', '~> 6.0.a', '~> 6.1', '~> 6.2', '~> 6.3' then HamlLint::Adapter::Haml6
25
23
  else fail HamlLint::Exceptions::UnknownHamlVersion, "Cannot handle Haml version: #{version}"
@@ -84,7 +84,35 @@ module HamlLint::RubyExtraction
84
84
  def visit_comment(node)
85
85
  line = @original_haml_lines[node.line - 1]
86
86
  indent = line.index(/\S/)
87
+
87
88
  @ruby_chunks << PlaceholderMarkerChunk.new(node, 'comment', indent: indent)
89
+
90
+ # Comment can have subnodes, such as plain. This happens for conditional comments, such as:
91
+ # %head
92
+ # /[if mso]
93
+ # %div
94
+ if node.children
95
+ # We don't want to use a block because assignments in a block are local to that block,
96
+ # so the semantics of the extracted ruby would be different from the one generated by
97
+ # Haml. Those differences can make some cops, such as UselessAssignment, have false
98
+ # positives
99
+ begin_chunk = AdHocChunk.new(node, [' ' * indent + 'begin'])
100
+ @ruby_chunks << begin_chunk
101
+ indent += 2
102
+
103
+ yield
104
+
105
+ indent -= 2
106
+
107
+ if @ruby_chunks.last.equal?(begin_chunk)
108
+ # So there is nothing nesting, remove the wrapping "begin"
109
+ @ruby_chunks.pop
110
+ else
111
+ @ruby_chunks << AdHocChunk.new(node,
112
+ [' ' * indent + 'ensure', ' ' * indent + ' HL.noop', ' ' * indent + 'end'],
113
+ haml_line_index: @ruby_chunks.last.haml_end_line_index)
114
+ end
115
+ end
88
116
  end
89
117
 
90
118
  # Visit a script which outputs. Lines looking like ` = foo`
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module HamlLint
5
- VERSION = '0.52.0'
5
+ VERSION = '0.53.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.52.0
4
+ version: 0.53.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: 2023-12-13 00:00:00.000000000 Z
11
+ date: 2024-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: parallel
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -93,7 +93,6 @@ files:
93
93
  - config/forced_rubocop_config.yml
94
94
  - lib/haml_lint.rb
95
95
  - lib/haml_lint/adapter.rb
96
- - lib/haml_lint/adapter/haml_4.rb
97
96
  - lib/haml_lint/adapter/haml_5.rb
98
97
  - lib/haml_lint/adapter/haml_6.rb
99
98
  - lib/haml_lint/cli.rb
@@ -200,7 +199,7 @@ homepage: https://github.com/sds/haml-lint
200
199
  licenses:
201
200
  - MIT
202
201
  metadata: {}
203
- post_install_message:
202
+ post_install_message:
204
203
  rdoc_options: []
205
204
  require_paths:
206
205
  - lib
@@ -215,8 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
214
  - !ruby/object:Gem::Version
216
215
  version: '0'
217
216
  requirements: []
218
- rubygems_version: 3.1.6
219
- signing_key:
217
+ rubygems_version: 3.0.3.1
218
+ signing_key:
220
219
  specification_version: 4
221
220
  summary: HAML lint tool
222
221
  test_files: []
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'forwardable'
4
-
5
- module HamlLint
6
- class Adapter
7
- # Adapts the Haml::Parser from Haml 4 for use in HamlLint
8
- # :reek:UncommunicativeModuleName
9
- class Haml4 < Adapter
10
- extend Forwardable
11
-
12
- # Parses the specified Haml code into an abstract syntax tree
13
- #
14
- # @example
15
- # HamlLint::Adapter::Haml4.new('%div')
16
- #
17
- # @api public
18
- # @param source [String] Haml code to parse
19
- # @param options [Haml::Options]
20
- def initialize(source, options = Haml::Options.new)
21
- @source = source
22
- @parser = Haml::Parser.new(source, options)
23
- end
24
-
25
- def precompile
26
- # Haml uses the filters as part of precompilation... we don't care about those,
27
- # but without this tweak, it would fail on filters that are not loaded.
28
- real_defined = Haml::Filters.defined
29
- Haml::Filters.instance_variable_set(:@defined, Hash.new { real_defined['plain'] })
30
-
31
- ::Haml::Engine.new(source).precompiled
32
- ensure
33
- Haml::Filters.instance_variable_set(:@defined, real_defined)
34
- end
35
-
36
- # @!method
37
- # Parses the source code into an abstract syntax tree
38
- #
39
- # @example
40
- # HamlLint::Adapter::Haml4.new('%div')
41
- #
42
- # @api public
43
- # @return [Haml::Parser::ParseNode]
44
- # @raise [Haml::Error]
45
- def_delegator :parser, :parse
46
-
47
- private
48
-
49
- # The Haml parser to adapt for HamlLint
50
- #
51
- # @api private
52
- # @return [Haml::Parser] the Haml 4 parser
53
- attr_reader :parser
54
-
55
- # The Haml code to parse
56
- #
57
- # @api private
58
- # @return [String] Haml code to parse
59
- attr_reader :source
60
- end
61
- end
62
- end