puppet-lint 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +74 -0
- data/.rubocop_todo.yml +89 -0
- data/.travis.yml +11 -9
- data/CHANGELOG.md +54 -0
- data/Gemfile +3 -0
- data/Rakefile +14 -3
- data/appveyor.yml +1 -4
- data/bin/puppet-lint +1 -1
- data/lib/puppet-lint.rb +25 -21
- data/lib/puppet-lint/bin.rb +15 -19
- data/lib/puppet-lint/checkplugin.rb +24 -17
- data/lib/puppet-lint/checks.rb +42 -31
- data/lib/puppet-lint/configuration.rb +11 -8
- data/lib/puppet-lint/data.rb +236 -164
- data/lib/puppet-lint/lexer.rb +225 -203
- data/lib/puppet-lint/lexer/token.rb +34 -18
- data/lib/puppet-lint/optparser.rb +33 -30
- data/lib/puppet-lint/plugins.rb +42 -38
- data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +26 -28
- data/lib/puppet-lint/plugins/check_classes/autoloader_layout.rb +21 -20
- data/lib/puppet-lint/plugins/check_classes/class_inherits_from_params_class.rb +8 -9
- data/lib/puppet-lint/plugins/check_classes/code_on_top_scope.rb +9 -8
- data/lib/puppet-lint/plugins/check_classes/inherits_across_namespaces.rb +12 -11
- data/lib/puppet-lint/plugins/check_classes/names_containing_dash.rb +13 -12
- data/lib/puppet-lint/plugins/check_classes/names_containing_uppercase.rb +14 -13
- data/lib/puppet-lint/plugins/check_classes/nested_classes_or_defines.rb +9 -10
- data/lib/puppet-lint/plugins/check_classes/parameter_order.rb +40 -31
- data/lib/puppet-lint/plugins/check_classes/right_to_left_relationship.rb +3 -2
- data/lib/puppet-lint/plugins/check_classes/variable_scope.rb +21 -24
- data/lib/puppet-lint/plugins/check_comments/slash_comments.rb +3 -2
- data/lib/puppet-lint/plugins/check_comments/star_comments.rb +6 -5
- data/lib/puppet-lint/plugins/check_conditionals/case_without_default.rb +21 -20
- data/lib/puppet-lint/plugins/check_conditionals/selector_inside_resource.rb +10 -13
- data/lib/puppet-lint/plugins/check_documentation/documentation.rb +26 -17
- data/lib/puppet-lint/plugins/check_nodes/unquoted_node_name.rb +11 -11
- data/lib/puppet-lint/plugins/check_resources/duplicate_params.rb +4 -3
- data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +17 -18
- data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +17 -16
- data/lib/puppet-lint/plugins/check_resources/file_mode.rb +22 -23
- data/lib/puppet-lint/plugins/check_resources/unquoted_file_mode.rb +14 -13
- data/lib/puppet-lint/plugins/check_resources/unquoted_resource_title.rb +9 -8
- data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +8 -8
- data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +29 -42
- data/lib/puppet-lint/plugins/check_strings/puppet_url_without_modules.rb +5 -4
- data/lib/puppet-lint/plugins/check_strings/quoted_booleans.rb +3 -2
- data/lib/puppet-lint/plugins/check_strings/single_quote_string_with_variables.rb +4 -3
- data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +3 -2
- data/lib/puppet-lint/plugins/check_variables/variable_contains_dash.rb +9 -8
- data/lib/puppet-lint/plugins/check_variables/variable_is_lowercase.rb +9 -8
- data/lib/puppet-lint/plugins/check_whitespace/140chars.rb +9 -9
- data/lib/puppet-lint/plugins/check_whitespace/2sp_soft_tabs.rb +4 -3
- data/lib/puppet-lint/plugins/check_whitespace/80chars.rb +10 -10
- data/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb +23 -22
- data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +3 -2
- data/lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb +3 -2
- data/lib/puppet-lint/tasks/puppet-lint.rb +3 -3
- data/lib/puppet-lint/version.rb +1 -1
- data/puppet-lint.gemspec +4 -4
- data/spec/puppet-lint/bin_spec.rb +268 -140
- data/spec/puppet-lint/checks_spec.rb +229 -0
- data/spec/puppet-lint/configuration_spec.rb +10 -9
- data/spec/puppet-lint/data_spec.rb +84 -0
- data/spec/puppet-lint/ignore_overrides_spec.rb +71 -40
- data/spec/puppet-lint/lexer/token_spec.rb +1 -1
- data/spec/puppet-lint/lexer_spec.rb +306 -73
- data/spec/puppet-lint/plugins/check_classes/arrow_on_right_operand_line_spec.rb +12 -6
- data/spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +10 -10
- data/spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb +15 -11
- data/spec/puppet-lint/plugins/check_classes/code_on_top_scope_spec.rb +26 -21
- data/spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +3 -3
- data/spec/puppet-lint/plugins/check_classes/name_contains_uppercase_spec.rb +4 -5
- data/spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +13 -0
- data/spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +33 -25
- data/spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb +80 -55
- data/spec/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +2 -2
- data/spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb +165 -130
- data/spec/puppet-lint/plugins/check_comments/slash_comments_spec.rb +2 -2
- data/spec/puppet-lint/plugins/check_comments/star_comments_spec.rb +53 -35
- data/spec/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +59 -49
- data/spec/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +18 -14
- data/spec/puppet-lint/plugins/check_documentation/documentation_spec.rb +14 -10
- data/spec/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb +7 -7
- data/spec/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +54 -44
- data/spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +114 -89
- data/spec/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +41 -30
- data/spec/puppet-lint/plugins/check_resources/file_mode_spec.rb +46 -40
- data/spec/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +46 -40
- data/spec/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +95 -71
- data/spec/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +28 -24
- data/spec/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +11 -9
- data/spec/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb +1 -2
- data/spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +18 -14
- data/spec/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +1 -1
- data/spec/puppet-lint/plugins/check_variables/variable_is_lowercase_spec.rb +1 -1
- data/spec/puppet-lint/plugins/check_whitespace/140chars_spec.rb +22 -15
- data/spec/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +8 -6
- data/spec/puppet-lint/plugins/check_whitespace/80chars_spec.rb +23 -29
- data/spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +588 -494
- data/spec/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +1 -1
- data/spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +27 -19
- data/spec/puppet-lint_spec.rb +2 -12
- data/spec/spec_helper.rb +35 -30
- metadata +6 -5
- data/lib/puppet-lint/monkeypatches.rb +0 -2
- data/lib/puppet-lint/monkeypatches/string_percent.rb +0 -52
- data/lib/puppet-lint/monkeypatches/string_prepend.rb +0 -13
@@ -5,18 +5,19 @@
|
|
5
5
|
PuppetLint.new_check(:inherits_across_namespaces) do
|
6
6
|
def check
|
7
7
|
class_indexes.each do |class_idx|
|
8
|
-
|
9
|
-
inherited_module_name = class_idx[:inherited_token].value.split('::').reject { |r| r.empty? }.first
|
10
|
-
class_module_name = class_idx[:name_token].value.split('::').reject { |r| r.empty? }.first
|
8
|
+
next if class_idx[:inherited_token].nil?
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
inherited_module_name = class_idx[:inherited_token].value.split('::').reject(&:empty?).first
|
11
|
+
class_module_name = class_idx[:name_token].value.split('::').reject(&:empty?).first
|
12
|
+
|
13
|
+
next if class_module_name == inherited_module_name
|
14
|
+
|
15
|
+
notify(
|
16
|
+
:warning,
|
17
|
+
:message => 'class inherits across module namespaces',
|
18
|
+
:line => class_idx[:inherited_token].line,
|
19
|
+
:column => class_idx[:inherited_token].column,
|
20
|
+
)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -5,19 +5,20 @@
|
|
5
5
|
PuppetLint.new_check(:names_containing_dash) do
|
6
6
|
def check
|
7
7
|
(class_indexes + defined_type_indexes).each do |class_idx|
|
8
|
-
|
9
|
-
if class_idx[:type] == :CLASS
|
10
|
-
obj_type = 'class'
|
11
|
-
else
|
12
|
-
obj_type = 'defined type'
|
13
|
-
end
|
8
|
+
next unless class_idx[:name_token].value.include?('-')
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
obj_type = if class_idx[:type] == :CLASS
|
11
|
+
'class'
|
12
|
+
else
|
13
|
+
'defined type'
|
14
|
+
end
|
15
|
+
|
16
|
+
notify(
|
17
|
+
:error,
|
18
|
+
:message => "#{obj_type} name containing a dash",
|
19
|
+
:line => class_idx[:name_token].line,
|
20
|
+
:column => class_idx[:name_token].column,
|
21
|
+
)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -5,20 +5,21 @@
|
|
5
5
|
PuppetLint.new_check(:names_containing_uppercase) do
|
6
6
|
def check
|
7
7
|
(class_indexes + defined_type_indexes).each do |class_idx|
|
8
|
-
|
9
|
-
if class_idx[:type] == :CLASS
|
10
|
-
obj_type = 'class'
|
11
|
-
else
|
12
|
-
obj_type = 'defined type'
|
13
|
-
end
|
8
|
+
next unless class_idx[:name_token].value =~ %r{[A-Z]}
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
obj_type = if class_idx[:type] == :CLASS
|
11
|
+
'class'
|
12
|
+
else
|
13
|
+
'defined type'
|
14
|
+
end
|
15
|
+
|
16
|
+
notify(
|
17
|
+
:error,
|
18
|
+
:message => "#{obj_type} '#{class_idx[:name_token].value}' contains illegal uppercase",
|
19
|
+
:line => class_idx[:name_token].line,
|
20
|
+
:column => class_idx[:name_token].column,
|
21
|
+
:token => class_idx[:name_token],
|
22
|
+
)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
@@ -11,17 +11,16 @@ PuppetLint.new_check(:nested_classes_or_defines) do
|
|
11
11
|
class_tokens = class_idx[:tokens][1..-1]
|
12
12
|
|
13
13
|
class_tokens.each do |token|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
next unless TOKENS.include?(token.type)
|
15
|
+
next if token.next_code_token.type == :LBRACE
|
16
|
+
type = token.type == :CLASS ? 'class' : 'defined type'
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
18
|
+
notify(
|
19
|
+
:warning,
|
20
|
+
:message => "#{type} defined inside a class",
|
21
|
+
:line => token.line,
|
22
|
+
:column => token.column,
|
23
|
+
)
|
25
24
|
end
|
26
25
|
end
|
27
26
|
end
|
@@ -6,39 +6,48 @@
|
|
6
6
|
PuppetLint.new_check(:parameter_order) do
|
7
7
|
def check
|
8
8
|
(class_indexes + defined_type_indexes).each do |class_idx|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
next if (! hash_or_array_stack.empty?)
|
23
|
-
next unless paren_stack.empty?
|
24
|
-
|
25
|
-
if token.type == :VARIABLE
|
26
|
-
if token.next_code_token.nil? || [:COMMA, :RPAREN].include?(token.next_code_token.type)
|
27
|
-
prev_tokens = class_idx[:param_tokens][0..i]
|
28
|
-
unless prev_tokens.rindex { |r| r.type == :EQUALS }.nil?
|
29
|
-
unless token.prev_code_token.nil? or token.prev_code_token.type == :EQUALS
|
30
|
-
msg = 'optional parameter listed before required parameter'
|
31
|
-
notify :warning, {
|
32
|
-
:message => msg,
|
33
|
-
:line => token.line,
|
34
|
-
:column => token.column,
|
35
|
-
}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
9
|
+
next if class_idx[:param_tokens].nil?
|
10
|
+
|
11
|
+
paren_stack = []
|
12
|
+
hash_or_array_stack = []
|
13
|
+
class_idx[:param_tokens].each_with_index do |token, i|
|
14
|
+
if token.type == :LPAREN
|
15
|
+
paren_stack.push(true)
|
16
|
+
elsif token.type == :RPAREN
|
17
|
+
paren_stack.pop
|
18
|
+
elsif token.type == :LBRACE || token.type == :LBRACK
|
19
|
+
hash_or_array_stack.push(true)
|
20
|
+
elsif token.type == :RBRACE || token.type == :RBRACK
|
21
|
+
hash_or_array_stack.pop
|
40
22
|
end
|
23
|
+
|
24
|
+
next unless hash_or_array_stack.empty? && paren_stack.empty?
|
25
|
+
next unless required_parameter?(token)
|
26
|
+
|
27
|
+
prev_tokens = class_idx[:param_tokens][0..i]
|
28
|
+
next if prev_tokens.rindex { |r| r.type == :EQUALS }.nil?
|
29
|
+
|
30
|
+
msg = 'optional parameter listed before required parameter'
|
31
|
+
notify(
|
32
|
+
:warning,
|
33
|
+
:message => msg,
|
34
|
+
:line => token.line,
|
35
|
+
:column => token.column,
|
36
|
+
)
|
41
37
|
end
|
42
38
|
end
|
43
39
|
end
|
40
|
+
|
41
|
+
def required_parameter?(token)
|
42
|
+
return false unless token.type == :VARIABLE
|
43
|
+
|
44
|
+
data_type = token.prev_token_of(:TYPE, :skip_blocks => true)
|
45
|
+
return false if data_type && data_type.value == 'Optional'
|
46
|
+
|
47
|
+
if token.next_code_token.nil? || [:COMMA, :RPAREN].include?(token.next_code_token.type)
|
48
|
+
return !(token.prev_code_token && token.prev_code_token.type == :EQUALS)
|
49
|
+
end
|
50
|
+
|
51
|
+
false
|
52
|
+
end
|
44
53
|
end
|
@@ -5,11 +5,12 @@
|
|
5
5
|
PuppetLint.new_check(:right_to_left_relationship) do
|
6
6
|
def check
|
7
7
|
tokens.select { |r| r.type == :OUT_EDGE }.each do |token|
|
8
|
-
notify
|
8
|
+
notify(
|
9
|
+
:warning,
|
9
10
|
:message => 'right-to-left (<-) relationship',
|
10
11
|
:line => token.line,
|
11
12
|
:column => token.column,
|
12
|
-
|
13
|
+
)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -43,11 +43,10 @@ PuppetLint.new_check(:variable_scope) do
|
|
43
43
|
|
44
44
|
unless idx[:param_tokens].nil?
|
45
45
|
idx[:param_tokens].each do |token|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
46
|
+
next unless token.type == :VARIABLE
|
47
|
+
next unless POST_VAR_TOKENS.include?(token.next_code_token.type)
|
48
|
+
|
49
|
+
variables_in_scope << token.value
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
@@ -72,10 +71,10 @@ PuppetLint.new_check(:variable_scope) do
|
|
72
71
|
brack_depth += 1
|
73
72
|
when :LBRACK
|
74
73
|
brack_depth -= 1
|
75
|
-
break if brack_depth
|
76
|
-
when :COMMA
|
74
|
+
break if brack_depth.zero?
|
75
|
+
when :COMMA # rubocop:disable Lint/EmptyWhen
|
77
76
|
# ignore
|
78
|
-
else
|
77
|
+
else # unexpected
|
79
78
|
break
|
80
79
|
end
|
81
80
|
end
|
@@ -102,7 +101,7 @@ PuppetLint.new_check(:variable_scope) do
|
|
102
101
|
brace_depth += 1
|
103
102
|
when :RBRACE
|
104
103
|
brace_depth -= 1
|
105
|
-
if brace_depth
|
104
|
+
if brace_depth.zero?
|
106
105
|
end_token = sub_token
|
107
106
|
break
|
108
107
|
end
|
@@ -118,25 +117,23 @@ PuppetLint.new_check(:variable_scope) do
|
|
118
117
|
end
|
119
118
|
end
|
120
119
|
|
121
|
-
msg =
|
120
|
+
msg = 'top-scope variable being used without an explicit namespace'
|
122
121
|
referenced_variables.each do |token|
|
123
122
|
unless future_parser_scopes[token.line].nil?
|
124
|
-
next if future_parser_scopes[token.line].include?(token.value.gsub(
|
123
|
+
next if future_parser_scopes[token.line].include?(token.value.gsub(%r{\[.+\]\Z}, ''))
|
125
124
|
end
|
126
125
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
end
|
139
|
-
end
|
126
|
+
next if token.value.include?('::')
|
127
|
+
next if token.value =~ %r{^(facts|trusted)\[.+\]}
|
128
|
+
next if variables_in_scope.include?(token.value.gsub(%r{\[.+\]\Z}, ''))
|
129
|
+
next if token.value =~ %r{\A\d+\Z}
|
130
|
+
|
131
|
+
notify(
|
132
|
+
:warning,
|
133
|
+
:message => msg,
|
134
|
+
:line => token.line,
|
135
|
+
:column => token.column,
|
136
|
+
)
|
140
137
|
end
|
141
138
|
end
|
142
139
|
end
|
@@ -7,12 +7,13 @@ PuppetLint.new_check(:slash_comments) do
|
|
7
7
|
tokens.select { |token|
|
8
8
|
token.type == :SLASH_COMMENT
|
9
9
|
}.each do |token|
|
10
|
-
notify
|
10
|
+
notify(
|
11
|
+
:warning,
|
11
12
|
:message => '// comment found',
|
12
13
|
:line => token.line,
|
13
14
|
:column => token.column,
|
14
15
|
:token => token,
|
15
|
-
|
16
|
+
)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -7,12 +7,13 @@ PuppetLint.new_check(:star_comments) do
|
|
7
7
|
tokens.select { |token|
|
8
8
|
token.type == :MLCOMMENT
|
9
9
|
}.each do |token|
|
10
|
-
notify
|
10
|
+
notify(
|
11
|
+
:warning,
|
11
12
|
:message => '/* */ comment found',
|
12
13
|
:line => token.line,
|
13
14
|
:column => token.column,
|
14
15
|
:token => token,
|
15
|
-
|
16
|
+
)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -26,9 +27,9 @@ PuppetLint.new_check(:star_comments) do
|
|
26
27
|
index = tokens.index(problem[:token].next_token) || 1
|
27
28
|
comment_lines.reverse.each do |line|
|
28
29
|
indent = problem[:token].prev_token.nil? ? nil : problem[:token].prev_token.value.dup
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
add_token(index, PuppetLint::Lexer::Token.new(:COMMENT, " #{line}", 0, 0))
|
31
|
+
add_token(index, PuppetLint::Lexer::Token.new(:INDENT, indent, 0, 0)) if indent
|
32
|
+
add_token(index, PuppetLint::Lexer::Token.new(:NEWLINE, "\n", 0, 0))
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -7,37 +7,38 @@ PuppetLint.new_check(:case_without_default) do
|
|
7
7
|
case_indexes = []
|
8
8
|
|
9
9
|
tokens.each_index do |token_idx|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
next unless tokens[token_idx].type == :CASE
|
11
|
+
|
12
|
+
depth = 0
|
13
|
+
tokens[(token_idx + 1)..-1].each_index do |case_token_idx|
|
14
|
+
idx = case_token_idx + token_idx + 1
|
15
|
+
if tokens[idx].type == :LBRACE
|
16
|
+
depth += 1
|
17
|
+
elsif tokens[idx].type == :RBRACE
|
18
|
+
depth -= 1
|
19
|
+
if depth.zero?
|
20
|
+
case_indexes << { :start => token_idx, :end => idx }
|
21
|
+
break
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
case_indexes.each_with_index do |kase,kase_index|
|
27
|
+
case_indexes.each_with_index do |kase, kase_index|
|
28
28
|
case_tokens = tokens[kase[:start]..kase[:end]]
|
29
29
|
|
30
30
|
case_indexes[(kase_index + 1)..-1].each do |successor_kase|
|
31
31
|
case_tokens -= tokens[successor_kase[:start]..successor_kase[:end]]
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
next if case_tokens.index { |r| r.type == :DEFAULT }
|
35
|
+
|
36
|
+
notify(
|
37
|
+
:warning,
|
38
|
+
:message => 'case statement without a default case',
|
39
|
+
:line => case_tokens.first.line,
|
40
|
+
:column => case_tokens.first.column,
|
41
|
+
)
|
41
42
|
end
|
42
43
|
end
|
43
44
|
end
|
@@ -6,19 +6,16 @@ PuppetLint.new_check(:selector_inside_resource) do
|
|
6
6
|
def check
|
7
7
|
resource_indexes.each do |resource|
|
8
8
|
resource[:tokens].each do |token|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
9
|
+
next unless token.type == :FARROW && token.next_code_token.type == :VARIABLE
|
10
|
+
next if token.next_code_token.next_code_token.nil?
|
11
|
+
next unless token.next_code_token.next_code_token.type == :QMARK
|
12
|
+
|
13
|
+
notify(
|
14
|
+
:warning,
|
15
|
+
:message => 'selector inside resource block',
|
16
|
+
:line => token.line,
|
17
|
+
:column => token.column,
|
18
|
+
)
|
22
19
|
end
|
23
20
|
end
|
24
21
|
end
|
@@ -9,25 +9,34 @@ PuppetLint.new_check(:documentation) do
|
|
9
9
|
|
10
10
|
def check
|
11
11
|
(class_indexes + defined_type_indexes).each do |item_idx|
|
12
|
-
|
13
|
-
while (!prev_token.nil?) && WHITESPACE_TOKENS.include?(prev_token.type)
|
14
|
-
prev_token = prev_token.prev_token
|
15
|
-
end
|
12
|
+
comment_token = find_comment_token(item_idx[:tokens].first)
|
16
13
|
|
17
|
-
unless
|
18
|
-
first_token = item_idx[:tokens].first
|
19
|
-
if first_token.type == :CLASS
|
20
|
-
type = 'class'
|
21
|
-
else
|
22
|
-
type = 'defined type'
|
23
|
-
end
|
14
|
+
next unless comment_token.nil?
|
24
15
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
16
|
+
first_token = item_idx[:tokens].first
|
17
|
+
type = if first_token.type == :CLASS
|
18
|
+
'class'
|
19
|
+
else
|
20
|
+
'defined type'
|
21
|
+
end
|
22
|
+
|
23
|
+
notify(
|
24
|
+
:warning,
|
25
|
+
:message => "#{type} not documented",
|
26
|
+
:line => first_token.line,
|
27
|
+
:column => first_token.column,
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_comment_token(start_token)
|
33
|
+
prev_token = start_token.prev_token
|
34
|
+
while !prev_token.nil? && WHITESPACE_TOKENS.include?(prev_token.type)
|
35
|
+
prev_token = prev_token.prev_token
|
31
36
|
end
|
37
|
+
|
38
|
+
return if prev_token.nil?
|
39
|
+
|
40
|
+
prev_token if COMMENT_TOKENS.include?(prev_token.type)
|
32
41
|
end
|
33
42
|
end
|