puppet-lint 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +56 -0
  5. data/Gemfile +15 -4
  6. data/README.md +60 -5
  7. data/Rakefile +13 -0
  8. data/lib/puppet-lint.rb +21 -4
  9. data/lib/puppet-lint/configuration.rb +1 -0
  10. data/lib/puppet-lint/data.rb +12 -4
  11. data/lib/puppet-lint/lexer.rb +32 -7
  12. data/lib/puppet-lint/optparser.rb +4 -3
  13. data/lib/puppet-lint/plugins/check_classes.rb +73 -0
  14. data/lib/puppet-lint/plugins/check_comments.rb +4 -0
  15. data/lib/puppet-lint/plugins/check_conditionals.rb +4 -0
  16. data/lib/puppet-lint/plugins/check_documentation.rb +2 -0
  17. data/lib/puppet-lint/plugins/check_nodes.rb +2 -0
  18. data/lib/puppet-lint/plugins/check_resources.rb +80 -3
  19. data/lib/puppet-lint/plugins/check_strings.rb +13 -1
  20. data/lib/puppet-lint/plugins/check_variables.rb +6 -0
  21. data/lib/puppet-lint/plugins/check_whitespace.rb +12 -0
  22. data/lib/puppet-lint/version.rb +1 -1
  23. data/puppet-lint.gemspec +0 -2
  24. data/spec/fixtures/test/manifests/ignore_reason.pp +4 -1
  25. data/spec/fixtures/test/manifests/mismatched_control_comment.pp +1 -0
  26. data/spec/puppet-lint/bin_spec.rb +25 -12
  27. data/spec/puppet-lint/configuration_spec.rb +1 -0
  28. data/spec/puppet-lint/lexer_spec.rb +56 -2
  29. data/spec/puppet-lint/plugins/check_classes/code_on_top_scope_spec.rb +43 -0
  30. data/spec/puppet-lint/plugins/check_classes/name_contains_uppercase_spec.rb +66 -0
  31. data/spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb +49 -0
  32. data/spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +140 -51
  33. data/spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +24 -0
  34. data/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb +17 -0
  35. data/spec/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +8 -0
  36. data/spec/spec_helper.rb +5 -0
  37. metadata +9 -17
@@ -14,4 +14,28 @@ describe 'single_quote_string_with_variables' do
14
14
  expect(problems).to contain_error(msg).on_line(1).in_column(8)
15
15
  end
16
16
  end
17
+
18
+ context 'single quoted inline template with dollar signs has no problems' do
19
+ let (:code) {"
20
+ $list = ['one', 'two', 'three']
21
+ file { '/tmp/text.txt':
22
+ ensure => file,
23
+ content => inline_template('<% $list.each |$item| { %><%= \"${item}\n\" %><% } %>'),
24
+ }
25
+ "}
26
+
27
+ it { expect(problems).to have(0).problem }
28
+ end
29
+
30
+ context 'single quoted inline epp with dollar signs has no problems' do
31
+ let (:code) {"
32
+ $list = ['one', 'two', 'three']
33
+ file { '/tmp/text.txt':
34
+ ensure => file,
35
+ content => inline_template('<% @list.each do |item| %><%= @item %>\n<% end %>'),
36
+ }
37
+ "}
38
+
39
+ it { expect(problems).to have(0).problem }
40
+ end
17
41
  end
@@ -69,5 +69,22 @@ describe 'variables_not_enclosed' do
69
69
  expect(manifest).to eq(("'groovy'\n" * 20) + '" ${gronk}"')
70
70
  end
71
71
  end
72
+
73
+ context 'variables not enclosed in {}, delimited by -' do
74
+ let(:code) { '"$foo-$bar"' }
75
+
76
+ it 'should only detect two problems' do
77
+ expect(problems).to have(2).problems
78
+ end
79
+
80
+ it 'should fix the manifest' do
81
+ expect(problems).to contain_fixed(msg).on_line(1).in_column(2)
82
+ expect(problems).to contain_fixed(msg).on_line(1).in_column(7)
83
+ end
84
+
85
+ it 'should enclose both variables in braces' do
86
+ expect(manifest).to eq('"${foo}-${bar}"')
87
+ end
88
+ end
72
89
  end
73
90
  end
@@ -34,4 +34,12 @@ describe 'variable_contains_dash' do
34
34
  expect(problems).to be_empty
35
35
  end
36
36
  end
37
+
38
+ context 'enclosed variable in a string followed by a dash' do
39
+ let(:code) { '"${variable}-is-ok"' }
40
+
41
+ it 'should not detect any problems' do
42
+ expect(problems).to be_empty
43
+ end
44
+ end
37
45
  end
@@ -1,6 +1,11 @@
1
1
  require 'puppet-lint'
2
2
  require 'rspec/its'
3
3
  require 'rspec/collection_matchers'
4
+ begin
5
+ require 'rspec/json_expectations'
6
+ rescue SyntaxError
7
+ puts 'rspec/json_expectations is not available'
8
+ end
4
9
 
5
10
  module RSpec
6
11
  module LintExampleGroup
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sharpe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-19 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: github_changelog_generator
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
11
+ date: 2016-12-30 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: |-
28
14
  Checks your Puppet manifests against the Puppetlabs
29
15
  style guide and alerts you to any discrepancies.
@@ -74,6 +60,7 @@ files:
74
60
  - spec/fixtures/test/manifests/ignore_reason.pp
75
61
  - spec/fixtures/test/manifests/init.pp
76
62
  - spec/fixtures/test/manifests/malformed.pp
63
+ - spec/fixtures/test/manifests/mismatched_control_comment.pp
77
64
  - spec/fixtures/test/manifests/url_interpolation.pp
78
65
  - spec/fixtures/test/manifests/warning.pp
79
66
  - spec/puppet-lint/bin_spec.rb
@@ -83,7 +70,9 @@ files:
83
70
  - spec/puppet-lint/lexer_spec.rb
84
71
  - spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb
85
72
  - spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb
73
+ - spec/puppet-lint/plugins/check_classes/code_on_top_scope_spec.rb
86
74
  - spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb
75
+ - spec/puppet-lint/plugins/check_classes/name_contains_uppercase_spec.rb
87
76
  - spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb
88
77
  - spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb
89
78
  - spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb
@@ -148,6 +137,7 @@ test_files:
148
137
  - spec/fixtures/test/manifests/ignore_reason.pp
149
138
  - spec/fixtures/test/manifests/init.pp
150
139
  - spec/fixtures/test/manifests/malformed.pp
140
+ - spec/fixtures/test/manifests/mismatched_control_comment.pp
151
141
  - spec/fixtures/test/manifests/url_interpolation.pp
152
142
  - spec/fixtures/test/manifests/warning.pp
153
143
  - spec/puppet-lint/bin_spec.rb
@@ -157,7 +147,9 @@ test_files:
157
147
  - spec/puppet-lint/lexer_spec.rb
158
148
  - spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb
159
149
  - spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb
150
+ - spec/puppet-lint/plugins/check_classes/code_on_top_scope_spec.rb
160
151
  - spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb
152
+ - spec/puppet-lint/plugins/check_classes/name_contains_uppercase_spec.rb
161
153
  - spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb
162
154
  - spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb
163
155
  - spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb