haml_lint 0.37.1 → 0.40.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 +4 -4
- data/lib/haml_lint/cli.rb +1 -1
- data/lib/haml_lint/configuration.rb +3 -3
- data/lib/haml_lint/linter/rubocop.rb +2 -2
- data/lib/haml_lint/linter/space_before_script.rb +1 -1
- data/lib/haml_lint/linter/space_inside_hash_attributes.rb +5 -5
- data/lib/haml_lint/linter_selector.rb +1 -1
- data/lib/haml_lint/options.rb +2 -2
- data/lib/haml_lint/reporter/offense_count_reporter.rb +33 -0
- data/lib/haml_lint/reporter.rb +7 -1
- data/lib/haml_lint/utils.rb +1 -1
- data/lib/haml_lint/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ef9ca7cc6bbd3b5f9663a2bda75669062b25efeb53af9e32cf152fd7f5aee6c
|
4
|
+
data.tar.gz: 35e34d39d55e13910ec90f9ee7ece9a4baa2d6bc44f2f6962b230f6387519174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 376df9f9c0de3c0949bd2187bb1ba9f3bc5e381644a93c827ca085125ac2922f59f98d048d8bf548b379ebe5def5180f9b182628030f4e66454f3edf71478f9f
|
7
|
+
data.tar.gz: fa1a9ad202224e1059dd7802b1aea08db8b9d11570feca891a31650dc3b10f0b991b2585ad27faa4425bc2165a2b23e799075c944250a43568e1d17c7f83f8b1
|
data/lib/haml_lint/cli.rb
CHANGED
@@ -94,7 +94,7 @@ module HamlLint
|
|
94
94
|
# @return [HamlLint::Reporter]
|
95
95
|
def reporter_from_options(options)
|
96
96
|
if options[:auto_gen_config]
|
97
|
-
HamlLint::Reporter::DisabledConfigReporter.new(log, limit: options[:auto_gen_exclude_limit] || 15)
|
97
|
+
HamlLint::Reporter::DisabledConfigReporter.new(log, limit: options[:auto_gen_exclude_limit] || 15)
|
98
98
|
else
|
99
99
|
options.fetch(:reporter, HamlLint::Reporter::DefaultReporter).new(log)
|
100
100
|
end
|
@@ -97,7 +97,7 @@ module HamlLint
|
|
97
97
|
def validate
|
98
98
|
ensure_exclude_option_array_exists
|
99
99
|
ensure_linter_section_exists
|
100
|
-
|
100
|
+
ensure_linter_include_exclude_arrays_valid
|
101
101
|
ensure_linter_severity_valid
|
102
102
|
end
|
103
103
|
|
@@ -113,11 +113,11 @@ module HamlLint
|
|
113
113
|
|
114
114
|
# Ensure `include` and `exclude` options for linters are arrays
|
115
115
|
# (since users can specify a single string glob pattern for convenience)
|
116
|
-
def
|
116
|
+
def ensure_linter_include_exclude_arrays_valid
|
117
117
|
@hash['linters'].each_key do |linter_name|
|
118
118
|
%w[include exclude].each do |option|
|
119
119
|
linter_config = @hash['linters'][linter_name]
|
120
|
-
linter_config[option] = Array(linter_config[option])
|
120
|
+
linter_config[option] = Array(linter_config[option]) if linter_config[option]
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -27,8 +27,6 @@ module HamlLint
|
|
27
27
|
find_lints(extracted_source.source, extracted_source.source_map)
|
28
28
|
end
|
29
29
|
|
30
|
-
private
|
31
|
-
|
32
30
|
# A single CLI instance is shared between files to avoid RuboCop
|
33
31
|
# having to repeatedly reload .rubocop.yml.
|
34
32
|
def self.rubocop_cli
|
@@ -37,6 +35,8 @@ module HamlLint
|
|
37
35
|
@rubocop_cli ||= ::RuboCop::CLI.new
|
38
36
|
end
|
39
37
|
|
38
|
+
private
|
39
|
+
|
40
40
|
# Executes RuboCop against the given Ruby code and records the offenses as
|
41
41
|
# lints.
|
42
42
|
#
|
@@ -9,7 +9,7 @@ module HamlLint
|
|
9
9
|
|
10
10
|
ALLOWED_SEPARATORS = [' ', '#'].freeze
|
11
11
|
|
12
|
-
def visit_tag(node) # rubocop:disable Metrics/
|
12
|
+
def visit_tag(node) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
13
13
|
# If this tag has inline script
|
14
14
|
return unless node.contains_script?
|
15
15
|
|
@@ -9,15 +9,15 @@ module HamlLint
|
|
9
9
|
STYLE = {
|
10
10
|
'no_space' => {
|
11
11
|
start_regex: /\A\{[^ ]/,
|
12
|
-
end_regex: /[^ ]\}\z/,
|
12
|
+
end_regex: /(?:^\s*\}|[^ ]\})\z/,
|
13
13
|
start_message: 'Hash attribute should start with no space after the opening brace',
|
14
|
-
end_message: 'Hash attribute should end with no space before the closing brace'
|
14
|
+
end_message: 'Hash attribute should end with no space before the closing brace or be on its own line'
|
15
15
|
},
|
16
16
|
'space' => {
|
17
|
-
start_regex: /\A\{ [^ ]/,
|
18
|
-
end_regex: /[^ ] \}\z/,
|
17
|
+
start_regex: /\A\{(?: [^ ]|$)/,
|
18
|
+
end_regex: /(?:^\s*\}|[^ ] \})\z/,
|
19
19
|
start_message: 'Hash attribute should start with one space after the opening brace',
|
20
|
-
end_message: 'Hash attribute should end with one space before the closing brace'
|
20
|
+
end_message: 'Hash attribute should end with one space before the closing brace or be on its own line'
|
21
21
|
}
|
22
22
|
}.freeze
|
23
23
|
|
@@ -64,7 +64,7 @@ module HamlLint
|
|
64
64
|
def run_linter_on_file?(config, linter, file)
|
65
65
|
linter_config = config.for_linter(linter)
|
66
66
|
|
67
|
-
if linter_config['include']
|
67
|
+
if linter_config['include'] &&
|
68
68
|
!HamlLint::Utils.any_glob_matches?(linter_config['include'], file)
|
69
69
|
return false
|
70
70
|
end
|
data/lib/haml_lint/options.rb
CHANGED
@@ -38,7 +38,7 @@ module HamlLint
|
|
38
38
|
end
|
39
39
|
|
40
40
|
parser.on('--auto-gen-exclude-limit limit', Integer,
|
41
|
-
'Number of failures to allow in the TODO list before the entire rule is excluded') do |limit|
|
41
|
+
'Number of failures to allow in the TODO list before the entire rule is excluded') do |limit|
|
42
42
|
@options[:auto_gen_exclude_limit] = limit
|
43
43
|
end
|
44
44
|
|
@@ -62,7 +62,7 @@ module HamlLint
|
|
62
62
|
parser.on('-r', '--reporter reporter', String,
|
63
63
|
'Specify which reporter you want to use to generate the output. One of:',
|
64
64
|
*reporters.map { |name| " - #{name}" }) do |reporter|
|
65
|
-
@options[:reporter] = load_reporter_class(reporter.capitalize)
|
65
|
+
@options[:reporter] = load_reporter_class(reporter.split('-').map(&:capitalize).join)
|
66
66
|
end
|
67
67
|
|
68
68
|
parser.on('--fail-fast', 'Fail after the first file with lint at or above the fail level') do
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
module HamlLint
|
4
|
+
# Outputs the a list of lints with a count of how many of each were found.
|
5
|
+
# Ordered by descending count
|
6
|
+
class Reporter::OffenseCountReporter < Reporter
|
7
|
+
def display_report(report)
|
8
|
+
lints = report.lints
|
9
|
+
total_count = lints.count
|
10
|
+
return if total_count.zero?
|
11
|
+
|
12
|
+
lints.group_by { |l| lint_type_group(l) }
|
13
|
+
.map { |linter, lints_for_this_linter| [linter, lints_for_this_linter.size] }.to_h
|
14
|
+
.sort_by { |_linter, lint_count| -lint_count }
|
15
|
+
.each do |linter, lint_count|
|
16
|
+
log.log "#{lint_count.to_s.ljust(total_count.to_s.length + 2)} #{linter}"
|
17
|
+
end
|
18
|
+
|
19
|
+
log.log '--'
|
20
|
+
log.log "#{total_count} Total"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def lint_type_group(lint)
|
26
|
+
"#{lint.linter.name}#{offense_type(lint)}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def offense_type(lint)
|
30
|
+
": #{lint.message.to_s.split(':')[0]}" if lint.linter.name == 'RuboCop'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/haml_lint/reporter.rb
CHANGED
@@ -32,7 +32,13 @@ module HamlLint
|
|
32
32
|
#
|
33
33
|
# @return [String]
|
34
34
|
def self.cli_name
|
35
|
-
name
|
35
|
+
name
|
36
|
+
.split('::')
|
37
|
+
.last
|
38
|
+
.sub(/Reporter$/, '')
|
39
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1-\2')
|
40
|
+
.gsub(/([a-z\d])([A-Z])/, '\1-\2')
|
41
|
+
.downcase
|
36
42
|
end
|
37
43
|
|
38
44
|
# Creates the reporter that will display the given report.
|
data/lib/haml_lint/utils.rb
CHANGED
@@ -52,7 +52,7 @@ module HamlLint
|
|
52
52
|
# the text.
|
53
53
|
# @yieldparam interpolated_code [String] code that was interpolated
|
54
54
|
# @yieldparam line [Integer] line number code appears on in text
|
55
|
-
def extract_interpolated_values(text)
|
55
|
+
def extract_interpolated_values(text)
|
56
56
|
dumped_text = text.dump
|
57
57
|
newline_positions = extract_substring_positions(dumped_text, '\\\n')
|
58
58
|
|
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.40.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:
|
11
|
+
date: 2022-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/haml_lint/reporter/hash_reporter.rb
|
159
159
|
- lib/haml_lint/reporter/hooks.rb
|
160
160
|
- lib/haml_lint/reporter/json_reporter.rb
|
161
|
+
- lib/haml_lint/reporter/offense_count_reporter.rb
|
161
162
|
- lib/haml_lint/reporter/progress_reporter.rb
|
162
163
|
- lib/haml_lint/reporter/utils.rb
|
163
164
|
- lib/haml_lint/ruby_extractor.rb
|
@@ -185,7 +186,7 @@ homepage: https://github.com/sds/haml-lint
|
|
185
186
|
licenses:
|
186
187
|
- MIT
|
187
188
|
metadata: {}
|
188
|
-
post_install_message:
|
189
|
+
post_install_message:
|
189
190
|
rdoc_options: []
|
190
191
|
require_paths:
|
191
192
|
- lib
|
@@ -200,8 +201,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
201
|
- !ruby/object:Gem::Version
|
201
202
|
version: '0'
|
202
203
|
requirements: []
|
203
|
-
rubygems_version: 3.1.
|
204
|
-
signing_key:
|
204
|
+
rubygems_version: 3.1.6
|
205
|
+
signing_key:
|
205
206
|
specification_version: 4
|
206
207
|
summary: HAML lint tool
|
207
208
|
test_files: []
|