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
@@ -9,28 +9,28 @@ PuppetLint.new_check(:unquoted_node_name) do
|
|
9
9
|
node_token_idx = tokens.index(node)
|
10
10
|
node_lbrace_tok = tokens[node_token_idx..-1].find { |token| token.type == :LBRACE }
|
11
11
|
if node_lbrace_tok.nil?
|
12
|
-
notify
|
12
|
+
notify(
|
13
|
+
:error,
|
13
14
|
:check => :syntax,
|
14
15
|
:message => 'Syntax error (try running `puppet parser validate <file>`)',
|
15
16
|
:line => node.line,
|
16
17
|
:column => node.column,
|
17
|
-
|
18
|
+
)
|
18
19
|
next
|
19
20
|
end
|
20
21
|
|
21
22
|
node_lbrace_idx = tokens.index(node_lbrace_tok)
|
22
23
|
|
23
24
|
tokens[node_token_idx..node_lbrace_idx].select { |token|
|
24
|
-
token.type == :NAME
|
25
|
+
token.type == :NAME && token.value != 'default'
|
25
26
|
}.each do |token|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
27
|
+
notify(
|
28
|
+
:warning,
|
29
|
+
:message => 'unquoted node name found',
|
30
|
+
:line => token.line,
|
31
|
+
:column => token.column,
|
32
|
+
:token => token,
|
33
|
+
)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -8,7 +8,7 @@ PuppetLint.new_check(:duplicate_params) do
|
|
8
8
|
seen_params = {}
|
9
9
|
level = 0
|
10
10
|
|
11
|
-
resource[:tokens].
|
11
|
+
resource[:tokens].each do |token|
|
12
12
|
case token.type
|
13
13
|
when :LBRACE
|
14
14
|
level += 1
|
@@ -22,11 +22,12 @@ PuppetLint.new_check(:duplicate_params) do
|
|
22
22
|
next unless prev_token.type == :NAME
|
23
23
|
|
24
24
|
if (seen_params[level] ||= Set.new).include?(prev_token.value)
|
25
|
-
notify
|
25
|
+
notify(
|
26
|
+
:error,
|
26
27
|
:message => 'duplicate parameter found in resource',
|
27
28
|
:line => prev_token.line,
|
28
29
|
:column => prev_token.column,
|
29
|
-
|
30
|
+
)
|
30
31
|
else
|
31
32
|
seen_params[level] << prev_token.value
|
32
33
|
end
|
@@ -6,22 +6,22 @@
|
|
6
6
|
PuppetLint.new_check(:ensure_first_param) do
|
7
7
|
def check
|
8
8
|
resource_indexes.each do |resource|
|
9
|
-
next if [:CLASS].include?
|
10
|
-
ensure_attr_index = resource[:param_tokens].index { |param_token|
|
11
|
-
param_token.value == 'ensure'
|
12
|
-
}
|
9
|
+
next if [:CLASS].include?(resource[:type].type)
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
ensure_token = resource[:param_tokens][ensure_attr_index]
|
17
|
-
notify :warning, {
|
18
|
-
:message => "ensure found on line but it's not the first attribute",
|
19
|
-
:line => ensure_token.line,
|
20
|
-
:column => ensure_token.column,
|
21
|
-
:resource => resource,
|
22
|
-
}
|
23
|
-
end
|
11
|
+
ensure_attr_index = resource[:param_tokens].index do |param_token|
|
12
|
+
param_token.value == 'ensure'
|
24
13
|
end
|
14
|
+
|
15
|
+
next if ensure_attr_index.nil? || ensure_attr_index.zero?
|
16
|
+
|
17
|
+
ensure_token = resource[:param_tokens][ensure_attr_index]
|
18
|
+
notify(
|
19
|
+
:warning,
|
20
|
+
:message => "ensure found on line but it's not the first attribute",
|
21
|
+
:line => ensure_token.line,
|
22
|
+
:column => ensure_token.column,
|
23
|
+
:resource => resource,
|
24
|
+
)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -31,7 +31,7 @@ PuppetLint.new_check(:ensure_first_param) do
|
|
31
31
|
ensure_param_name_token = first_param_comma_token.next_token_of(:NAME, :value => 'ensure')
|
32
32
|
ensure_param_comma_token = ensure_param_name_token.next_token_of([:COMMA, :SEMIC])
|
33
33
|
|
34
|
-
if first_param_name_token.nil?
|
34
|
+
if first_param_name_token.nil? || first_param_comma_token.nil? || ensure_param_name_token.nil? || ensure_param_comma_token.nil?
|
35
35
|
raise PuppetLint::NoFix
|
36
36
|
end
|
37
37
|
|
@@ -54,12 +54,11 @@ PuppetLint.new_check(:ensure_first_param) do
|
|
54
54
|
ensure_param_comma_token.next_token = next_token
|
55
55
|
|
56
56
|
next_code_token = first_param_comma_token.next_code_token
|
57
|
-
first_param_comma_code_token = ensure_param_comma_token.next_code_token
|
58
57
|
ensure_param_comma_token.next_code_token = next_code_token
|
59
58
|
|
60
59
|
# Update index
|
61
|
-
ensure_tmp = tokens.slice!(ensure_param_name_idx..ensure_param_comma_idx-1)
|
62
|
-
first_tmp = tokens.slice!(first_param_name_idx..first_param_comma_idx-1)
|
60
|
+
ensure_tmp = tokens.slice!(ensure_param_name_idx..ensure_param_comma_idx - 1)
|
61
|
+
first_tmp = tokens.slice!(first_param_name_idx..first_param_comma_idx - 1)
|
63
62
|
ensure_tmp.reverse_each do |item|
|
64
63
|
tokens.insert(first_param_name_idx, item)
|
65
64
|
end
|
@@ -6,21 +6,22 @@
|
|
6
6
|
PuppetLint.new_check(:ensure_not_symlink_target) do
|
7
7
|
def check
|
8
8
|
resource_indexes.each do |resource|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
9
|
+
next unless resource[:type].value == 'file'
|
10
|
+
|
11
|
+
resource[:param_tokens].select { |param_token|
|
12
|
+
param_token.value == 'ensure'
|
13
|
+
}.each do |ensure_token|
|
14
|
+
value_token = ensure_token.next_code_token.next_code_token
|
15
|
+
next unless value_token.value.start_with?('/')
|
16
|
+
|
17
|
+
notify(
|
18
|
+
:warning,
|
19
|
+
:message => 'symlink target specified in ensure attr',
|
20
|
+
:line => value_token.line,
|
21
|
+
:column => value_token.column,
|
22
|
+
:param_token => ensure_token,
|
23
|
+
:value_token => value_token,
|
24
|
+
)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -37,7 +38,7 @@ PuppetLint.new_check(:ensure_not_symlink_target) do
|
|
37
38
|
PuppetLint::Lexer::Token.new(:WHITESPACE, ' ', 0, 0),
|
38
39
|
PuppetLint::Lexer::Token.new(:FARROW, '=>', 0, 0),
|
39
40
|
PuppetLint::Lexer::Token.new(:WHITESPACE, ' ', 0, 0),
|
40
|
-
].
|
41
|
+
].reverse_each do |new_token|
|
41
42
|
tokens.insert(index, new_token)
|
42
43
|
end
|
43
44
|
end
|
@@ -4,39 +4,38 @@
|
|
4
4
|
#
|
5
5
|
# https://docs.puppet.com/guides/style_guide.html#file-modes
|
6
6
|
PuppetLint.new_check(:file_mode) do
|
7
|
-
MSG = 'mode should be represented as a 4 digit octal value or symbolic mode'
|
8
|
-
SYM_RE =
|
7
|
+
MSG = 'mode should be represented as a 4 digit octal value or symbolic mode'.freeze
|
8
|
+
SYM_RE = '([ugoa]*[-=+][-=+rstwxXugo]*)(,[ugoa]*[-=+][-=+rstwxXugo]*)*'.freeze
|
9
9
|
IGNORE_TYPES = Set[:VARIABLE, :UNDEF, :FUNCTION_NAME]
|
10
|
-
MODE_RE =
|
10
|
+
MODE_RE = %r{\A([0-7]{4}|#{SYM_RE})\Z}
|
11
11
|
|
12
12
|
def check
|
13
13
|
resource_indexes.each do |resource|
|
14
|
-
|
15
|
-
resource[:param_tokens].select { |param_token|
|
16
|
-
param_token.value == 'mode'
|
17
|
-
}.each do |param_token|
|
18
|
-
value_token = param_token.next_code_token.next_code_token
|
14
|
+
next unless resource[:type].value == 'file' || resource[:type].value == 'concat'
|
19
15
|
|
20
|
-
|
21
|
-
|
16
|
+
resource[:param_tokens].select { |param_token|
|
17
|
+
param_token.value == 'mode'
|
18
|
+
}.each do |param_token|
|
19
|
+
value_token = param_token.next_code_token.next_code_token
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
break if IGNORE_TYPES.include?(value_token.type)
|
22
|
+
break if value_token.value =~ MODE_RE
|
23
|
+
|
24
|
+
notify(
|
25
|
+
:warning,
|
26
|
+
:message => MSG,
|
27
|
+
:line => value_token.line,
|
28
|
+
:column => value_token.column,
|
29
|
+
:token => value_token,
|
30
|
+
)
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
35
|
def fix(problem)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
raise PuppetLint::NoFix
|
40
|
-
end
|
36
|
+
raise PuppetLint::NoFix unless problem[:token].value =~ %r{\A[0-7]{3}\Z}
|
37
|
+
|
38
|
+
problem[:token].type = :SSTRING
|
39
|
+
problem[:token].value = "0#{problem[:token].value}"
|
41
40
|
end
|
42
41
|
end
|
@@ -8,19 +8,20 @@ PuppetLint.new_check(:unquoted_file_mode) do
|
|
8
8
|
|
9
9
|
def check
|
10
10
|
resource_indexes.each do |resource|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
11
|
+
next unless resource[:type].value == 'file' || resource[:type].value == 'concat'
|
12
|
+
|
13
|
+
resource[:param_tokens].select { |param_token|
|
14
|
+
param_token.value == 'mode' &&
|
15
|
+
TOKEN_TYPES.include?(param_token.next_code_token.next_code_token.type)
|
16
|
+
}.each do |param_token|
|
17
|
+
value_token = param_token.next_code_token.next_code_token
|
18
|
+
notify(
|
19
|
+
:warning,
|
20
|
+
:message => 'unquoted file mode',
|
21
|
+
:line => value_token.line,
|
22
|
+
:column => value_token.column,
|
23
|
+
:token => value_token,
|
24
|
+
)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -5,14 +5,15 @@
|
|
5
5
|
PuppetLint.new_check(:unquoted_resource_title) do
|
6
6
|
def check
|
7
7
|
title_tokens.each do |token|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
next unless token.type == :NAME
|
9
|
+
|
10
|
+
notify(
|
11
|
+
:warning,
|
12
|
+
:message => 'unquoted resource title',
|
13
|
+
:line => token.line,
|
14
|
+
:column => token.column,
|
15
|
+
:token => token,
|
16
|
+
)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -4,20 +4,20 @@
|
|
4
4
|
#
|
5
5
|
# https://docs.puppet.com/guides/style_guide.html#quoting
|
6
6
|
PuppetLint.new_check(:double_quoted_strings) do
|
7
|
+
ESCAPE_CHAR_RE = %r{(\\\$|\\"|\\'|'|\r|\t|\\t|\n|\\n|\\\\)}
|
8
|
+
|
7
9
|
def check
|
8
10
|
tokens.select { |token|
|
9
|
-
token.type == :STRING
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}.each do |token, sane_value|
|
15
|
-
notify :warning, {
|
11
|
+
token.type == :STRING &&
|
12
|
+
token.value.gsub(' ' * token.column, "\n")[ESCAPE_CHAR_RE].nil?
|
13
|
+
}.each do |token|
|
14
|
+
notify(
|
15
|
+
:warning,
|
16
16
|
:message => 'double quoted string containing no variables',
|
17
17
|
:line => token.line,
|
18
18
|
:column => token.column,
|
19
19
|
:token => token,
|
20
|
-
|
20
|
+
)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -7,57 +7,44 @@ PuppetLint.new_check(:only_variable_string) do
|
|
7
7
|
|
8
8
|
def check
|
9
9
|
tokens.each_with_index do |start_token, start_token_idx|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
notify :warning, {
|
25
|
-
:message => 'string containing only a variable',
|
26
|
-
:line => var_token.line,
|
27
|
-
:column => var_token.column,
|
28
|
-
:start_token => start_token,
|
29
|
-
:var_token => var_token,
|
30
|
-
:end_token => eos_token,
|
31
|
-
}
|
32
|
-
end
|
33
|
-
break
|
34
|
-
else
|
10
|
+
next unless start_token.type == :DQPRE && start_token.value == ''
|
11
|
+
|
12
|
+
var_token = start_token.next_token
|
13
|
+
next unless VAR_TYPES.include?(var_token.type)
|
14
|
+
|
15
|
+
eos_offset = 2
|
16
|
+
loop do
|
17
|
+
eos_token = tokens[start_token_idx + eos_offset]
|
18
|
+
case eos_token.type
|
19
|
+
when :LBRACK
|
20
|
+
eos_offset += 3
|
21
|
+
when :DQPOST
|
22
|
+
if eos_token.value == ''
|
23
|
+
if eos_token.next_code_token && eos_token.next_code_token.type == :FARROW
|
35
24
|
break
|
36
25
|
end
|
26
|
+
notify(
|
27
|
+
:warning,
|
28
|
+
:message => 'string containing only a variable',
|
29
|
+
:line => var_token.line,
|
30
|
+
:column => var_token.column,
|
31
|
+
:start_token => start_token,
|
32
|
+
:var_token => var_token,
|
33
|
+
:end_token => eos_token,
|
34
|
+
)
|
37
35
|
end
|
36
|
+
break
|
37
|
+
else
|
38
|
+
break
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
44
|
def fix(problem)
|
44
|
-
|
45
|
-
|
46
|
-
next_token = problem[:end_token].next_token
|
47
|
-
next_code_token = problem[:end_token].next_code_token
|
48
|
-
var_token = problem[:var_token]
|
49
|
-
|
50
|
-
tokens.delete(problem[:start_token])
|
51
|
-
tokens.delete(problem[:end_token])
|
45
|
+
remove_token(problem[:start_token])
|
46
|
+
remove_token(problem[:end_token])
|
52
47
|
|
53
|
-
|
54
|
-
prev_code_token.next_code_token = var_token unless prev_code_token.nil?
|
55
|
-
next_code_token.prev_code_token = var_token unless next_code_token.nil?
|
56
|
-
next_token.prev_token = var_token unless next_token.nil?
|
57
|
-
var_token.type = :VARIABLE
|
58
|
-
var_token.next_token = next_token
|
59
|
-
var_token.next_code_token = next_code_token
|
60
|
-
var_token.prev_code_token = prev_code_token
|
61
|
-
var_token.prev_token = prev_token
|
48
|
+
problem[:var_token].type = :VARIABLE
|
62
49
|
end
|
63
50
|
end
|
@@ -8,18 +8,19 @@ PuppetLint.new_check(:puppet_url_without_modules) do
|
|
8
8
|
tokens.select { |token|
|
9
9
|
(token.type == :SSTRING || token.type == :STRING || token.type == :DQPRE) && token.value.start_with?('puppet://')
|
10
10
|
}.reject { |token|
|
11
|
-
token.value[
|
11
|
+
token.value[%r{puppet://.*?/(.+)}, 1].start_with?('modules/') unless token.value[%r{puppet://.*?/(.+)}, 1].nil?
|
12
12
|
}.each do |token|
|
13
|
-
notify
|
13
|
+
notify(
|
14
|
+
:warning,
|
14
15
|
:message => 'puppet:// URL without modules/ found',
|
15
16
|
:line => token.line,
|
16
17
|
:column => token.column,
|
17
18
|
:token => token,
|
18
|
-
|
19
|
+
)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
23
|
def fix(problem)
|
23
|
-
problem[:token].value.gsub!(
|
24
|
+
problem[:token].value.gsub!(%r{(puppet://.*?/)}, '\1modules/')
|
24
25
|
end
|
25
26
|
end
|
@@ -11,12 +11,13 @@ PuppetLint.new_check(:quoted_booleans) do
|
|
11
11
|
tokens.select { |r|
|
12
12
|
STRING_TYPES.include?(r.type) && BOOLEANS.include?(r.value)
|
13
13
|
}.each do |token|
|
14
|
-
notify
|
14
|
+
notify(
|
15
|
+
:warning,
|
15
16
|
:message => 'quoted boolean value found',
|
16
17
|
:line => token.line,
|
17
18
|
:column => token.column,
|
18
19
|
:token => token,
|
19
|
-
|
20
|
+
)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|