halyard-puppet-lint 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +10 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +210 -0
- data/Rakefile +7 -0
- data/bin/puppet-lint +7 -0
- data/lib/puppet-lint.rb +214 -0
- data/lib/puppet-lint/bin.rb +79 -0
- data/lib/puppet-lint/checkplugin.rb +176 -0
- data/lib/puppet-lint/checks.rb +91 -0
- data/lib/puppet-lint/configuration.rb +153 -0
- data/lib/puppet-lint/data.rb +521 -0
- data/lib/puppet-lint/lexer.rb +373 -0
- data/lib/puppet-lint/lexer/token.rb +101 -0
- data/lib/puppet-lint/monkeypatches.rb +2 -0
- data/lib/puppet-lint/monkeypatches/string_percent.rb +52 -0
- data/lib/puppet-lint/monkeypatches/string_prepend.rb +13 -0
- data/lib/puppet-lint/optparser.rb +118 -0
- data/lib/puppet-lint/plugins.rb +74 -0
- data/lib/puppet-lint/plugins/check_classes.rb +285 -0
- data/lib/puppet-lint/plugins/check_comments.rb +55 -0
- data/lib/puppet-lint/plugins/check_conditionals.rb +65 -0
- data/lib/puppet-lint/plugins/check_documentation.rb +31 -0
- data/lib/puppet-lint/plugins/check_nodes.rb +29 -0
- data/lib/puppet-lint/plugins/check_resources.rb +194 -0
- data/lib/puppet-lint/plugins/check_strings.rb +174 -0
- data/lib/puppet-lint/plugins/check_variables.rb +19 -0
- data/lib/puppet-lint/plugins/check_whitespace.rb +170 -0
- data/lib/puppet-lint/tasks/puppet-lint.rb +91 -0
- data/lib/puppet-lint/version.rb +3 -0
- data/puppet-lint.gemspec +24 -0
- data/spec/fixtures/test/manifests/fail.pp +2 -0
- data/spec/fixtures/test/manifests/ignore.pp +1 -0
- data/spec/fixtures/test/manifests/ignore_multiple_block.pp +6 -0
- data/spec/fixtures/test/manifests/ignore_multiple_line.pp +2 -0
- data/spec/fixtures/test/manifests/ignore_reason.pp +1 -0
- data/spec/fixtures/test/manifests/init.pp +3 -0
- data/spec/fixtures/test/manifests/malformed.pp +1 -0
- data/spec/fixtures/test/manifests/url_interpolation.pp +12 -0
- data/spec/fixtures/test/manifests/warning.pp +2 -0
- data/spec/puppet-lint/bin_spec.rb +326 -0
- data/spec/puppet-lint/configuration_spec.rb +56 -0
- data/spec/puppet-lint/ignore_overrides_spec.rb +109 -0
- data/spec/puppet-lint/lexer/token_spec.rb +18 -0
- data/spec/puppet-lint/lexer_spec.rb +783 -0
- data/spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +105 -0
- data/spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb +35 -0
- data/spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +33 -0
- data/spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +45 -0
- data/spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +76 -0
- data/spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb +73 -0
- data/spec/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +25 -0
- data/spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb +196 -0
- data/spec/puppet-lint/plugins/check_comments/slash_comments_spec.rb +45 -0
- data/spec/puppet-lint/plugins/check_comments/star_comments_spec.rb +84 -0
- data/spec/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +98 -0
- data/spec/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +36 -0
- data/spec/puppet-lint/plugins/check_documentation/documentation_spec.rb +52 -0
- data/spec/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb +146 -0
- data/spec/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +100 -0
- data/spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +55 -0
- data/spec/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +89 -0
- data/spec/puppet-lint/plugins/check_resources/file_mode_spec.rb +113 -0
- data/spec/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +45 -0
- data/spec/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +216 -0
- data/spec/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +199 -0
- data/spec/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +114 -0
- data/spec/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb +62 -0
- data/spec/puppet-lint/plugins/check_strings/quoted_booleans_spec.rb +129 -0
- data/spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +17 -0
- data/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb +73 -0
- data/spec/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +37 -0
- data/spec/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +21 -0
- data/spec/puppet-lint/plugins/check_whitespace/80chars_spec.rb +54 -0
- data/spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +524 -0
- data/spec/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +45 -0
- data/spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +101 -0
- data/spec/puppet-lint_spec.rb +20 -0
- data/spec/spec_helper.rb +129 -0
- metadata +229 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'duplicate_params' do
|
4
|
+
let(:msg) { 'duplicate parameter found in resource' }
|
5
|
+
|
6
|
+
context 'resource with duplicate parameters' do
|
7
|
+
let(:code) { "
|
8
|
+
file { '/tmp/foo':
|
9
|
+
ensure => present,
|
10
|
+
foo => bar,
|
11
|
+
baz => gronk,
|
12
|
+
foo => meh,
|
13
|
+
}"
|
14
|
+
}
|
15
|
+
|
16
|
+
it 'should only detect a single problem' do
|
17
|
+
expect(problems).to have(1).problem
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should create an error' do
|
21
|
+
expect(problems).to contain_error(msg).on_line(6).in_column(9)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'bug #145: resource with a hash and no duplicate parameters' do
|
26
|
+
let(:code) { "
|
27
|
+
class {'fooname':
|
28
|
+
hashes => [
|
29
|
+
{ foo => 'bar01',},
|
30
|
+
{ foo => 'bar02', },
|
31
|
+
],
|
32
|
+
}"
|
33
|
+
}
|
34
|
+
|
35
|
+
it 'should not detect any errors' do
|
36
|
+
expect(problems).to have(0).problems
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'bug #145: resource with a hash and duplicate parameters in subhash' do
|
41
|
+
let(:code) { "
|
42
|
+
class {'fooname':
|
43
|
+
hashes => [
|
44
|
+
{ foo => 'bar01',
|
45
|
+
foo => 'bar02', },
|
46
|
+
],
|
47
|
+
}"
|
48
|
+
}
|
49
|
+
|
50
|
+
it 'should only detect a single error' do
|
51
|
+
expect(problems).to have(1).problem
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should create an error' do
|
55
|
+
expect(problems).to contain_error(msg).on_line(5).in_column(13)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'bug #145: resource with a hash and duplicate parameters in parent type' do
|
60
|
+
let(:code) { "
|
61
|
+
class {'fooname':
|
62
|
+
hashes => [
|
63
|
+
{ foo => 'bar01', },
|
64
|
+
{ foo => 'bar02', },
|
65
|
+
],
|
66
|
+
something => { hash => 'mini', },
|
67
|
+
hashes => 'dupe',
|
68
|
+
}"
|
69
|
+
}
|
70
|
+
|
71
|
+
it 'should only detect a single problem' do
|
72
|
+
expect(problems).to have(1).problem
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should create an error' do
|
76
|
+
expect(problems).to contain_error(msg).on_line(8).in_column(9)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'bug #145: more hash tests and no duplicate parameters' do
|
81
|
+
let(:code) { "
|
82
|
+
class test {
|
83
|
+
$foo = { param => 'value', }
|
84
|
+
$bar = { param => 'bar', }
|
85
|
+
}"
|
86
|
+
}
|
87
|
+
|
88
|
+
it 'should not detect any problems' do
|
89
|
+
expect(problems).to have(0).problems
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'colon as last token in file' do
|
94
|
+
let(:code) { "}:" }
|
95
|
+
|
96
|
+
it 'should not detect any problems' do
|
97
|
+
expect(problems).to have(0).problems
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'ensure_first_param' do
|
4
|
+
let(:msg) { "ensure found on line but it's not the first attribute" }
|
5
|
+
|
6
|
+
context 'ensure as only attr in a single line resource' do
|
7
|
+
let(:code) { "file { 'foo': ensure => present }" }
|
8
|
+
|
9
|
+
it 'should not detect any problems' do
|
10
|
+
expect(problems).to have(0).problems
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'ensure as only attr in a multi line resource' do
|
15
|
+
let(:code) { "
|
16
|
+
file { 'foo':
|
17
|
+
ensure => present,
|
18
|
+
}"
|
19
|
+
}
|
20
|
+
|
21
|
+
it 'should not detect any problems' do
|
22
|
+
expect(problems).to have(0).problems
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'ensure as second attr in a multi line resource' do
|
27
|
+
let(:code) { "
|
28
|
+
file { 'foo':
|
29
|
+
mode => '0000',
|
30
|
+
ensure => present,
|
31
|
+
}"
|
32
|
+
}
|
33
|
+
|
34
|
+
it 'should only detect a single problem' do
|
35
|
+
expect(problems).to have(1).problem
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should create a warning' do
|
39
|
+
expect(problems).to contain_warning(msg).on_line(4).in_column(9)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'ensure as first attr in a multi line resource' do
|
44
|
+
let(:code) { "
|
45
|
+
file { 'foo':
|
46
|
+
ensure => present,
|
47
|
+
mode => '0000',
|
48
|
+
}"
|
49
|
+
}
|
50
|
+
|
51
|
+
it 'should not detect any problems' do
|
52
|
+
expect(problems).to have(0).problems
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'ensure_not_symlink_target' do
|
4
|
+
let(:msg) { 'symlink target specified in ensure attr' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'file resource creating a symlink with seperate target attr' do
|
8
|
+
let(:code) { "
|
9
|
+
file { 'foo':
|
10
|
+
ensure => link,
|
11
|
+
target => '/foo/bar',
|
12
|
+
}"
|
13
|
+
}
|
14
|
+
|
15
|
+
it 'should not detect any problems' do
|
16
|
+
expect(problems).to have(0).problems
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'file resource creating a symlink with target specified in ensure' do
|
21
|
+
let(:code) { "
|
22
|
+
file { 'foo':
|
23
|
+
ensure => '/foo/bar',
|
24
|
+
}"
|
25
|
+
}
|
26
|
+
|
27
|
+
it 'should only detect a single problem' do
|
28
|
+
expect(problems).to have(1).problem
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should create a warning' do
|
32
|
+
expect(problems).to contain_warning(msg).on_line(3).in_column(21)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'with fix enabled' do
|
38
|
+
before do
|
39
|
+
PuppetLint.configuration.fix = true
|
40
|
+
end
|
41
|
+
|
42
|
+
after do
|
43
|
+
PuppetLint.configuration.fix = false
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'file resource creating a symlink with seperate target attr' do
|
47
|
+
let(:code) { "
|
48
|
+
file { 'foo':
|
49
|
+
ensure => link,
|
50
|
+
target => '/foo/bar',
|
51
|
+
}"
|
52
|
+
}
|
53
|
+
|
54
|
+
it 'should not detect any problems' do
|
55
|
+
expect(problems).to have(0).problems
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should not modify the manifest' do
|
59
|
+
expect(manifest).to eq(code)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'file resource creating a symlink with target specified in ensure' do
|
64
|
+
let(:code) { "
|
65
|
+
file { 'foo':
|
66
|
+
ensure => '/foo/bar',
|
67
|
+
}"
|
68
|
+
}
|
69
|
+
let(:fixed) { "
|
70
|
+
file { 'foo':
|
71
|
+
ensure => symlink,
|
72
|
+
target => '/foo/bar',
|
73
|
+
}"
|
74
|
+
}
|
75
|
+
|
76
|
+
it 'should only detect a single problem' do
|
77
|
+
expect(problems).to have(1).problem
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should fix the problem' do
|
81
|
+
expect(problems).to contain_fixed(msg).on_line(3).in_column(21)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should create a new target param' do
|
85
|
+
expect(manifest).to eq(fixed)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'file_mode' do
|
4
|
+
let(:msg) { 'mode should be represented as a 4 digit octal value or symbolic mode' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context '3 digit file mode' do
|
8
|
+
let(:code) { "file { 'foo': mode => '777' }" }
|
9
|
+
|
10
|
+
it 'should only detect a single problem' do
|
11
|
+
expect(problems).to have(1).problem
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should create a warning' do
|
15
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(23)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context '4 digit file mode' do
|
20
|
+
let(:code) { "file { 'foo': mode => '0777' }" }
|
21
|
+
|
22
|
+
it 'should not detect any problems' do
|
23
|
+
expect(problems).to have(0).problems
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'file mode as a variable' do
|
28
|
+
let(:code) { "file { 'foo': mode => $file_mode }" }
|
29
|
+
|
30
|
+
it 'should not detect any problems' do
|
31
|
+
expect(problems).to have(0).problems
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'symbolic file mode' do
|
36
|
+
let(:code) { "file { 'foo': mode => 'u=rw,og=r' }" }
|
37
|
+
|
38
|
+
it 'should not detect any problems' do
|
39
|
+
expect(problems).to have(0).problems
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'file mode undef unquoted' do
|
44
|
+
let(:code) { "file { 'foo': mode => undef }" }
|
45
|
+
|
46
|
+
it 'should not detect any problems' do
|
47
|
+
expect(problems).to have(0).problems
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'file mode undef quoted' do
|
52
|
+
let(:code) { "file { 'foo': mode => 'undef' }" }
|
53
|
+
|
54
|
+
it 'should only detect a single problem' do
|
55
|
+
expect(problems).to have(1).problem
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should create a warning' do
|
59
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(23)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'mode as audit value' do
|
64
|
+
let(:code) { "file { '/etc/passwd': audit => [ owner, mode ], }" }
|
65
|
+
|
66
|
+
it 'should not detect any problems' do
|
67
|
+
expect(problems).to have(0).problems
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'with fix enabled' do
|
73
|
+
before do
|
74
|
+
PuppetLint.configuration.fix = true
|
75
|
+
end
|
76
|
+
|
77
|
+
after do
|
78
|
+
PuppetLint.configuration.fix = false
|
79
|
+
end
|
80
|
+
|
81
|
+
context '3 digit file mode' do
|
82
|
+
let(:code) { "file { 'foo': mode => '777' }" }
|
83
|
+
|
84
|
+
it 'should only detect a single problem' do
|
85
|
+
expect(problems).to have(1).problem
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should fix the manifest' do
|
89
|
+
expect(problems).to contain_fixed(msg).on_line(1).in_column(23)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should zero pad the file mode' do
|
93
|
+
expect(manifest).to eq("file { 'foo': mode => '0777' }")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'file mode undef quoted' do
|
98
|
+
let(:code) { "file { 'foo': mode => 'undef' }" }
|
99
|
+
|
100
|
+
it 'should only detect a single problem' do
|
101
|
+
expect(problems).to have(1).problem
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should create a warning' do
|
105
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(23)
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should not modify the original manifest' do
|
109
|
+
expect(manifest).to eq(code)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'unquoted_file_mode' do
|
4
|
+
let(:msg) { 'unquoted file mode' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context '4 digit unquoted file mode' do
|
8
|
+
let(:code) { "file { 'foo': mode => 0777 }" }
|
9
|
+
|
10
|
+
it 'should only detect a single problem' do
|
11
|
+
expect(problems).to have(1).problem
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should create a warning' do
|
15
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(23)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with fix enabled' do
|
21
|
+
before do
|
22
|
+
PuppetLint.configuration.fix = true
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
PuppetLint.configuration.fix = false
|
27
|
+
end
|
28
|
+
|
29
|
+
context '4 digit unquoted file mode w/fix' do
|
30
|
+
let(:code) { "file { 'foo': mode => 0777 }" }
|
31
|
+
|
32
|
+
it 'should only detect a single problem' do
|
33
|
+
expect(problems).to have(1).problem
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should fix the manifest' do
|
37
|
+
expect(problems).to contain_fixed(msg).on_line(1).in_column(23)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should single quote the file mode' do
|
41
|
+
expect(manifest).to eq("file { 'foo': mode => '0777' }")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'unquoted_resource_title' do
|
4
|
+
let(:msg) { 'unquoted resource title' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'quoted resource title on single line resource' do
|
8
|
+
let(:code) { "file { 'foo': }" }
|
9
|
+
|
10
|
+
it 'should not detect any problems' do
|
11
|
+
expect(problems).to have(0).problems
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'unquoted resource title on single line resource' do
|
16
|
+
let(:code) { "file { foo: }" }
|
17
|
+
|
18
|
+
it 'should only detect a single problem' do
|
19
|
+
expect(problems).to have(1).problem
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should create a warning' do
|
23
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(8)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'quoted resource title on multi line resource' do
|
28
|
+
let(:code) { "
|
29
|
+
file { 'foo':
|
30
|
+
}"
|
31
|
+
}
|
32
|
+
|
33
|
+
it 'should not detect any problems' do
|
34
|
+
expect(problems).to have(0).problems
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'unquoted resource title on multi line resource' do
|
39
|
+
let(:code) { "
|
40
|
+
file { foo:
|
41
|
+
}"
|
42
|
+
}
|
43
|
+
|
44
|
+
it 'should only detect a single problem' do
|
45
|
+
expect(problems).to have(1).problem
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should create a warning' do
|
49
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(16)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'condensed resources with quoted titles' do
|
54
|
+
let(:code) { "
|
55
|
+
file {
|
56
|
+
'foo': ;
|
57
|
+
'bar': ;
|
58
|
+
}"
|
59
|
+
}
|
60
|
+
|
61
|
+
it 'should not detect any problems' do
|
62
|
+
expect(problems).to have(0).problems
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'condensed resources with an unquoted title' do
|
67
|
+
let(:code) { "
|
68
|
+
file {
|
69
|
+
'foo': ;
|
70
|
+
bar: ;
|
71
|
+
}"
|
72
|
+
}
|
73
|
+
|
74
|
+
it 'should only detect a single problem' do
|
75
|
+
expect(problems).to have(1).problem
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should create a warning' do
|
79
|
+
expect(problems).to contain_warning(msg).on_line(4).in_column(11)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'single line resource with an array of titles (all quoted)' do
|
84
|
+
let(:code) { "file { ['foo', 'bar']: }" }
|
85
|
+
|
86
|
+
it 'should not detect any problems' do
|
87
|
+
expect(problems).to have(0).problems
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'resource inside a case statement' do
|
92
|
+
let(:code) { "
|
93
|
+
case $ensure {
|
94
|
+
'absent': {
|
95
|
+
file { \"some_file_${name}\":
|
96
|
+
ensure => absent,
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}"
|
100
|
+
}
|
101
|
+
|
102
|
+
it 'should not detect any problems' do
|
103
|
+
expect(problems).to have(0).problems
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'issue #116' do
|
108
|
+
let(:code) { "
|
109
|
+
$config_file_init = $::operatingsystem ? {
|
110
|
+
/(?i:Debian|Ubuntu|Mint)/ => '/etc/default/foo',
|
111
|
+
default => '/etc/sysconfig/foo',
|
112
|
+
}"
|
113
|
+
}
|
114
|
+
|
115
|
+
it 'should not detect any problems' do
|
116
|
+
expect(problems).to have(0).problems
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'case statement' do
|
121
|
+
let(:code) { %{
|
122
|
+
case $operatingsystem {
|
123
|
+
centos: {
|
124
|
+
$version = '1.2.3'
|
125
|
+
}
|
126
|
+
solaris: {
|
127
|
+
$version = '3.2.1'
|
128
|
+
}
|
129
|
+
default: {
|
130
|
+
fail("Module ${module_name} is not supported on ${operatingsystem}")
|
131
|
+
}
|
132
|
+
}}
|
133
|
+
}
|
134
|
+
|
135
|
+
it 'should not detect any problems' do
|
136
|
+
expect(problems).to have(0).problems
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'with fix enabled' do
|
142
|
+
before do
|
143
|
+
PuppetLint.configuration.fix = true
|
144
|
+
end
|
145
|
+
|
146
|
+
after do
|
147
|
+
PuppetLint.configuration.fix = false
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'unquoted resource title on single line resource' do
|
151
|
+
let(:code) { "file { foo: }" }
|
152
|
+
|
153
|
+
it 'should only detect a single problem' do
|
154
|
+
expect(problems).to have(1).problem
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'should fix the manifest' do
|
158
|
+
expect(problems).to contain_fixed(msg).on_line(1).in_column(8)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'should single quote the resource title' do
|
162
|
+
expect(manifest).to eq("file { 'foo': }")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context 'unquoted resource title on multi line resource' do
|
167
|
+
let(:code) { "
|
168
|
+
file { foo:
|
169
|
+
}"
|
170
|
+
}
|
171
|
+
let(:fixed) { "
|
172
|
+
file { 'foo':
|
173
|
+
}"
|
174
|
+
}
|
175
|
+
|
176
|
+
it 'should only detect a single problem' do
|
177
|
+
expect(problems).to have(1).problem
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should fix the manifest' do
|
181
|
+
expect(problems).to contain_fixed(msg).on_line(2).in_column(16)
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should single quote the resource title' do
|
185
|
+
expect(manifest).to eq(fixed)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
context 'condensed resources with an unquoted title' do
|
190
|
+
let(:code) { "
|
191
|
+
file {
|
192
|
+
'foo': ;
|
193
|
+
bar: ;
|
194
|
+
}"
|
195
|
+
}
|
196
|
+
let(:fixed) { "
|
197
|
+
file {
|
198
|
+
'foo': ;
|
199
|
+
'bar': ;
|
200
|
+
}"
|
201
|
+
}
|
202
|
+
|
203
|
+
it 'should only detect a single problem' do
|
204
|
+
expect(problems).to have(1).problem
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'should fix the manifest' do
|
208
|
+
expect(problems).to contain_fixed(msg).on_line(4).in_column(11)
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'should single quote the resource title' do
|
212
|
+
expect(manifest).to eq(fixed)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|