puppet-lint 2.5.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +522 -0
- data/lib/puppet-lint/bin.rb +71 -6
- data/lib/puppet-lint/checkplugin.rb +43 -9
- data/lib/puppet-lint/checks.rb +16 -16
- data/lib/puppet-lint/configuration.rb +134 -134
- data/lib/puppet-lint/data.rb +28 -28
- data/lib/puppet-lint/lexer/string_slurper.rb +138 -140
- data/lib/puppet-lint/lexer/token.rb +188 -190
- data/lib/puppet-lint/lexer.rb +416 -417
- data/lib/puppet-lint/monkeypatches.rb +1 -1
- data/lib/puppet-lint/optparser.rb +5 -1
- data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +6 -4
- data/lib/puppet-lint/plugins/check_classes/autoloader_layout.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/class_inherits_from_params_class.rb +6 -4
- data/lib/puppet-lint/plugins/check_classes/code_on_top_scope.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/inherits_across_namespaces.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/names_containing_dash.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/names_containing_uppercase.rb +7 -5
- data/lib/puppet-lint/plugins/check_classes/nested_classes_or_defines.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/parameter_order.rb +7 -4
- data/lib/puppet-lint/plugins/check_classes/right_to_left_relationship.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/variable_scope.rb +15 -13
- data/lib/puppet-lint/plugins/check_comments/slash_comments.rb +9 -7
- data/lib/puppet-lint/plugins/check_comments/star_comments.rb +10 -8
- data/lib/puppet-lint/plugins/check_conditionals/case_without_default.rb +6 -4
- data/lib/puppet-lint/plugins/check_conditionals/selector_inside_resource.rb +5 -3
- data/lib/puppet-lint/plugins/check_documentation/documentation.rb +7 -3
- data/lib/puppet-lint/plugins/check_nodes/unquoted_node_name.rb +15 -11
- data/lib/puppet-lint/plugins/check_resources/duplicate_params.rb +5 -3
- data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +8 -5
- data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +11 -8
- data/lib/puppet-lint/plugins/check_resources/file_mode.rb +14 -9
- data/lib/puppet-lint/plugins/check_resources/unquoted_file_mode.rb +11 -6
- data/lib/puppet-lint/plugins/check_resources/unquoted_resource_title.rb +6 -4
- data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +12 -7
- data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +8 -6
- data/lib/puppet-lint/plugins/check_strings/puppet_url_without_modules.rb +14 -8
- data/lib/puppet-lint/plugins/check_strings/quoted_booleans.rb +11 -7
- data/lib/puppet-lint/plugins/check_strings/single_quote_string_with_variables.rb +11 -6
- data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +12 -8
- data/lib/puppet-lint/plugins/check_variables/variable_contains_dash.rb +11 -7
- data/lib/puppet-lint/plugins/check_variables/variable_is_lowercase.rb +11 -7
- data/lib/puppet-lint/plugins/check_whitespace/140chars.rb +3 -8
- data/lib/puppet-lint/plugins/check_whitespace/2sp_soft_tabs.rb +10 -8
- data/lib/puppet-lint/plugins/check_whitespace/80chars.rb +3 -8
- data/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb +10 -8
- data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +11 -7
- data/lib/puppet-lint/plugins/check_whitespace/line_length.rb +29 -0
- data/lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb +13 -7
- data/lib/puppet-lint/plugins.rb +63 -61
- data/lib/puppet-lint/report/github.rb +17 -0
- data/lib/puppet-lint/report/sarif_template.json +63 -0
- data/lib/puppet-lint/tasks/puppet-lint.rb +84 -83
- data/lib/puppet-lint/tasks/release_test.rb +4 -1
- data/lib/puppet-lint/version.rb +1 -1
- data/lib/puppet-lint.rb +27 -12
- data/spec/acceptance/puppet_lint_spec.rb +46 -0
- data/spec/spec_helper.rb +92 -91
- data/spec/spec_helper_acceptance.rb +6 -0
- data/spec/spec_helper_acceptance_local.rb +38 -0
- data/spec/{puppet-lint → unit/puppet-lint}/bin_spec.rb +79 -35
- data/spec/{puppet-lint → unit/puppet-lint}/checks_spec.rb +36 -36
- data/spec/unit/puppet-lint/configuration_spec.rb +88 -0
- data/spec/{puppet-lint → unit/puppet-lint}/data_spec.rb +6 -3
- data/spec/{puppet-lint → unit/puppet-lint}/ignore_overrides_spec.rb +17 -17
- data/spec/{puppet-lint → unit/puppet-lint}/lexer/string_slurper_spec.rb +128 -128
- data/spec/{puppet-lint → unit/puppet-lint}/lexer/token_spec.rb +1 -1
- data/spec/{puppet-lint → unit/puppet-lint}/lexer_spec.rb +653 -671
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/arrow_on_right_operand_line_spec.rb +16 -16
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/autoloader_layout_spec.rb +13 -13
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/class_inherits_from_params_class_spec.rb +3 -3
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/code_on_top_scope_spec.rb +4 -4
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/inherits_across_namespaces_spec.rb +4 -4
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/name_contains_uppercase_spec.rb +10 -10
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/names_containing_dash_spec.rb +7 -7
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/nested_classes_or_defines_spec.rb +7 -7
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/parameter_order_spec.rb +9 -9
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/right_to_left_relationship_spec.rb +3 -3
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/variable_scope_spec.rb +25 -25
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_comments/slash_comments_spec.rb +7 -7
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_comments/star_comments_spec.rb +13 -13
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_conditionals/case_without_default_spec.rb +10 -10
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_conditionals/selector_inside_resource_spec.rb +3 -3
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_documentation/documentation_spec.rb +8 -8
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_nodes/unquoted_node_name_spec.rb +24 -24
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/duplicate_params_spec.rb +9 -9
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/ensure_first_param_spec.rb +19 -19
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/ensure_not_symlink_target_spec.rb +10 -10
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/file_mode_spec.rb +40 -40
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/unquoted_file_mode_spec.rb +20 -20
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/unquoted_resource_title_spec.rb +24 -24
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/double_quoted_strings_spec.rb +28 -27
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/only_variable_string_spec.rb +18 -18
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/puppet_url_without_modules_spec.rb +9 -9
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/quoted_booleans_spec.rb +22 -22
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/single_quote_string_with_variables_spec.rb +2 -2
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/variables_not_enclosed_spec.rb +21 -21
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_variables/variable_contains_dash_spec.rb +6 -6
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_variables/variable_is_lowercase_spec.rb +7 -7
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/140chars_spec.rb +5 -5
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/2sp_soft_tabs_spec.rb +2 -2
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/80chars_spec.rb +6 -6
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/arrow_alignment_spec.rb +127 -127
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/hard_tabs_spec.rb +7 -7
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/trailing_whitespace_spec.rb +15 -15
- data/spec/unit/puppet-lint/puppet-lint_spec.rb +18 -0
- metadata +69 -120
- data/CHANGELOG.md +0 -1130
- data/spec/puppet-lint/configuration_spec.rb +0 -66
- data/spec/puppet-lint_spec.rb +0 -16
@@ -41,7 +41,7 @@ class PuppetLint::CheckPlugin
|
|
41
41
|
begin
|
42
42
|
fix(problem)
|
43
43
|
problem[:kind] = :fixed
|
44
|
-
rescue PuppetLint::NoFix
|
44
|
+
rescue PuppetLint::NoFix
|
45
45
|
# noop
|
46
46
|
end
|
47
47
|
end
|
@@ -105,6 +105,38 @@ class PuppetLint::CheckPlugin
|
|
105
105
|
PuppetLint::Data.node_indexes
|
106
106
|
end
|
107
107
|
|
108
|
+
# Public: Provides positional information for any array definitions in the
|
109
|
+
# tokens array to the check plugins.
|
110
|
+
#
|
111
|
+
# Returns an array of hashes containing the position information.
|
112
|
+
def array_indexes
|
113
|
+
PuppetLint::Data.array_indexes
|
114
|
+
end
|
115
|
+
|
116
|
+
# Public: Provides positional information for any hash definitions in the
|
117
|
+
# tokens array to the check plugins.
|
118
|
+
#
|
119
|
+
# Returns an array of hashes containing the position information.
|
120
|
+
def hash_indexes
|
121
|
+
PuppetLint::Data.hash_indexes
|
122
|
+
end
|
123
|
+
|
124
|
+
# Public: Provides positional information for any default definitions in the
|
125
|
+
# tokens array to the check plugins.
|
126
|
+
#
|
127
|
+
# Returns an Array of Hashes containing the position information.
|
128
|
+
def defaults_indexes
|
129
|
+
PuppetLint::Data.defaults_indexes
|
130
|
+
end
|
131
|
+
|
132
|
+
# Public: Provides positional information for any function definition in the
|
133
|
+
# tokens array to the check plugins.
|
134
|
+
#
|
135
|
+
# Returns an Array of Hashes containing the position information.
|
136
|
+
def function_indexes
|
137
|
+
PuppetLint::Data.function_indexes
|
138
|
+
end
|
139
|
+
|
108
140
|
# Public: Provides the expanded path of the file being analysed to check
|
109
141
|
# plugins.
|
110
142
|
#
|
@@ -147,10 +179,10 @@ class PuppetLint::CheckPlugin
|
|
147
179
|
# Returns a Hash of default problem information.
|
148
180
|
def default_info
|
149
181
|
@default_info ||= {
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
153
|
-
:
|
182
|
+
check: self.class.const_get('NAME'),
|
183
|
+
fullpath: fullpath,
|
184
|
+
path: path,
|
185
|
+
filename: filename,
|
154
186
|
}
|
155
187
|
end
|
156
188
|
|
@@ -158,10 +190,12 @@ class PuppetLint::CheckPlugin
|
|
158
190
|
#
|
159
191
|
# kind - The Symbol problem type (:warning or :error).
|
160
192
|
# problem - A Hash containing the attributes of the problem
|
161
|
-
# :message
|
162
|
-
# :line
|
163
|
-
# :column
|
164
|
-
# :check
|
193
|
+
# :message - The String message describing the problem.
|
194
|
+
# :line - The Integer line number of the location of the problem.
|
195
|
+
# :column - The Integer column number of the location of the problem.
|
196
|
+
# :check - The Symbol name of the check that detected the problem.
|
197
|
+
# :description - The description of the check that detected the problem.
|
198
|
+
# :help_uri - The help web page of the check that detected the problem.
|
165
199
|
#
|
166
200
|
# Returns nothing.
|
167
201
|
def notify(kind, problem)
|
data/lib/puppet-lint/checks.rb
CHANGED
@@ -32,14 +32,14 @@ class PuppetLint::Checks
|
|
32
32
|
end
|
33
33
|
|
34
34
|
problems << {
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
35
|
+
kind: :error,
|
36
|
+
check: :syntax,
|
37
|
+
message: message,
|
38
|
+
line: e.line_no,
|
39
|
+
column: e.column,
|
40
|
+
fullpath: PuppetLint::Data.fullpath,
|
41
|
+
path: PuppetLint::Data.path,
|
42
|
+
filename: PuppetLint::Data.filename,
|
43
43
|
}
|
44
44
|
PuppetLint::Data.tokens = []
|
45
45
|
end
|
@@ -73,14 +73,14 @@ class PuppetLint::Checks
|
|
73
73
|
@problems
|
74
74
|
rescue PuppetLint::SyntaxError => e
|
75
75
|
@problems << {
|
76
|
-
:
|
77
|
-
:
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
76
|
+
kind: :error,
|
77
|
+
check: :syntax,
|
78
|
+
message: 'Syntax error',
|
79
|
+
fullpath: File.expand_path(fileinfo, ENV['PWD']),
|
80
|
+
filename: File.basename(fileinfo),
|
81
|
+
path: fileinfo,
|
82
|
+
line: e.token.line,
|
83
|
+
column: e.token.column,
|
84
84
|
}
|
85
85
|
|
86
86
|
@problems
|
@@ -1,157 +1,157 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
settings["#{check}_disabled"] == true ? false : true
|
23
|
-
end
|
24
|
-
|
25
|
-
# Public: Disable the named check.
|
26
|
-
#
|
27
|
-
# Returns nothing.
|
28
|
-
define_method("disable_#{check}") do
|
29
|
-
settings["#{check}_disabled"] = true
|
30
|
-
end
|
31
|
-
|
32
|
-
# Public: Enable the named check.
|
33
|
-
#
|
34
|
-
# Returns nothing.
|
35
|
-
define_method("enable_#{check}") do
|
36
|
-
settings["#{check}_disabled"] = false
|
37
|
-
end
|
1
|
+
# Public: A singleton class to store the running configuration of
|
2
|
+
# puppet-lint.
|
3
|
+
class PuppetLint::Configuration
|
4
|
+
# Internal: Add helper methods for a new check to the
|
5
|
+
# PuppetLint::Configuration object.
|
6
|
+
#
|
7
|
+
# check - The String name of the check.
|
8
|
+
#
|
9
|
+
# Returns nothing.
|
10
|
+
#
|
11
|
+
# Signature
|
12
|
+
#
|
13
|
+
# <check>_enabled?
|
14
|
+
# disable_<check>
|
15
|
+
# enable_<check>
|
16
|
+
def self.add_check(check)
|
17
|
+
# Public: Determine if the named check is enabled.
|
18
|
+
#
|
19
|
+
# Returns true if the check is enabled, otherwise return false.
|
20
|
+
define_method("#{check}_enabled?") do
|
21
|
+
settings["#{check}_disabled"] == true ? false : true
|
38
22
|
end
|
39
23
|
|
40
|
-
# Public:
|
41
|
-
# and create the necessary methods to get & set the option in the future.
|
42
|
-
#
|
43
|
-
# args - An Array of values to set the option to.
|
44
|
-
# method - The String name of the option.
|
45
|
-
# block - Unused.
|
24
|
+
# Public: Disable the named check.
|
46
25
|
#
|
47
26
|
# Returns nothing.
|
48
|
-
#
|
49
|
-
|
50
|
-
#
|
51
|
-
# <option>=(value)
|
52
|
-
def method_missing(method, *args, &_block)
|
53
|
-
super unless method.to_s =~ %r{^(\w+)=?$}
|
54
|
-
|
55
|
-
option = Regexp.last_match(1)
|
56
|
-
add_option(option.to_s) if settings[option].nil?
|
57
|
-
settings[option] = args[0] unless args.empty?
|
27
|
+
define_method("disable_#{check}") do
|
28
|
+
settings["#{check}_disabled"] = true
|
58
29
|
end
|
59
30
|
|
60
|
-
|
61
|
-
method.to_s =~ %r{^\w+=?$} || super
|
62
|
-
end
|
63
|
-
|
64
|
-
# Internal: Add options to the PuppetLint::Configuration object from inside
|
65
|
-
# the class.
|
66
|
-
#
|
67
|
-
# option - The String name of the option.
|
31
|
+
# Public: Enable the named check.
|
68
32
|
#
|
69
33
|
# Returns nothing.
|
70
|
-
#
|
71
|
-
|
72
|
-
#
|
73
|
-
# <option>
|
74
|
-
# <option>=(value)
|
75
|
-
def add_option(option)
|
76
|
-
self.class.add_option(option)
|
34
|
+
define_method("enable_#{check}") do
|
35
|
+
settings["#{check}_disabled"] = false
|
77
36
|
end
|
37
|
+
end
|
78
38
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
# value - The value to set the option to.
|
94
|
-
#
|
95
|
-
# Returns nothing.
|
96
|
-
define_method("#{option}=") do |value|
|
97
|
-
settings[option] = value
|
98
|
-
end
|
39
|
+
# Public: Catch situations where options are being set for the first time
|
40
|
+
# and create the necessary methods to get & set the option in the future.
|
41
|
+
#
|
42
|
+
# args - An Array of values to set the option to.
|
43
|
+
# method - The String name of the option.
|
44
|
+
# block - Unused.
|
45
|
+
#
|
46
|
+
# Returns nothing.
|
47
|
+
#
|
48
|
+
# Signature
|
49
|
+
#
|
50
|
+
# <option>=(value)
|
51
|
+
def method_missing(method, *args, &_block)
|
52
|
+
super unless method.to_s =~ %r{^(\w+)=?$}
|
99
53
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
settings[option]
|
105
|
-
end
|
106
|
-
end
|
54
|
+
option = Regexp.last_match(1)
|
55
|
+
add_option(option.to_s) if settings[option].nil?
|
56
|
+
settings[option] = args[0] unless args.empty?
|
57
|
+
end
|
107
58
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
59
|
+
def respond_to_missing?(method, *)
|
60
|
+
method.to_s =~ %r{^\w+=?$} || super
|
61
|
+
end
|
62
|
+
|
63
|
+
# Internal: Add options to the PuppetLint::Configuration object from inside
|
64
|
+
# the class.
|
65
|
+
#
|
66
|
+
# option - The String name of the option.
|
67
|
+
#
|
68
|
+
# Returns nothing.
|
69
|
+
#
|
70
|
+
# Signature
|
71
|
+
#
|
72
|
+
# <option>
|
73
|
+
# <option>=(value)
|
74
|
+
def add_option(option)
|
75
|
+
self.class.add_option(option)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Public: Add an option to the PuppetLint::Configuration object from
|
79
|
+
# outside the class.
|
80
|
+
#
|
81
|
+
# option - The String name of the option.
|
82
|
+
#
|
83
|
+
# Returns nothing.
|
84
|
+
#
|
85
|
+
# Signature
|
86
|
+
#
|
87
|
+
# <option>
|
88
|
+
# <option>=(value)
|
89
|
+
def self.add_option(option)
|
90
|
+
# Public: Set the value of the named option.
|
91
|
+
#
|
92
|
+
# value - The value to set the option to.
|
112
93
|
#
|
113
94
|
# Returns nothing.
|
114
|
-
|
115
|
-
|
116
|
-
check_object[check] = klass
|
95
|
+
define_method("#{option}=") do |value|
|
96
|
+
settings[option] = value
|
117
97
|
end
|
118
98
|
|
119
|
-
#
|
99
|
+
# Public: Get the value of the named option.
|
120
100
|
#
|
121
|
-
# Returns
|
122
|
-
|
123
|
-
|
101
|
+
# Returns the value of the option.
|
102
|
+
define_method(option) do
|
103
|
+
settings[option]
|
124
104
|
end
|
105
|
+
end
|
125
106
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
107
|
+
# Internal: Register a new check.
|
108
|
+
#
|
109
|
+
# check - The String name of the check
|
110
|
+
# klass - The Class containing the check logic.
|
111
|
+
#
|
112
|
+
# Returns nothing.
|
113
|
+
def add_check(check, klass)
|
114
|
+
self.class.add_check(check)
|
115
|
+
check_object[check] = klass
|
116
|
+
end
|
132
117
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
118
|
+
# Internal: Access the internal storage for settings.
|
119
|
+
#
|
120
|
+
# Returns a Hash containing all the settings.
|
121
|
+
def settings
|
122
|
+
@settings ||= {}
|
123
|
+
end
|
139
124
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
125
|
+
# Internal: Access the internal storage for check method blocks.
|
126
|
+
#
|
127
|
+
# Returns a Hash containing all the check blocks.
|
128
|
+
def check_object
|
129
|
+
@check_object ||= {}
|
130
|
+
end
|
131
|
+
|
132
|
+
# Public: Get a list of all the defined checks.
|
133
|
+
#
|
134
|
+
# Returns an Array of String check names.
|
135
|
+
def checks
|
136
|
+
check_object.keys
|
137
|
+
end
|
138
|
+
|
139
|
+
# Public: Clear the PuppetLint::Configuration storage and set some sane
|
140
|
+
# default values.
|
141
|
+
#
|
142
|
+
# Returns nothing.
|
143
|
+
def defaults
|
144
|
+
settings.clear
|
145
|
+
self.with_filename = false
|
146
|
+
self.fail_on_warnings = false
|
147
|
+
self.error_level = :all
|
148
|
+
self.log_format = ''
|
149
|
+
self.with_context = false
|
150
|
+
self.fix = false
|
151
|
+
self.json = false
|
152
|
+
self.sarif = false
|
153
|
+
self.show_ignored = false
|
154
|
+
self.ignore_paths = ['vendor/**/*.pp']
|
155
|
+
self.github_actions = ENV.key?('GITHUB_ACTION')
|
156
156
|
end
|
157
157
|
end
|
data/lib/puppet-lint/data.rb
CHANGED
@@ -143,7 +143,7 @@ class PuppetLint::Data
|
|
143
143
|
end
|
144
144
|
title_array_tokens = tokens[(array_start_idx + 1)..(token_idx - 2)]
|
145
145
|
result += title_array_tokens.select do |token|
|
146
|
-
{ :
|
146
|
+
{ STRING: true, NAME: true }.include?(token.type)
|
147
147
|
end
|
148
148
|
else
|
149
149
|
next_token = tokens[token_idx].next_code_token
|
@@ -180,11 +180,11 @@ class PuppetLint::Data
|
|
180
180
|
marker = rel_end_idx + start_idx
|
181
181
|
|
182
182
|
result << {
|
183
|
-
:
|
184
|
-
:
|
185
|
-
:
|
186
|
-
:
|
187
|
-
:
|
183
|
+
start: start_idx + 1,
|
184
|
+
end: marker,
|
185
|
+
tokens: tokens[start_idx..marker],
|
186
|
+
type: find_resource_type_token(start_idx),
|
187
|
+
param_tokens: find_resource_param_tokens(tokens[start_idx..marker]),
|
188
188
|
}
|
189
189
|
end
|
190
190
|
result
|
@@ -310,13 +310,13 @@ class PuppetLint::Data
|
|
310
310
|
if brace_depth.zero? && !in_params
|
311
311
|
if token.next_code_token.type != :LBRACE
|
312
312
|
result << {
|
313
|
-
:
|
314
|
-
:
|
315
|
-
:
|
316
|
-
:
|
317
|
-
:
|
318
|
-
:
|
319
|
-
:
|
313
|
+
start: i,
|
314
|
+
end: i + j + 1,
|
315
|
+
tokens: tokens[i..(i + j + 1)],
|
316
|
+
param_tokens: param_tokens(tokens[i..(i + j + 1)]),
|
317
|
+
type: type,
|
318
|
+
name_token: token.next_code_token,
|
319
|
+
inherited_token: inherited_class,
|
320
320
|
}
|
321
321
|
break
|
322
322
|
end
|
@@ -367,9 +367,9 @@ class PuppetLint::Data
|
|
367
367
|
end
|
368
368
|
|
369
369
|
functions << {
|
370
|
-
:
|
371
|
-
:
|
372
|
-
:
|
370
|
+
start: token_idx,
|
371
|
+
end: real_idx,
|
372
|
+
tokens: tokens[token_idx..real_idx],
|
373
373
|
}
|
374
374
|
end
|
375
375
|
functions
|
@@ -403,9 +403,9 @@ class PuppetLint::Data
|
|
403
403
|
token.prev_code_token.type == :CLASSREF
|
404
404
|
|
405
405
|
arrays << {
|
406
|
-
:
|
407
|
-
:
|
408
|
-
:
|
406
|
+
start: token_idx,
|
407
|
+
end: real_idx,
|
408
|
+
tokens: tokens[token_idx..real_idx],
|
409
409
|
}
|
410
410
|
end
|
411
411
|
arrays
|
@@ -441,9 +441,9 @@ class PuppetLint::Data
|
|
441
441
|
end
|
442
442
|
|
443
443
|
hashes << {
|
444
|
-
:
|
445
|
-
:
|
446
|
-
:
|
444
|
+
start: token_idx,
|
445
|
+
end: real_idx,
|
446
|
+
tokens: tokens[token_idx..real_idx],
|
447
447
|
}
|
448
448
|
end
|
449
449
|
hashes
|
@@ -475,9 +475,9 @@ class PuppetLint::Data
|
|
475
475
|
end
|
476
476
|
|
477
477
|
defaults << {
|
478
|
-
:
|
479
|
-
:
|
480
|
-
:
|
478
|
+
start: token_idx,
|
479
|
+
end: real_idx,
|
480
|
+
tokens: tokens[token_idx..real_idx],
|
481
481
|
}
|
482
482
|
end
|
483
483
|
defaults
|
@@ -561,7 +561,7 @@ class PuppetLint::Data
|
|
561
561
|
|
562
562
|
comment_words = token.value.strip.split(%r{\s+})
|
563
563
|
comment_words.each_with_index do |word, i|
|
564
|
-
if
|
564
|
+
if %r{\Alint\:(ignore|endignore)}.match?(word)
|
565
565
|
comment_data << word
|
566
566
|
else
|
567
567
|
# Once we reach the first non-controlcomment word, assume the rest
|
@@ -591,7 +591,7 @@ class PuppetLint::Data
|
|
591
591
|
if top_override.nil?
|
592
592
|
# TODO: refactor to provide a way to expose problems from
|
593
593
|
# PuppetLint::Data via the normal problem reporting mechanism.
|
594
|
-
puts "WARNING: lint:endignore comment with no opening lint:ignore:<check> comment found on line #{token.line}"
|
594
|
+
$stderr.puts "WARNING: lint:endignore comment with no opening lint:ignore:<check> comment found on line #{token.line}"
|
595
595
|
else
|
596
596
|
top_override.each do |start|
|
597
597
|
next if start.nil?
|
@@ -607,7 +607,7 @@ class PuppetLint::Data
|
|
607
607
|
end
|
608
608
|
|
609
609
|
stack.each do |control|
|
610
|
-
puts "WARNING: lint:ignore:#{control[0][2]} comment on line #{control[0][0]} with no closing lint:endignore comment"
|
610
|
+
$stderr.puts "WARNING: lint:ignore:#{control[0][2]} comment on line #{control[0][0]} with no closing lint:endignore comment"
|
611
611
|
end
|
612
612
|
end
|
613
613
|
end
|