haml_lint 0.36.0 → 0.39.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/config/default.yml +1 -0
- data/lib/haml_lint/cli.rb +1 -1
- data/lib/haml_lint/configuration.rb +3 -3
- data/lib/haml_lint/linter/rubocop.rb +9 -3
- data/lib/haml_lint/linter/space_before_script.rb +1 -1
- 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 +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9b35d2560a3a069ba7c72c9d0729dd3123248fdf3f4d9767eb10cac347141c1
|
4
|
+
data.tar.gz: 54d62f683b3b7e5a72572f8de7c7ffe45cc21e6f1de597f1cedd085c7b175154
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c28755b6e79b1fc038f89ec6e90f18568c9c55bec73909dc526f331e484d1273cf5d6d037ca44970eeafcde15c7a93df4990ea157a1ffc7f42ff902a72848fc
|
7
|
+
data.tar.gz: e6ddfe5ff416b4cb04d47ecb80a212a97979f52dd2d82f449e65548b6bbab588eb04bafb01c4e61b757ebe168db47ab4d77b9bbdd9b70d1b439f02dae273c82c
|
data/config/default.yml
CHANGED
@@ -93,6 +93,7 @@ linters:
|
|
93
93
|
- Lint/Void
|
94
94
|
- Layout/AlignHash # renamed to Layout/HashAlignment in rubocop 0.77
|
95
95
|
- Layout/AlignParameters # renamed to Layout/ParameterAlignment in rubocop 0.77
|
96
|
+
- Layout/ArgumentAlignment
|
96
97
|
- Layout/CaseIndentation
|
97
98
|
- Layout/ElseAlignment
|
98
99
|
- Layout/EndOfLine
|
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,6 +27,14 @@ module HamlLint
|
|
27
27
|
find_lints(extracted_source.source, extracted_source.source_map)
|
28
28
|
end
|
29
29
|
|
30
|
+
# A single CLI instance is shared between files to avoid RuboCop
|
31
|
+
# having to repeatedly reload .rubocop.yml.
|
32
|
+
def self.rubocop_cli
|
33
|
+
# The ivar is stored on the class singleton rather than the Linter instance
|
34
|
+
# because it can't be Marshal.dump'd (as used by Parallel.map)
|
35
|
+
@rubocop_cli ||= ::RuboCop::CLI.new
|
36
|
+
end
|
37
|
+
|
30
38
|
private
|
31
39
|
|
32
40
|
# Executes RuboCop against the given Ruby code and records the offenses as
|
@@ -36,8 +44,6 @@ module HamlLint
|
|
36
44
|
# @param source_map [Hash] map of Ruby code line numbers to original line
|
37
45
|
# numbers in the template
|
38
46
|
def find_lints(ruby, source_map)
|
39
|
-
rubocop = ::RuboCop::CLI.new
|
40
|
-
|
41
47
|
filename =
|
42
48
|
if document.file
|
43
49
|
"#{document.file}.rb"
|
@@ -46,7 +52,7 @@ module HamlLint
|
|
46
52
|
end
|
47
53
|
|
48
54
|
with_ruby_from_stdin(ruby) do
|
49
|
-
extract_lints_from_offenses(lint_file(
|
55
|
+
extract_lints_from_offenses(lint_file(self.class.rubocop_cli, filename), source_map)
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
@@ -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
|
|
@@ -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.39.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:
|
11
|
+
date: 2022-02-26 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
|
@@ -200,7 +201,7 @@ 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
|
+
rubygems_version: 3.1.6
|
204
205
|
signing_key:
|
205
206
|
specification_version: 4
|
206
207
|
summary: HAML lint tool
|