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.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +74 -0
  3. data/.rubocop_todo.yml +89 -0
  4. data/.travis.yml +11 -9
  5. data/CHANGELOG.md +54 -0
  6. data/Gemfile +3 -0
  7. data/Rakefile +14 -3
  8. data/appveyor.yml +1 -4
  9. data/bin/puppet-lint +1 -1
  10. data/lib/puppet-lint.rb +25 -21
  11. data/lib/puppet-lint/bin.rb +15 -19
  12. data/lib/puppet-lint/checkplugin.rb +24 -17
  13. data/lib/puppet-lint/checks.rb +42 -31
  14. data/lib/puppet-lint/configuration.rb +11 -8
  15. data/lib/puppet-lint/data.rb +236 -164
  16. data/lib/puppet-lint/lexer.rb +225 -203
  17. data/lib/puppet-lint/lexer/token.rb +34 -18
  18. data/lib/puppet-lint/optparser.rb +33 -30
  19. data/lib/puppet-lint/plugins.rb +42 -38
  20. data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +26 -28
  21. data/lib/puppet-lint/plugins/check_classes/autoloader_layout.rb +21 -20
  22. data/lib/puppet-lint/plugins/check_classes/class_inherits_from_params_class.rb +8 -9
  23. data/lib/puppet-lint/plugins/check_classes/code_on_top_scope.rb +9 -8
  24. data/lib/puppet-lint/plugins/check_classes/inherits_across_namespaces.rb +12 -11
  25. data/lib/puppet-lint/plugins/check_classes/names_containing_dash.rb +13 -12
  26. data/lib/puppet-lint/plugins/check_classes/names_containing_uppercase.rb +14 -13
  27. data/lib/puppet-lint/plugins/check_classes/nested_classes_or_defines.rb +9 -10
  28. data/lib/puppet-lint/plugins/check_classes/parameter_order.rb +40 -31
  29. data/lib/puppet-lint/plugins/check_classes/right_to_left_relationship.rb +3 -2
  30. data/lib/puppet-lint/plugins/check_classes/variable_scope.rb +21 -24
  31. data/lib/puppet-lint/plugins/check_comments/slash_comments.rb +3 -2
  32. data/lib/puppet-lint/plugins/check_comments/star_comments.rb +6 -5
  33. data/lib/puppet-lint/plugins/check_conditionals/case_without_default.rb +21 -20
  34. data/lib/puppet-lint/plugins/check_conditionals/selector_inside_resource.rb +10 -13
  35. data/lib/puppet-lint/plugins/check_documentation/documentation.rb +26 -17
  36. data/lib/puppet-lint/plugins/check_nodes/unquoted_node_name.rb +11 -11
  37. data/lib/puppet-lint/plugins/check_resources/duplicate_params.rb +4 -3
  38. data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +17 -18
  39. data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +17 -16
  40. data/lib/puppet-lint/plugins/check_resources/file_mode.rb +22 -23
  41. data/lib/puppet-lint/plugins/check_resources/unquoted_file_mode.rb +14 -13
  42. data/lib/puppet-lint/plugins/check_resources/unquoted_resource_title.rb +9 -8
  43. data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +8 -8
  44. data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +29 -42
  45. data/lib/puppet-lint/plugins/check_strings/puppet_url_without_modules.rb +5 -4
  46. data/lib/puppet-lint/plugins/check_strings/quoted_booleans.rb +3 -2
  47. data/lib/puppet-lint/plugins/check_strings/single_quote_string_with_variables.rb +4 -3
  48. data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +3 -2
  49. data/lib/puppet-lint/plugins/check_variables/variable_contains_dash.rb +9 -8
  50. data/lib/puppet-lint/plugins/check_variables/variable_is_lowercase.rb +9 -8
  51. data/lib/puppet-lint/plugins/check_whitespace/140chars.rb +9 -9
  52. data/lib/puppet-lint/plugins/check_whitespace/2sp_soft_tabs.rb +4 -3
  53. data/lib/puppet-lint/plugins/check_whitespace/80chars.rb +10 -10
  54. data/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb +23 -22
  55. data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +3 -2
  56. data/lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb +3 -2
  57. data/lib/puppet-lint/tasks/puppet-lint.rb +3 -3
  58. data/lib/puppet-lint/version.rb +1 -1
  59. data/puppet-lint.gemspec +4 -4
  60. data/spec/puppet-lint/bin_spec.rb +268 -140
  61. data/spec/puppet-lint/checks_spec.rb +229 -0
  62. data/spec/puppet-lint/configuration_spec.rb +10 -9
  63. data/spec/puppet-lint/data_spec.rb +84 -0
  64. data/spec/puppet-lint/ignore_overrides_spec.rb +71 -40
  65. data/spec/puppet-lint/lexer/token_spec.rb +1 -1
  66. data/spec/puppet-lint/lexer_spec.rb +306 -73
  67. data/spec/puppet-lint/plugins/check_classes/arrow_on_right_operand_line_spec.rb +12 -6
  68. data/spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +10 -10
  69. data/spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb +15 -11
  70. data/spec/puppet-lint/plugins/check_classes/code_on_top_scope_spec.rb +26 -21
  71. data/spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +3 -3
  72. data/spec/puppet-lint/plugins/check_classes/name_contains_uppercase_spec.rb +4 -5
  73. data/spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +13 -0
  74. data/spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +33 -25
  75. data/spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb +80 -55
  76. data/spec/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +2 -2
  77. data/spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb +165 -130
  78. data/spec/puppet-lint/plugins/check_comments/slash_comments_spec.rb +2 -2
  79. data/spec/puppet-lint/plugins/check_comments/star_comments_spec.rb +53 -35
  80. data/spec/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +59 -49
  81. data/spec/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +18 -14
  82. data/spec/puppet-lint/plugins/check_documentation/documentation_spec.rb +14 -10
  83. data/spec/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb +7 -7
  84. data/spec/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +54 -44
  85. data/spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +114 -89
  86. data/spec/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +41 -30
  87. data/spec/puppet-lint/plugins/check_resources/file_mode_spec.rb +46 -40
  88. data/spec/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +46 -40
  89. data/spec/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +95 -71
  90. data/spec/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +28 -24
  91. data/spec/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +11 -9
  92. data/spec/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb +1 -2
  93. data/spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +18 -14
  94. data/spec/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +1 -1
  95. data/spec/puppet-lint/plugins/check_variables/variable_is_lowercase_spec.rb +1 -1
  96. data/spec/puppet-lint/plugins/check_whitespace/140chars_spec.rb +22 -15
  97. data/spec/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +8 -6
  98. data/spec/puppet-lint/plugins/check_whitespace/80chars_spec.rb +23 -29
  99. data/spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +588 -494
  100. data/spec/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +1 -1
  101. data/spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +27 -19
  102. data/spec/puppet-lint_spec.rb +2 -12
  103. data/spec/spec_helper.rb +35 -30
  104. metadata +6 -5
  105. data/lib/puppet-lint/monkeypatches.rb +0 -2
  106. data/lib/puppet-lint/monkeypatches/string_percent.rb +0 -52
  107. 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 :error, {
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
- unless token.value == 'default'
27
- notify :warning, {
28
- :message => 'unquoted node name found',
29
- :line => token.line,
30
- :column => token.column,
31
- :token => token,
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].each_with_index do |token, idx|
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 :error, {
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? resource[:type].type
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
- unless ensure_attr_index.nil?
15
- if ensure_attr_index > 0
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? or first_param_comma_token.nil? or ensure_param_name_token.nil? or ensure_param_comma_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
- if resource[:type].value == "file"
10
- resource[:param_tokens].select { |param_token|
11
- param_token.value == 'ensure'
12
- }.each do |ensure_token|
13
- value_token = ensure_token.next_code_token.next_code_token
14
- if value_token.value.start_with? '/'
15
- notify :warning, {
16
- :message => 'symlink target specified in ensure attr',
17
- :line => value_token.line,
18
- :column => value_token.column,
19
- :param_token => ensure_token,
20
- :value_token => value_token,
21
- }
22
- end
23
- end
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
- ].reverse.each do |new_token|
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 = "([ugoa]*[-=+][-=+rstwxXugo]*)(,[ugoa]*[-=+][-=+rstwxXugo]*)*"
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 = Regexp.new(/\A([0-7]{4}|#{SYM_RE})\Z/)
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
- if resource[:type].value == "file" or resource[:type].value == "concat"
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
- break if IGNORE_TYPES.include?(value_token.type)
21
- break if value_token.value =~ MODE_RE
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
- notify :warning, {
24
- :message => MSG,
25
- :line => value_token.line,
26
- :column => value_token.column,
27
- :token => value_token,
28
- }
29
- end
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
- if problem[:token].value =~ /\A[0-7]{3}\Z/
36
- problem[:token].type = :SSTRING
37
- problem[:token].value = "0#{problem[:token].value.to_s}"
38
- else
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
- if resource[:type].value == "file" or resource[:type].value == "concat"
12
- resource[:param_tokens].select { |param_token|
13
- param_token.value == 'mode' &&
14
- TOKEN_TYPES.include?(param_token.next_code_token.next_code_token.type)
15
- }.each do |param_token|
16
- value_token = param_token.next_code_token.next_code_token
17
- notify :warning, {
18
- :message => 'unquoted file mode',
19
- :line => value_token.line,
20
- :column => value_token.column,
21
- :token => value_token,
22
- }
23
- end
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
- if token.type == :NAME
9
- notify :warning, {
10
- :message => 'unquoted resource title',
11
- :line => token.line,
12
- :column => token.column,
13
- :token => token,
14
- }
15
- end
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
- }.map { |token|
11
- [token, token.value.gsub(' '*token.column, "\n")]
12
- }.select { |token, sane_value|
13
- sane_value[/(\\\$|\\"|\\'|'|\r|\t|\\t|\n|\\n|\\\\)/].nil?
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
- if start_token.type == :DQPRE and start_token.value == ''
11
- var_token = start_token.next_token
12
- if VAR_TYPES.include? var_token.type
13
- eos_offset = 2
14
- loop do
15
- eos_token = tokens[start_token_idx + eos_offset]
16
- case eos_token.type
17
- when :LBRACK
18
- eos_offset += 3
19
- when :DQPOST
20
- if eos_token.value == ''
21
- if eos_token.next_code_token && eos_token.next_code_token.type == :FARROW
22
- break
23
- end
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
- prev_token = problem[:start_token].prev_token
45
- prev_code_token = problem[:start_token].prev_code_token
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
- prev_token.next_token = var_token unless prev_token.nil?
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[/puppet:\/\/.*?\/(.+)/, 1].start_with?('modules/') unless token.value[/puppet:\/\/.*?\/(.+)/, 1].nil?
11
+ token.value[%r{puppet://.*?/(.+)}, 1].start_with?('modules/') unless token.value[%r{puppet://.*?/(.+)}, 1].nil?
12
12
  }.each do |token|
13
- notify :warning, {
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!(/(puppet:\/\/.*?\/)/, '\1modules/')
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 :warning, {
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