puppet-lint 2.3.0 → 2.3.1
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.
- 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
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'arrow_on_right_operand_line' do
|
4
|
-
{'chain' => '->', 'subscribe chain' => '~>'}.each do |name, operator|
|
4
|
+
{ 'chain' => '->', 'subscribe chain' => '~>' }.each do |name, operator|
|
5
5
|
context "#{name} operator" do
|
6
6
|
context 'both operands on same line' do
|
7
7
|
let(:code) { "Package['httpd'] #{operator} Service['httpd']" }
|
@@ -11,7 +11,8 @@ describe 'arrow_on_right_operand_line' do
|
|
11
11
|
|
12
12
|
context 'arrow on the line of left operand' do
|
13
13
|
let(:code) do
|
14
|
-
"
|
14
|
+
"
|
15
|
+
Package['httpd'] #{operator}
|
15
16
|
Service['httpd']"
|
16
17
|
end
|
17
18
|
|
@@ -27,17 +28,22 @@ describe 'arrow_on_right_operand_line' do
|
|
27
28
|
end
|
28
29
|
|
29
30
|
let(:fixed) do
|
30
|
-
"
|
31
|
+
"
|
32
|
+
Package['httpd']
|
31
33
|
#{operator} Service['httpd']"
|
32
34
|
end
|
33
35
|
|
34
|
-
it { expect(manifest).to eq
|
36
|
+
it { expect(manifest).to eq(fixed) }
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
40
|
context 'arrow on the line of right operand' do
|
39
|
-
let(:code)
|
40
|
-
|
41
|
+
let(:code) do
|
42
|
+
<<-END
|
43
|
+
Package['httpd']
|
44
|
+
#{operator} Service['httpd']
|
45
|
+
END
|
46
|
+
end
|
41
47
|
|
42
48
|
it { expect(problems).to have(0).problems }
|
43
49
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'autoloader_layout' do
|
4
4
|
context 'foo::bar in foo/manifests/bar.pp' do
|
5
|
-
let(:code) {
|
5
|
+
let(:code) { 'class foo::bar { }' }
|
6
6
|
let(:path) { 'foo/manifests/bar.pp' }
|
7
7
|
|
8
8
|
it 'should not detect any problems' do
|
@@ -43,14 +43,16 @@ describe 'autoloader_layout' do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'foo included in bar/manifests/init.pp' do
|
46
|
-
let(:code)
|
47
|
-
|
48
|
-
class {
|
49
|
-
|
46
|
+
let(:code) do
|
47
|
+
<<-END
|
48
|
+
class bar {
|
49
|
+
class {'foo':
|
50
|
+
someparam => 'somevalue',
|
51
|
+
}
|
50
52
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
53
|
+
END
|
54
|
+
end
|
55
|
+
|
54
56
|
let(:path) { 'bar/manifests/init.pp' }
|
55
57
|
|
56
58
|
it 'should not detect any problems' do
|
@@ -100,6 +102,4 @@ describe 'autoloader_layout' do
|
|
100
102
|
expect(problems).to have(0).problems
|
101
103
|
end
|
102
104
|
end
|
103
|
-
|
104
|
-
|
105
105
|
end
|
@@ -4,29 +4,33 @@ describe 'class_inherits_from_params_class' do
|
|
4
4
|
let(:msg) { 'class inheriting from params class' }
|
5
5
|
|
6
6
|
context 'parameterised class that inherits from a params class' do
|
7
|
-
let(:code)
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
let(:code) do
|
8
|
+
<<-END
|
9
|
+
# commented
|
10
|
+
class foo($bar = $name) inherits foo::params { }
|
11
|
+
END
|
12
|
+
end
|
11
13
|
|
12
14
|
it 'should only detect a single problem' do
|
13
15
|
expect(problems).to have(1).problem
|
14
16
|
end
|
15
17
|
|
16
18
|
it 'should create a warning' do
|
17
|
-
expect(problems).to contain_warning(msg).on_line(
|
19
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(42)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
23
|
context 'class without parameters' do
|
22
|
-
let(:code)
|
23
|
-
|
24
|
+
let(:code) do
|
25
|
+
<<-END
|
26
|
+
class myclass {
|
24
27
|
|
25
|
-
|
26
|
-
|
28
|
+
if ( $::lsbdistcodename == 'squeeze' ) {
|
29
|
+
#TODO
|
30
|
+
}
|
27
31
|
}
|
28
|
-
|
29
|
-
|
32
|
+
END
|
33
|
+
end
|
30
34
|
|
31
35
|
it 'should not detect any problems' do
|
32
36
|
expect(problems).to have(0).problems
|
@@ -2,42 +2,47 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'code_on_top_scope' do
|
4
4
|
describe 'comments outside class block' do
|
5
|
-
let(:code)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
let(:code) do
|
6
|
+
<<-END
|
7
|
+
# Baz
|
8
|
+
class foo:bar {
|
9
|
+
}
|
10
|
+
END
|
11
|
+
end
|
10
12
|
|
11
13
|
its(:problems) { should be_empty }
|
12
14
|
end
|
13
15
|
|
14
16
|
describe 'new lines outside of class-define block' do
|
15
|
-
let(:code)
|
17
|
+
let(:code) do
|
18
|
+
<<-END
|
16
19
|
|
17
|
-
|
18
|
-
|
20
|
+
class foo:bar {
|
21
|
+
}
|
19
22
|
|
20
|
-
|
21
|
-
|
23
|
+
END
|
24
|
+
end
|
22
25
|
|
23
26
|
its(:problems) { should be_empty }
|
24
27
|
end
|
25
28
|
|
26
29
|
describe 'code outside class block' do
|
27
|
-
let(:code)
|
28
|
-
|
30
|
+
let(:code) do
|
31
|
+
<<-END
|
32
|
+
include('something')
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
34
|
+
# Baz
|
35
|
+
class foo:bar {
|
36
|
+
}
|
33
37
|
|
34
|
-
|
35
|
-
|
36
|
-
|
38
|
+
define whatever {
|
39
|
+
}
|
40
|
+
END
|
41
|
+
end
|
37
42
|
|
38
|
-
its(:problems)
|
39
|
-
should contain_warning(
|
43
|
+
its(:problems) do
|
44
|
+
should contain_warning('code outside of class or define block - include')
|
40
45
|
should have(4).problems
|
41
|
-
|
46
|
+
end
|
42
47
|
end
|
43
48
|
end
|
@@ -4,7 +4,7 @@ describe 'inherits_across_namespaces' do
|
|
4
4
|
let(:msg) { 'class inherits across module namespaces' }
|
5
5
|
|
6
6
|
context 'class inheriting from parent in same module namespace' do
|
7
|
-
let(:code) {
|
7
|
+
let(:code) { 'class foo::bar inherits foo { }' }
|
8
8
|
|
9
9
|
it 'should not detect any problems' do
|
10
10
|
expect(problems).to have(0).problems
|
@@ -12,7 +12,7 @@ describe 'inherits_across_namespaces' do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'class inheriting from sister in same module namespace' do
|
15
|
-
let(:code) {
|
15
|
+
let(:code) { 'class foo::bar inherits foo::baz { }' }
|
16
16
|
|
17
17
|
it 'should not detect any problems' do
|
18
18
|
expect(problems).to have(0).problems
|
@@ -20,7 +20,7 @@ describe 'inherits_across_namespaces' do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
context 'class inheriting from another module namespace' do
|
23
|
-
let(:code) {
|
23
|
+
let(:code) { 'class foo::bar inherits baz { }' }
|
24
24
|
|
25
25
|
it 'should only detect a single problem' do
|
26
26
|
expect(problems).to have(1).problem
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'names_containing_uppercase' do
|
4
|
-
|
5
4
|
context 'defined type named FooBar' do
|
6
5
|
let(:code) { 'define FooBar { }' }
|
7
6
|
let(:path) { 'foobar/manifests/init.pp' }
|
@@ -47,17 +46,17 @@ describe 'names_containing_uppercase' do
|
|
47
46
|
before do
|
48
47
|
PuppetLint.configuration.fix = true
|
49
48
|
end
|
50
|
-
|
49
|
+
|
51
50
|
after do
|
52
51
|
PuppetLint.configuration.fix = false
|
53
52
|
end
|
54
|
-
|
53
|
+
|
55
54
|
let(:fixed) { code.downcase }
|
56
|
-
|
55
|
+
|
57
56
|
it 'should create an error' do
|
58
57
|
expect(problems).to contain_fixed(class_msg).on_line(1).in_column(7)
|
59
58
|
end
|
60
|
-
|
59
|
+
|
61
60
|
it 'should downcase the class name' do
|
62
61
|
expect(manifest).to eq(fixed)
|
63
62
|
end
|
@@ -42,4 +42,17 @@ describe 'names_containing_dash' do
|
|
42
42
|
expect(problems).to contain_error(class_msg).on_line(1).in_column(7)
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
context 'multiple classes' do
|
47
|
+
let(:code) do
|
48
|
+
<<-END
|
49
|
+
class foo::bar_foo { }
|
50
|
+
class foo::baz-foo { }
|
51
|
+
END
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should create an error' do
|
55
|
+
expect(problems).to contain_error(class_msg).on_line(2).in_column(15)
|
56
|
+
end
|
57
|
+
end
|
45
58
|
end
|
@@ -5,7 +5,7 @@ describe 'nested_classes_or_defines' do
|
|
5
5
|
let(:define_msg) { 'defined type defined inside a class' }
|
6
6
|
|
7
7
|
context 'class on its own' do
|
8
|
-
let(:code) {
|
8
|
+
let(:code) { 'class foo { }' }
|
9
9
|
|
10
10
|
it 'should not detect any problems' do
|
11
11
|
expect(problems).to have(0).problems
|
@@ -13,30 +13,34 @@ describe 'nested_classes_or_defines' do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'class inside a class' do
|
16
|
-
let(:code)
|
17
|
-
|
18
|
-
class
|
16
|
+
let(:code) do
|
17
|
+
<<-END
|
18
|
+
class foo {
|
19
|
+
class bar {
|
20
|
+
}
|
19
21
|
}
|
20
|
-
|
21
|
-
|
22
|
+
END
|
23
|
+
end
|
22
24
|
|
23
25
|
it 'should only detect a single problem' do
|
24
26
|
expect(problems).to have(1).problem
|
25
27
|
end
|
26
28
|
|
27
29
|
it 'should create a warning' do
|
28
|
-
expect(problems).to contain_warning(class_msg).on_line(
|
30
|
+
expect(problems).to contain_warning(class_msg).on_line(2).in_column(11)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
34
|
context 'instantiating a parametised class inside a class' do
|
33
|
-
let(:code)
|
34
|
-
|
35
|
-
class {
|
36
|
-
|
35
|
+
let(:code) do
|
36
|
+
<<-END
|
37
|
+
class bar {
|
38
|
+
class { 'foo':
|
39
|
+
bar => 'foobar'
|
40
|
+
}
|
37
41
|
}
|
38
|
-
|
39
|
-
|
42
|
+
END
|
43
|
+
end
|
40
44
|
|
41
45
|
it 'should not detect any problems' do
|
42
46
|
expect(problems).to have(0).problems
|
@@ -44,13 +48,15 @@ describe 'nested_classes_or_defines' do
|
|
44
48
|
end
|
45
49
|
|
46
50
|
context 'instantiating a parametised class inside a define' do
|
47
|
-
let(:code)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
+
let(:code) do
|
52
|
+
<<-END
|
53
|
+
define bar() {
|
54
|
+
class { 'foo':
|
55
|
+
bar => 'foobar'
|
56
|
+
}
|
51
57
|
}
|
52
|
-
|
53
|
-
|
58
|
+
END
|
59
|
+
end
|
54
60
|
|
55
61
|
it 'should not detect any problems' do
|
56
62
|
expect(problems).to have(0).problems
|
@@ -58,19 +64,21 @@ describe 'nested_classes_or_defines' do
|
|
58
64
|
end
|
59
65
|
|
60
66
|
context 'define inside a class' do
|
61
|
-
let(:code)
|
62
|
-
|
63
|
-
|
67
|
+
let(:code) do
|
68
|
+
<<-END
|
69
|
+
class foo {
|
70
|
+
define bar() {
|
71
|
+
}
|
64
72
|
}
|
65
|
-
|
66
|
-
|
73
|
+
END
|
74
|
+
end
|
67
75
|
|
68
76
|
it 'should only detect a single problem' do
|
69
77
|
expect(problems).to have(1).problems
|
70
78
|
end
|
71
79
|
|
72
80
|
it 'should create a warning' do
|
73
|
-
expect(problems).to contain_warning(define_msg).on_line(
|
81
|
+
expect(problems).to contain_warning(define_msg).on_line(2).in_column(11)
|
74
82
|
end
|
75
83
|
end
|
76
84
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe 'parameter_order' do
|
4
4
|
let(:msg) { 'optional parameter listed before required parameter' }
|
5
5
|
|
6
|
-
[
|
6
|
+
%w[define class].each do |type|
|
7
7
|
context "#{type} with attrs in order" do
|
8
8
|
let(:code) { "#{type} foo($bar, $baz='gronk') { }" }
|
9
9
|
|
@@ -27,17 +27,19 @@ describe 'parameter_order' do
|
|
27
27
|
expect(problems).to have(1).problem
|
28
28
|
end
|
29
29
|
|
30
|
-
col = (type ==
|
30
|
+
col = (type == 'class' ? 23 : 24)
|
31
31
|
it 'should create a warning' do
|
32
32
|
expect(problems).to contain_warning(msg).on_line(1).in_column(col)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
context "#{type} parameter set to another variable" do
|
37
|
-
let(:code)
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
let(:code) do
|
38
|
+
<<-END
|
39
|
+
#{type} foo($bar, $baz = $name, $gronk=$::fqdn) {
|
40
|
+
}
|
41
|
+
END
|
42
|
+
end
|
41
43
|
|
42
44
|
it 'should not detect any problems' do
|
43
45
|
expect(problems).to have(0).problems
|
@@ -45,29 +47,33 @@ describe 'parameter_order' do
|
|
45
47
|
end
|
46
48
|
|
47
49
|
context "#{type} parameter set to another variable with incorrect order" do
|
48
|
-
let(:code)
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
let(:code) do
|
51
|
+
<<-END
|
52
|
+
#{type} foo($baz = $name, $bar, $gronk=$::fqdn) {
|
53
|
+
}
|
54
|
+
END
|
55
|
+
end
|
52
56
|
|
53
57
|
it 'should only detect a single problem' do
|
54
58
|
expect(problems).to have(1).problem
|
55
59
|
end
|
56
60
|
|
57
|
-
col = (type ==
|
61
|
+
col = (type == 'class' ? 35 : 36)
|
58
62
|
it 'should create a warning' do
|
59
|
-
expect(problems).to contain_warning(msg).on_line(
|
63
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(col)
|
60
64
|
end
|
61
65
|
end
|
62
66
|
|
63
67
|
context 'issue-101' do
|
64
|
-
let(:code)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
let(:code) do
|
69
|
+
<<-END
|
70
|
+
#{type} b (
|
71
|
+
$foo,
|
72
|
+
$bar='',
|
73
|
+
$baz={}
|
74
|
+
) { }
|
75
|
+
END
|
76
|
+
end
|
71
77
|
|
72
78
|
it 'should not detect any problems' do
|
73
79
|
expect(problems).to have(0).problems
|
@@ -75,52 +81,71 @@ describe 'parameter_order' do
|
|
75
81
|
end
|
76
82
|
|
77
83
|
context "#{type} parameter w/a hash containing a variable and no optional parameters" do
|
78
|
-
let(:code)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
let(:code) do
|
85
|
+
<<-END
|
86
|
+
$var1 = 'test'
|
87
|
+
|
88
|
+
#{type} test (
|
89
|
+
$entries = {
|
90
|
+
'200 xxx' => {
|
91
|
+
param1 => $var1,
|
92
|
+
param2 => 'value2',
|
93
|
+
param3 => 'value3',
|
94
|
+
}
|
95
|
+
},
|
96
|
+
$mandatory => undef,
|
97
|
+
) { }
|
98
|
+
END
|
99
|
+
end
|
92
100
|
|
93
101
|
it { expect(problems).to have(0).problem }
|
94
102
|
end
|
95
103
|
|
96
104
|
context "#{type} parameter w/a hash containing a variable followed by an optional parameter" do
|
97
|
-
let(:code)
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
105
|
+
let(:code) do
|
106
|
+
<<-END
|
107
|
+
$var1 = 'test'
|
108
|
+
|
109
|
+
#{type} test (
|
110
|
+
$entries = {
|
111
|
+
'200 xxx' => {
|
112
|
+
param1 => $var1,
|
113
|
+
param2 => 'value2',
|
114
|
+
param3 => 'value3',
|
115
|
+
}
|
116
|
+
},
|
117
|
+
$optional,
|
118
|
+
$mandatory => undef,
|
119
|
+
) { }
|
120
|
+
END
|
121
|
+
end
|
122
|
+
|
123
|
+
it { expect(problems).to contain_warning(msg).on_line(11).in_column(13) }
|
114
124
|
end
|
115
125
|
|
116
126
|
context "#{type} parameter w/array containing a variable" do
|
117
|
-
let(:code)
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
127
|
+
let(:code) do
|
128
|
+
<<-END
|
129
|
+
#{type} test (
|
130
|
+
$var1 = [$::hostname, 'host'],
|
131
|
+
) { }
|
132
|
+
END
|
133
|
+
end
|
122
134
|
|
123
135
|
it { expect(problems).to have(0).problem }
|
124
136
|
end
|
137
|
+
|
138
|
+
context "#{type} parameter with Optional data type" do
|
139
|
+
let(:code) do
|
140
|
+
<<-END
|
141
|
+
#{type} test(
|
142
|
+
String $test = 'value',
|
143
|
+
Optional[String] $optional,
|
144
|
+
) { }
|
145
|
+
END
|
146
|
+
end
|
147
|
+
|
148
|
+
it { expect(problems).to have(0).problems }
|
149
|
+
end
|
125
150
|
end
|
126
151
|
end
|