puppet-lint 0.4.0.pre1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +3 -4
- data/Gemfile +2 -5
- data/README.md +2 -149
- data/Rakefile +0 -5
- data/lib/puppet-lint.rb +74 -20
- data/lib/puppet-lint/bin.rb +20 -85
- data/lib/puppet-lint/checkplugin.rb +158 -12
- data/lib/puppet-lint/checks.rb +39 -222
- data/lib/puppet-lint/configuration.rb +12 -31
- data/lib/puppet-lint/data.rb +329 -0
- data/lib/puppet-lint/lexer.rb +37 -30
- data/lib/puppet-lint/lexer/token.rb +14 -16
- data/lib/puppet-lint/monkeypatches/string_prepend.rb +6 -0
- data/lib/puppet-lint/optparser.rb +105 -0
- data/lib/puppet-lint/plugins.rb +28 -9
- data/lib/puppet-lint/plugins/check_classes.rb +162 -238
- data/lib/puppet-lint/plugins/check_comments.rb +40 -25
- data/lib/puppet-lint/plugins/check_conditionals.rb +16 -20
- data/lib/puppet-lint/plugins/check_documentation.rb +14 -20
- data/lib/puppet-lint/plugins/check_nodes.rb +23 -0
- data/lib/puppet-lint/plugins/check_resources.rb +127 -141
- data/lib/puppet-lint/plugins/check_strings.rb +133 -107
- data/lib/puppet-lint/plugins/check_variables.rb +11 -11
- data/lib/puppet-lint/plugins/check_whitespace.rb +86 -92
- data/lib/puppet-lint/tasks/puppet-lint.rb +17 -1
- data/lib/puppet-lint/version.rb +1 -1
- data/puppet-lint.gemspec +4 -2
- data/spec/fixtures/test/manifests/ignore.pp +1 -0
- data/spec/fixtures/test/manifests/ignore_reason.pp +1 -0
- data/spec/puppet-lint/bin_spec.rb +104 -84
- data/spec/puppet-lint/configuration_spec.rb +19 -19
- data/spec/puppet-lint/ignore_overrides_spec.rb +97 -0
- data/spec/puppet-lint/lexer/token_spec.rb +9 -9
- data/spec/puppet-lint/lexer_spec.rb +352 -325
- data/spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +77 -23
- data/spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb +14 -12
- data/spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +18 -14
- data/spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +30 -30
- data/spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +31 -26
- data/spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb +34 -28
- data/spec/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +14 -12
- data/spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb +74 -30
- data/spec/puppet-lint/plugins/check_comments/slash_comments_spec.rb +27 -20
- data/spec/puppet-lint/plugins/check_comments/star_comments_spec.rb +78 -13
- data/spec/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +17 -12
- data/spec/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +13 -10
- data/spec/puppet-lint/plugins/check_documentation/documentation_spec.rb +21 -16
- data/spec/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb +69 -0
- data/spec/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +42 -38
- data/spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +22 -10
- data/spec/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +81 -18
- data/spec/puppet-lint/plugins/check_resources/file_mode_spec.rb +69 -112
- data/spec/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +27 -20
- data/spec/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +177 -171
- data/spec/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +165 -88
- data/spec/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +97 -22
- data/spec/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb +25 -0
- data/spec/puppet-lint/plugins/check_strings/quoted_booleans_spec.rb +97 -111
- data/spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +10 -9
- data/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb +53 -53
- data/spec/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +26 -14
- data/spec/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +10 -9
- data/spec/puppet-lint/plugins/check_whitespace/80chars_spec.rb +31 -15
- data/spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +340 -322
- data/spec/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +30 -23
- data/spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +42 -41
- data/spec/puppet-lint_spec.rb +3 -3
- data/spec/spec_helper.rb +109 -116
- metadata +109 -50
- data/spec/puppet-lint/plugins/check_classes/class_parameter_defaults_spec.rb +0 -60
@@ -1,42 +1,48 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'autoloader_layout' do
|
4
|
-
|
4
|
+
context 'foo::bar in foo/manifests/bar.pp' do
|
5
5
|
let(:code) { "class foo::bar { }" }
|
6
|
-
let(:
|
6
|
+
let(:path) { 'foo/manifests/bar.pp' }
|
7
7
|
|
8
|
-
|
8
|
+
it 'should not detect any problems' do
|
9
|
+
expect(problems).to have(0).problems
|
10
|
+
end
|
9
11
|
end
|
10
12
|
|
11
|
-
|
13
|
+
context 'foo::bar::baz in foo/manifests/bar/baz.pp' do
|
12
14
|
let(:code) { 'define foo::bar::baz() { }' }
|
13
|
-
let(:
|
15
|
+
let(:path) { 'foo/manifests/bar/baz.pp' }
|
14
16
|
|
15
|
-
|
17
|
+
it 'should not detect any problems' do
|
18
|
+
expect(problems).to have(0).problems
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
|
-
|
22
|
+
context 'foo in foo/manifests/init.pp' do
|
19
23
|
let(:code) { 'class foo { }' }
|
20
|
-
let(:
|
24
|
+
let(:path) { 'foo/manifests/init.pp' }
|
21
25
|
|
22
|
-
|
26
|
+
it 'should not detect any problems' do
|
27
|
+
expect(problems).to have(0).problems
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
|
-
|
31
|
+
context 'foo::bar in foo/manifests/init.pp' do
|
26
32
|
let(:code) { 'class foo::bar { }' }
|
27
|
-
let(:
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
let(:path) { 'foo/manifests/init.pp' }
|
34
|
+
let(:msg) { 'foo::bar not in autoload module layout' }
|
35
|
+
|
36
|
+
it 'should only detect a single problem' do
|
37
|
+
expect(problems).to have(1).problem
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should create an error' do
|
41
|
+
expect(problems).to contain_error(msg).on_line(1).in_column(7)
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
|
-
|
45
|
+
context 'foo included in bar/manifests/init.pp' do
|
40
46
|
let(:code) { "
|
41
47
|
class bar {
|
42
48
|
class {'foo':
|
@@ -45,7 +51,55 @@ describe 'autoloader_layout' do
|
|
45
51
|
}
|
46
52
|
"
|
47
53
|
}
|
48
|
-
let(:
|
49
|
-
|
54
|
+
let(:path) { 'bar/manifests/init.pp' }
|
55
|
+
|
56
|
+
it 'should not detect any problems' do
|
57
|
+
expect(problems).to have(0).problems
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'foo in puppet-foo/manifests/init.pp' do
|
62
|
+
let(:code) { 'class foo { }' }
|
63
|
+
let(:path) { 'puppet-foo/manifests/init.pp' }
|
64
|
+
|
65
|
+
it 'should detect a single problem' do
|
66
|
+
expect(problems).to have(1).problems
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'foo in puppet-foo/manifests/bar.pp with relative option' do
|
71
|
+
before do
|
72
|
+
PuppetLint.configuration.relative = true
|
73
|
+
end
|
74
|
+
|
75
|
+
after do
|
76
|
+
PuppetLint.configuration.relative = false
|
77
|
+
end
|
78
|
+
|
79
|
+
let(:code) { 'class foo { }' }
|
80
|
+
let(:path) { 'puppet-foo/manifests/bar.pp' }
|
81
|
+
|
82
|
+
it 'should detect a single problem' do
|
83
|
+
expect(problems).to have(1).problems
|
84
|
+
end
|
50
85
|
end
|
86
|
+
|
87
|
+
context 'foo in puppet-foo/manifests/init.pp with relative option' do
|
88
|
+
before do
|
89
|
+
PuppetLint.configuration.relative = true
|
90
|
+
end
|
91
|
+
|
92
|
+
after do
|
93
|
+
PuppetLint.configuration.relative = false
|
94
|
+
end
|
95
|
+
|
96
|
+
let(:code) { 'class foo { }' }
|
97
|
+
let(:path) { 'puppet-foo/manifests/init.pp' }
|
98
|
+
|
99
|
+
it 'should not detect any problems' do
|
100
|
+
expect(problems).to have(0).problems
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
51
105
|
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'class_inherits_from_params_class' do
|
4
|
-
|
4
|
+
let(:msg) { 'class inheriting from params class' }
|
5
|
+
|
6
|
+
context 'parameterised class that inherits from a params class' do
|
5
7
|
let(:code) { "
|
6
8
|
# commented
|
7
9
|
class foo($bar = $name) inherits foo::params { }"
|
8
10
|
}
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
should_not have_problem :kind => :error
|
18
|
-
}
|
12
|
+
it 'should only detect a single problem' do
|
13
|
+
expect(problems).to have(1).problem
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should create a warning' do
|
17
|
+
expect(problems).to contain_warning(msg).on_line(3).in_column(40)
|
18
|
+
end
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
context 'class without parameters' do
|
22
22
|
let(:code) {"
|
23
23
|
class myclass {
|
24
24
|
|
@@ -28,6 +28,8 @@ describe 'class_inherits_from_params_class' do
|
|
28
28
|
}
|
29
29
|
"}
|
30
30
|
|
31
|
-
|
31
|
+
it 'should not detect any problems' do
|
32
|
+
expect(problems).to have(0).problems
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
@@ -1,29 +1,33 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'inherits_across_namespaces' do
|
4
|
-
|
4
|
+
let(:msg) { 'class inherits across module namespaces' }
|
5
|
+
|
6
|
+
context 'class inheriting from parent in same module namespace' do
|
5
7
|
let(:code) { "class foo::bar inherits foo { }" }
|
6
8
|
|
7
|
-
|
9
|
+
it 'should not detect any problems' do
|
10
|
+
expect(problems).to have(0).problems
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
|
-
|
14
|
+
context 'class inheriting from sister in same module namespace' do
|
11
15
|
let(:code) { "class foo::bar inherits foo::baz { }" }
|
12
16
|
|
13
|
-
|
17
|
+
it 'should not detect any problems' do
|
18
|
+
expect(problems).to have(0).problems
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
|
-
|
22
|
+
context 'class inheriting from another module namespace' do
|
17
23
|
let(:code) { "class foo::bar inherits baz { }" }
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
should_not have_problem :kind => :error
|
27
|
-
}
|
25
|
+
it 'should only detect a single problem' do
|
26
|
+
expect(problems).to have(1).problem
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should create a warning' do
|
30
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(25)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
@@ -1,45 +1,45 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'names_containing_dash' do
|
4
|
-
|
4
|
+
let(:class_msg) { 'class name containing a dash' }
|
5
|
+
let(:define_msg) { 'defined type name containing a dash' }
|
6
|
+
|
7
|
+
context 'module named foo-bar' do
|
5
8
|
let(:code) { 'class foo-bar { }' }
|
6
|
-
let(:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
})
|
9
|
+
let(:path) { 'foo-bar/manifests/init.pp' }
|
10
|
+
|
11
|
+
it 'should only detect a single problem' do
|
12
|
+
expect(problems).to have(1).problem
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should create a warning' do
|
16
|
+
expect(problems).to contain_warning(class_msg).on_line(1).in_column(7)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
|
20
|
+
context 'define named foo-bar' do
|
19
21
|
let(:code) { 'define foo::foo-bar { }' }
|
20
|
-
let(:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
})
|
22
|
+
let(:path) { 'foo/manifests/foo-bar.pp' }
|
23
|
+
|
24
|
+
it 'should only detect a single problem' do
|
25
|
+
expect(problems).to have(1).problem
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should create a warning' do
|
29
|
+
expect(problems).to contain_warning(define_msg).on_line(1).in_column(8)
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
|
33
|
+
context 'class named bar-foo' do
|
33
34
|
let(:code) { 'class foo::bar-foo { }' }
|
34
|
-
let(:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
})
|
35
|
+
let(:path) { 'foo/manifests/bar-foo.pp' }
|
36
|
+
|
37
|
+
it 'should only detect a single problem' do
|
38
|
+
expect(problems).to have(1).problem
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should create a warning' do
|
42
|
+
expect(problems).to contain_warning(class_msg).on_line(1).in_column(7)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -1,13 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'nested_classes_or_defines' do
|
4
|
-
|
4
|
+
let(:class_msg) { 'class defined inside a class' }
|
5
|
+
let(:define_msg) { 'defined type defined inside a class' }
|
6
|
+
|
7
|
+
context 'class on its own' do
|
5
8
|
let(:code) { "class foo { }" }
|
6
9
|
|
7
|
-
|
10
|
+
it 'should not detect any problems' do
|
11
|
+
expect(problems).to have(0).problems
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
|
-
|
15
|
+
context 'class inside a class' do
|
11
16
|
let(:code) { "
|
12
17
|
class foo {
|
13
18
|
class bar {
|
@@ -15,18 +20,16 @@ describe 'nested_classes_or_defines' do
|
|
15
20
|
}"
|
16
21
|
}
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
should_not have_problem :kind => :error
|
26
|
-
}
|
23
|
+
it 'should only detect a single problem' do
|
24
|
+
expect(problems).to have(1).problem
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should create a warning' do
|
28
|
+
expect(problems).to contain_warning(class_msg).on_line(3).in_column(9)
|
29
|
+
end
|
27
30
|
end
|
28
31
|
|
29
|
-
|
32
|
+
context 'instantiating a parametised class inside a class' do
|
30
33
|
let(:code) { "
|
31
34
|
class bar {
|
32
35
|
class { 'foo':
|
@@ -35,10 +38,12 @@ describe 'nested_classes_or_defines' do
|
|
35
38
|
}"
|
36
39
|
}
|
37
40
|
|
38
|
-
|
41
|
+
it 'should not detect any problems' do
|
42
|
+
expect(problems).to have(0).problems
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
|
-
|
46
|
+
context 'instantiating a parametised class inside a define' do
|
42
47
|
let(:code) { "
|
43
48
|
define bar() {
|
44
49
|
class { 'foo':
|
@@ -47,10 +52,12 @@ describe 'nested_classes_or_defines' do
|
|
47
52
|
}"
|
48
53
|
}
|
49
54
|
|
50
|
-
|
55
|
+
it 'should not detect any problems' do
|
56
|
+
expect(problems).to have(0).problems
|
57
|
+
end
|
51
58
|
end
|
52
59
|
|
53
|
-
|
60
|
+
context 'define inside a class' do
|
54
61
|
let(:code) { "
|
55
62
|
class foo {
|
56
63
|
define bar() {
|
@@ -58,14 +65,12 @@ describe 'nested_classes_or_defines' do
|
|
58
65
|
}"
|
59
66
|
}
|
60
67
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
should_not have_problem :kind => :error
|
69
|
-
}
|
68
|
+
it 'should only detect a single problem' do
|
69
|
+
expect(problems).to have(1).problems
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should create a warning' do
|
73
|
+
expect(problems).to contain_warning(define_msg).on_line(3).in_column(9)
|
74
|
+
end
|
70
75
|
end
|
71
76
|
end
|
@@ -1,59 +1,63 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'parameter_order' do
|
4
|
-
|
4
|
+
let(:msg) { 'optional parameter listed before required parameter' }
|
5
|
+
|
6
|
+
context 'define with attrs in order' do
|
5
7
|
let(:code) { "define foo($bar, $baz='gronk') { }" }
|
6
8
|
|
7
|
-
|
9
|
+
it 'should not detect any problems' do
|
10
|
+
expect(problems).to have(0).problems
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
|
-
|
14
|
+
context 'define with parameter that calls a function' do
|
11
15
|
let(:code) { "define foo($bar=extlookup($name)) {}" }
|
12
16
|
|
13
|
-
|
17
|
+
it 'should not detect any problems' do
|
18
|
+
expect(problems).to have(0).problems
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
|
-
|
22
|
+
context 'define with attrs out of order' do
|
17
23
|
let(:code) { "define foo($bar='baz', $gronk) { }" }
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
should_not have_problem :kind => :error
|
27
|
-
}
|
25
|
+
it 'should only detect a single problem' do
|
26
|
+
expect(problems).to have(1).problem
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should create a warning' do
|
30
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(24)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
|
-
|
34
|
+
context 'class/define parameter set to another variable' do
|
31
35
|
let(:code) { "
|
32
36
|
define foo($bar, $baz = $name, $gronk=$::fqdn) {
|
33
37
|
}"
|
34
38
|
}
|
35
39
|
|
36
|
-
|
40
|
+
it 'should not detect any problems' do
|
41
|
+
expect(problems).to have(0).problems
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
|
-
|
45
|
+
context 'class/define parameter set to another variable with incorrect order' do
|
40
46
|
let(:code) { "
|
41
47
|
define foo($baz = $name, $bar, $gronk=$::fqdn) {
|
42
48
|
}"
|
43
49
|
}
|
44
50
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
should_not have_problem :kind => :error
|
53
|
-
}
|
51
|
+
it 'should only detect a single problem' do
|
52
|
+
expect(problems).to have(1).problem
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should create a warning' do
|
56
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(32)
|
57
|
+
end
|
54
58
|
end
|
55
59
|
|
56
|
-
|
60
|
+
context 'issue-101' do
|
57
61
|
let(:code) { "
|
58
62
|
define b (
|
59
63
|
$foo,
|
@@ -62,6 +66,8 @@ describe 'parameter_order' do
|
|
62
66
|
) { }
|
63
67
|
" }
|
64
68
|
|
65
|
-
|
69
|
+
it 'should not detect any problems' do
|
70
|
+
expect(problems).to have(0).problems
|
71
|
+
end
|
66
72
|
end
|
67
73
|
end
|