haml_lint 0.25.1 → 0.26.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
  SHA1:
3
- metadata.gz: bf05f1a1e2ec9d5ca6b6a6cd1ae398c8bf99f394
4
- data.tar.gz: 39ea41022301f4ec279256bf6a9bfb930b786e25
3
+ metadata.gz: fd94eae8ee22841c46e2d3af6beb0a8b3083c305
4
+ data.tar.gz: 209d59375ccc51443638795414ca08cbb15a9ce1
5
5
  SHA512:
6
- metadata.gz: 5ff5514837ce5b08d1571e2c61fe26b8fd9b26c063b7582cfafecb353bc308988bc9c64773b932821efd7d5122b2b64babd200dc5f69f2e1df2ef59874a6b063
7
- data.tar.gz: 08ca2d1c74ae2c561734f6c69e65257e0ee8a64658e919be2875c367a83b217422e4dfa8fb7efce137f3cda118fed35d9e53de00fb4371046360aab39d6b8e67
6
+ metadata.gz: 37f51cc96857c95b8e32eab1cdc8bd992f8264c371869e56ce8b3eb304e80f0a8c90a313b9ad4ca2f1c8879a4a7e713d23a7c8cba38e0752c4b4ee6c75112f5f
7
+ data.tar.gz: affb71eddfa8eaf47096af284fa57c4d115072904e0c4b78934df1e0dc3eb4675a864b02b0d8343e0d80be6982456266c51c1a0dd12700dbd0619c629fc0bce8
data/config/default.yml CHANGED
@@ -91,9 +91,12 @@ linters:
91
91
  - Lint/BlockAlignment
92
92
  - Lint/EndAlignment
93
93
  - Lint/Void
94
+ - Layout/AlignParameters
95
+ - Layout/IndentationWidth
96
+ - Layout/TrailingBlankLines
97
+ - Layout/TrailingWhitespace
94
98
  - Metrics/BlockLength
95
99
  - Metrics/LineLength
96
- - Style/AlignParameters
97
100
  - Style/BlockNesting
98
101
  - Style/ElseAlignment
99
102
  - Style/EndOfLine
@@ -101,10 +104,7 @@ linters:
101
104
  - Style/FinalNewline
102
105
  - Style/FrozenStringLiteralComment
103
106
  - Style/IfUnlessModifier
104
- - Style/IndentationWidth
105
107
  - Style/Next
106
- - Style/TrailingBlankLines
107
- - Style/TrailingWhitespace
108
108
  - Style/WhileUntilModifier
109
109
 
110
110
  RubyComments:
@@ -128,3 +128,7 @@ linters:
128
128
 
129
129
  UnnecessaryStringOutput:
130
130
  enabled: true
131
+
132
+ ViewLength:
133
+ enabled: true
134
+ max: 100
@@ -26,7 +26,12 @@ module HamlLint
26
26
  def find_lints(ruby, source_map)
27
27
  rubocop = ::RuboCop::CLI.new
28
28
 
29
- filename = document.file || 'ruby_script'
29
+ filename =
30
+ if document.file
31
+ "#{document.file}.rb"
32
+ else
33
+ 'ruby_script.rb'
34
+ end
30
35
 
31
36
  with_ruby_from_stdin(ruby) do
32
37
  extract_lints_from_offenses(lint_file(rubocop, filename), source_map)
@@ -10,7 +10,7 @@ module HamlLint
10
10
  include LinterRegistry
11
11
 
12
12
  def visit_tag(node)
13
- return if node.script.empty?
13
+ return if node.script.length <= 2
14
14
 
15
15
  count = 0
16
16
  chars = 2 # Include surrounding quote chars
@@ -0,0 +1,19 @@
1
+ module HamlLint
2
+ # Detects overly long views.
3
+ class Linter::ViewLength < Linter
4
+ include LinterRegistry
5
+
6
+ MSG = 'View template is too long [%d/%d]'.freeze
7
+
8
+ DummyNode = Struct.new(:line)
9
+
10
+ def visit_root(_root)
11
+ max = config['max']
12
+ line_count = document.source_lines.count
13
+
14
+ if line_count > max
15
+ record_lint(DummyNode.new(0), format(MSG, line_count, max))
16
+ end
17
+ end
18
+ end
19
+ end
@@ -95,9 +95,15 @@ module HamlLint
95
95
  [].tap do |output|
96
96
  output << " # Offense count: #{linters_lint_count[linter]}"
97
97
  output << " #{linter}:"
98
- output << ' exclude:'
99
- files.each do |filename|
100
- output << %{ - "#{filename}"}
98
+ # disable the linter when there are many files with offenses.
99
+ # exclude the affected files otherwise.
100
+ if files.count > 15
101
+ output << ' enabled: false'
102
+ else
103
+ output << ' exclude:'
104
+ files.each do |filename|
105
+ output << %{ - "#{filename}"}
106
+ end
101
107
  end
102
108
  end.join("\n")
103
109
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module HamlLint
5
- VERSION = '0.25.1'.freeze
5
+ VERSION = '0.26.0'.freeze
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.1
4
+ version: 0.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brigade Engineering
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-11 00:00:00.000000000 Z
12
+ date: 2017-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: haml
@@ -71,14 +71,14 @@ dependencies:
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 0.47.0
74
+ version: 0.49.0
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 0.47.0
81
+ version: 0.49.0
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: sysexits
84
84
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,7 @@ files:
150
150
  - lib/haml_lint/linter/trailing_whitespace.rb
151
151
  - lib/haml_lint/linter/unnecessary_interpolation.rb
152
152
  - lib/haml_lint/linter/unnecessary_string_output.rb
153
+ - lib/haml_lint/linter/view_length.rb
153
154
  - lib/haml_lint/linter_registry.rb
154
155
  - lib/haml_lint/linter_selector.rb
155
156
  - lib/haml_lint/logger.rb