slim_lint 0.19.0 → 0.21.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +7 -1
- data/lib/slim_lint.rb +4 -4
- data/lib/slim_lint/linter/embedded_engines.rb +22 -0
- data/lib/slim_lint/options.rb +5 -0
- data/lib/slim_lint/reporter/emacs_reporter.rb +44 -0
- data/lib/slim_lint/reporter/json_reporter.rb +1 -0
- data/lib/slim_lint/runner.rb +13 -9
- data/lib/slim_lint/version.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba421a3f089d61c739817da641835d0f1154fda39e56114ddbd8c0bbebf8d3a4
|
4
|
+
data.tar.gz: 4fee0abaf859c5cb826684ff6aea6146d7b07949faf90f6a7ae3a26839f9c179
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 382eaadb2170a24c75e48163612cb0b4d32f80516f7576c4e152fdbaaa6c77281a4174203c4a10c4f4b402c0812d918f8e73cdbb5205f672ef8f788a7b4b0fe9
|
7
|
+
data.tar.gz: 463ac3fbf8f3677183440abdf937209b886c5f02e8b4b4bec6405a920297993049aa4d0199f54b57bcc5ccaab03833557a179651beee0bc43802e928564059d9
|
data/config/default.yml
CHANGED
@@ -18,6 +18,10 @@ linters:
|
|
18
18
|
ControlStatementSpacing:
|
19
19
|
enabled: true
|
20
20
|
|
21
|
+
EmbeddedEngines:
|
22
|
+
enabled: false
|
23
|
+
forbidden_engines: []
|
24
|
+
|
21
25
|
EmptyControlStatement:
|
22
26
|
enabled: true
|
23
27
|
|
@@ -53,6 +57,7 @@ linters:
|
|
53
57
|
- Layout/IndentationConsistency
|
54
58
|
- Layout/IndentationWidth
|
55
59
|
- Layout/InitialIndentation
|
60
|
+
- Layout/LineLength
|
56
61
|
- Layout/MultilineArrayBraceLayout
|
57
62
|
- Layout/MultilineAssignmentLayout
|
58
63
|
- Layout/MultilineHashBraceLayout
|
@@ -66,11 +71,12 @@ linters:
|
|
66
71
|
- Lint/Void
|
67
72
|
- Metrics/BlockLength
|
68
73
|
- Metrics/BlockNesting
|
69
|
-
- Metrics/LineLength
|
70
74
|
- Naming/FileName
|
71
75
|
- Style/FrozenStringLiteralComment
|
76
|
+
- Style/IdenticalConditionalBranches
|
72
77
|
- Style/IfUnlessModifier
|
73
78
|
- Style/Next
|
79
|
+
- Style/WhileUntilDo
|
74
80
|
- Style/WhileUntilModifier
|
75
81
|
|
76
82
|
Tab:
|
data/lib/slim_lint.rb
CHANGED
@@ -19,7 +19,7 @@ require 'slim_lint/logger'
|
|
19
19
|
require 'slim_lint/version'
|
20
20
|
|
21
21
|
# Load all filters (required by SlimLint::Engine)
|
22
|
-
Dir[File.expand_path('slim_lint/filters/*.rb', File.dirname(__FILE__))].each do |file|
|
22
|
+
Dir[File.expand_path('slim_lint/filters/*.rb', File.dirname(__FILE__))].sort.each do |file|
|
23
23
|
require file
|
24
24
|
end
|
25
25
|
|
@@ -37,16 +37,16 @@ require 'slim_lint/runner'
|
|
37
37
|
|
38
38
|
# Load all matchers
|
39
39
|
require 'slim_lint/matcher/base'
|
40
|
-
Dir[File.expand_path('slim_lint/matcher/*.rb', File.dirname(__FILE__))].each do |file|
|
40
|
+
Dir[File.expand_path('slim_lint/matcher/*.rb', File.dirname(__FILE__))].sort.each do |file|
|
41
41
|
require file
|
42
42
|
end
|
43
43
|
|
44
44
|
# Load all linters
|
45
|
-
Dir[File.expand_path('slim_lint/linter/*.rb', File.dirname(__FILE__))].each do |file|
|
45
|
+
Dir[File.expand_path('slim_lint/linter/*.rb', File.dirname(__FILE__))].sort.each do |file|
|
46
46
|
require file
|
47
47
|
end
|
48
48
|
|
49
49
|
# Load all reporters
|
50
|
-
Dir[File.expand_path('slim_lint/reporter/*.rb', File.dirname(__FILE__))].each do |file|
|
50
|
+
Dir[File.expand_path('slim_lint/reporter/*.rb', File.dirname(__FILE__))].sort.each do |file|
|
51
51
|
require file
|
52
52
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SlimLint
|
4
|
+
# Checks for forbidden embedded engines.
|
5
|
+
class Linter::EmbeddedEngines < Linter
|
6
|
+
include LinterRegistry
|
7
|
+
|
8
|
+
MESSAGE = 'Forbidden embedded engine `%s` found'
|
9
|
+
|
10
|
+
on_start do |_sexp|
|
11
|
+
forbidden_engines = config['forbidden_engines']
|
12
|
+
dummy_node = Struct.new(:line)
|
13
|
+
document.source_lines.each_with_index do |line, index|
|
14
|
+
forbidden_engines.each do |forbidden_engine|
|
15
|
+
next unless line =~ /^#{forbidden_engine}.*:\s*$/
|
16
|
+
|
17
|
+
report_lint(dummy_node.new(index + 1), MESSAGE % forbidden_engine)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/slim_lint/options.rb
CHANGED
@@ -73,6 +73,11 @@ module SlimLint
|
|
73
73
|
'List of file names to exclude') do |files|
|
74
74
|
@options[:excluded_files] = files
|
75
75
|
end
|
76
|
+
|
77
|
+
parser.on('--stdin-file-path file', String,
|
78
|
+
'Pipe source from STDIN, using file in offense reports.') do |file|
|
79
|
+
@options[:stdin_file_path] = file
|
80
|
+
end
|
76
81
|
end
|
77
82
|
|
78
83
|
# Register informational flags.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SlimLint
|
4
|
+
# Outputs lints in format: {filename}:{line}:{column}: {kind}: {message}.
|
5
|
+
class Reporter::EmacsReporter < Reporter
|
6
|
+
def display_report(report)
|
7
|
+
sorted_lints = report.lints.sort_by { |l| [l.filename, l.line] }
|
8
|
+
|
9
|
+
sorted_lints.each do |lint|
|
10
|
+
print_location(lint)
|
11
|
+
print_type(lint)
|
12
|
+
print_message(lint)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def print_location(lint)
|
19
|
+
log.info lint.filename, false
|
20
|
+
log.log ':', false
|
21
|
+
log.bold lint.line, false
|
22
|
+
log.log ':', false
|
23
|
+
# TODO: change 1 to column number when linter will have this info.
|
24
|
+
log.bold 1, false
|
25
|
+
log.log ':', false
|
26
|
+
end
|
27
|
+
|
28
|
+
def print_type(lint)
|
29
|
+
if lint.error?
|
30
|
+
log.error ' E: ', false
|
31
|
+
else
|
32
|
+
log.warning ' W: ', false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def print_message(lint)
|
37
|
+
if lint.linter
|
38
|
+
log.success("#{lint.linter.name}: ", false)
|
39
|
+
end
|
40
|
+
|
41
|
+
log.log lint.message
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/slim_lint/runner.rb
CHANGED
@@ -15,13 +15,17 @@ module SlimLint
|
|
15
15
|
# @return [SlimLint::Report] a summary of all lints found
|
16
16
|
def run(options = {})
|
17
17
|
config = load_applicable_config(options)
|
18
|
-
files = extract_applicable_files(config, options)
|
19
|
-
|
20
18
|
linter_selector = SlimLint::LinterSelector.new(config, options)
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
if options[:stdin_file_path].nil?
|
21
|
+
files = extract_applicable_files(config, options)
|
22
|
+
lints = files.map do |file|
|
23
|
+
collect_lints(File.read(file), file, linter_selector, config)
|
24
|
+
end.flatten
|
25
|
+
else
|
26
|
+
files = [options[:stdin_file_path]]
|
27
|
+
lints = collect_lints($stdin.read, options[:stdin_file_path], linter_selector, config)
|
28
|
+
end
|
25
29
|
|
26
30
|
SlimLint::Report.new(lints, files)
|
27
31
|
end
|
@@ -49,14 +53,14 @@ module SlimLint
|
|
49
53
|
# @param file [String] path to file to lint
|
50
54
|
# @param linter_selector [SlimLint::LinterSelector]
|
51
55
|
# @param config [SlimLint::Configuration]
|
52
|
-
def collect_lints(
|
56
|
+
def collect_lints(file_content, file_name, linter_selector, config)
|
53
57
|
begin
|
54
|
-
document = SlimLint::Document.new(
|
58
|
+
document = SlimLint::Document.new(file_content, file: file_name, config: config)
|
55
59
|
rescue SlimLint::Exceptions::ParseError => e
|
56
|
-
return [SlimLint::Lint.new(nil,
|
60
|
+
return [SlimLint::Lint.new(nil, file_name, e.lineno, e.error, :error)]
|
57
61
|
end
|
58
62
|
|
59
|
-
linter_selector.linters_for_file(
|
63
|
+
linter_selector.linters_for_file(file_name).map do |linter|
|
60
64
|
linter.run(document)
|
61
65
|
end.flatten
|
62
66
|
end
|
data/lib/slim_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.1
|
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: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.78.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: 0.
|
26
|
+
version: 0.78.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: slim
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/slim_lint/linter/comment_control_statement.rb
|
105
105
|
- lib/slim_lint/linter/consecutive_control_statements.rb
|
106
106
|
- lib/slim_lint/linter/control_statement_spacing.rb
|
107
|
+
- lib/slim_lint/linter/embedded_engines.rb
|
107
108
|
- lib/slim_lint/linter/empty_control_statement.rb
|
108
109
|
- lib/slim_lint/linter/empty_lines.rb
|
109
110
|
- lib/slim_lint/linter/file_length.rb
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- lib/slim_lint/reporter.rb
|
128
129
|
- lib/slim_lint/reporter/checkstyle_reporter.rb
|
129
130
|
- lib/slim_lint/reporter/default_reporter.rb
|
131
|
+
- lib/slim_lint/reporter/emacs_reporter.rb
|
130
132
|
- lib/slim_lint/reporter/json_reporter.rb
|
131
133
|
- lib/slim_lint/ruby_extract_engine.rb
|
132
134
|
- lib/slim_lint/ruby_extractor.rb
|
@@ -140,7 +142,7 @@ homepage: https://github.com/sds/slim-lint
|
|
140
142
|
licenses:
|
141
143
|
- MIT
|
142
144
|
metadata: {}
|
143
|
-
post_install_message:
|
145
|
+
post_install_message:
|
144
146
|
rdoc_options: []
|
145
147
|
require_paths:
|
146
148
|
- lib
|
@@ -155,8 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
157
|
- !ruby/object:Gem::Version
|
156
158
|
version: '0'
|
157
159
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
159
|
-
signing_key:
|
160
|
+
rubygems_version: 3.1.4
|
161
|
+
signing_key:
|
160
162
|
specification_version: 4
|
161
163
|
summary: Slim template linting tool
|
162
164
|
test_files: []
|