puppet-lint-absolute_template_path 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: af85d198561d667385793e06959464ff6586ee1c
4
- data.tar.gz: e8e84e4479283dd2b67f6bec70e541f92fdd7474
2
+ SHA256:
3
+ metadata.gz: 02a0cdec7239448a8e68128530bfe37d0e08015e2918d2b4c6727cccb030fa7b
4
+ data.tar.gz: 7fdea9bcf4663a099fdf96e396197d987650e52b186aa08f4acfe6aa2719b8a4
5
5
  SHA512:
6
- metadata.gz: fcfec278a95babef8f415c1c5a131f4f2800f90e9629ea2b9c8e5daa30b7643834fcbb59b992714824005f34e00328fc6121d7fb7f20acbe917c66f73b5ece3d
7
- data.tar.gz: 2dd27e1e2fa00d393e5557e4ca65b15652532b12e3c109254f16cc07db0e572f5dc3493dcda4dcb293b8ff2b102ed8773a95abd5b55e7cfa23e3976a2f41a719
6
+ metadata.gz: 9acf95528a3d812914e8ee0cd083a2d8d65159e289286612701e4837813dbff0662a3decb71ef3e597972d9f6e3b30e9dd7971e255e8035212d20f7e61e4d1bc
7
+ data.tar.gz: 7993374239e66964b7c613839e6c0442267f6f84d1d54251363b9af85fc1c4ebcfa4ada566fc603b0065386b7d75805b5912dfcb01f1217732298490494dbebf
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # puppet-lint absolute template path check
2
2
 
3
+ [![Actions Status](https://github.com/deanwilson/puppet-lint-absolute_template_path-check/workflows/Ruby/badge.svg)](https://github.com/deanwilson/puppet-lint-absolute_template_path-check/actions)
4
+
3
5
  A new check for puppet-lint that checks template paths are in the
4
6
  relative `template('example/template.erb')` form rather than the absolute
5
7
  `template('/etc/puppet/modules/example/templates/template.erb')` format.
@@ -1,28 +1,28 @@
1
1
  PuppetLint.new_check(:absolute_template_path) do
2
2
  def check
3
3
  resource_indexes.each do |resource|
4
- if resource[:type].value == "file"
5
- resource[:param_tokens].select { |param_token|
6
- param_token.value == 'content'
7
- }.each do |content_token|
4
+ next unless resource[:type].value == 'file'
8
5
 
9
- value_token = content_token.next_code_token.next_code_token
6
+ content_tokens = resource[:param_tokens].select { |pt| pt.value == 'content' }
10
7
 
11
- if value_token.value.start_with? 'template'
12
- template_path = value_token.next_code_token.next_code_token.value
8
+ content_tokens.each do |content_token|
9
+ value_token = content_token.next_code_token.next_code_token
13
10
 
14
- if template_path.start_with? '/'
11
+ next unless value_token.value.start_with? 'template'
15
12
 
16
- notify :warning, {
17
- :message => 'template module paths should be relative, not absolute',
18
- :line => value_token.line,
19
- :column => value_token.column,
20
- :param_token => content_token,
21
- :value_token => value_token,
22
- }
23
- end
24
- end
25
- end
13
+ template_path = value_token.next_code_token.next_code_token.value
14
+
15
+ next unless template_path.start_with? '/' # skip relative paths
16
+
17
+ # if we made it here it's a file resource with a template parameter
18
+ # that begins with an absolute path, so raise a lint issue for it.
19
+ notify :warning, {
20
+ message: 'template module paths should be relative, not absolute',
21
+ line: value_token.line,
22
+ column: value_token.column,
23
+ param_token: content_token,
24
+ value_token: value_token,
25
+ }
26
26
  end
27
27
  end
28
28
  end
@@ -1,45 +1,77 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'absolute_template_path' do
4
-
5
4
  let(:msg) { 'template module paths should be relative, not absolute' }
6
5
 
6
+ context 'when the manifest has no file resources' do
7
+ let(:code) do
8
+ <<-TEST_CLASS
9
+ class no_file_resource {
10
+ host { 'syslog':
11
+ ip => '10.10.10.10',
12
+ }
13
+ }
14
+ TEST_CLASS
15
+ end
16
+
17
+ it 'does not detect any problems' do
18
+ expect(problems).to have(0).problems
19
+ end
20
+ end
21
+
22
+ context 'with file resource but no template call' do
23
+ context 'when the template has a relative module path' do
24
+ let(:code) do
25
+ <<-TEST_CLASS
26
+ class template_tester {
27
+ file { '/tmp/template':
28
+ content => 'A static string',
29
+ }
30
+ }
31
+ TEST_CLASS
32
+ end
33
+
34
+ it 'detects no problems' do
35
+ expect(problems).to have(0).problems
36
+ end
37
+ end
38
+ end
39
+
7
40
  context 'with fix disabled' do
8
- context 'template with a relative module path' do
41
+ context 'when the template has a relative module path' do
9
42
  let(:code) do
10
- <<-EOS
43
+ <<-TEST_CLASS
11
44
  class template_tester {
12
45
  file { '/tmp/template':
13
46
  content => template('example/template.erb'),
14
47
  }
15
48
  }
16
- EOS
49
+ TEST_CLASS
17
50
  end
18
51
 
19
- it 'should not detect any problems' do
52
+ it 'detects no problems' do
20
53
  expect(problems).to have(0).problems
21
54
  end
22
55
  end
23
56
 
24
- context 'template with an absolute module path' do
57
+ context 'when the template has an absolute module path' do
25
58
  let(:code) do
26
- <<-EOS
59
+ <<-TEST_CLASS
27
60
  class template_tester {
28
61
  file { '/tmp/template':
29
62
  content => template('/etc/puppet/modules/example/template.erb'),
30
63
  }
31
64
  }
32
- EOS
65
+ TEST_CLASS
33
66
  end
34
67
 
35
- it 'should detect a single problem' do
68
+ it 'detects a single problem' do
36
69
  expect(problems).to have(1).problem
37
70
  end
38
71
 
39
- it 'should create a warning' do
40
- expect(problems).to contain_warning(msg).on_line(3).in_column(26)
72
+ it 'creates a warning' do
73
+ expect(problems).to contain_warning(msg).on_line(3).in_column(26)
41
74
  end
42
75
  end
43
76
  end
44
-
45
77
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,8 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ enable_coverage :branch
4
+ end
5
+
1
6
  require 'puppet-lint'
2
7
 
3
8
  PuppetLint::Plugins.load_spec_helper
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-absolute_template_path
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-21 00:00:00.000000000 Z
11
+ date: 2023-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '1.1'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '3.0'
22
+ version: '5.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,23 +29,37 @@ dependencies:
29
29
  version: '1.1'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '3.0'
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 13.0.0
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 13.0.0
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: rspec
35
49
  requirement: !ruby/object:Gem::Requirement
36
50
  requirements:
37
51
  - - "~>"
38
52
  - !ruby/object:Gem::Version
39
- version: '3.0'
53
+ version: 3.12.0
40
54
  type: :development
41
55
  prerelease: false
42
56
  version_requirements: !ruby/object:Gem::Requirement
43
57
  requirements:
44
58
  - - "~>"
45
59
  - !ruby/object:Gem::Version
46
- version: '3.0'
60
+ version: 3.12.0
47
61
  - !ruby/object:Gem::Dependency
48
- name: rspec-its
62
+ name: rspec-collection_matchers
49
63
  requirement: !ruby/object:Gem::Requirement
50
64
  requirements:
51
65
  - - "~>"
@@ -59,7 +73,7 @@ dependencies:
59
73
  - !ruby/object:Gem::Version
60
74
  version: '1.0'
61
75
  - !ruby/object:Gem::Dependency
62
- name: rspec-collection_matchers
76
+ name: rspec-its
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
79
  - - "~>"
@@ -73,7 +87,35 @@ dependencies:
73
87
  - !ruby/object:Gem::Version
74
88
  version: '1.0'
75
89
  - !ruby/object:Gem::Dependency
76
- name: rake
90
+ name: rspec-json_expectations
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '2.2'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '2.2'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.52.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 1.52.0
117
+ - !ruby/object:Gem::Dependency
118
+ name: rubocop-rake
77
119
  requirement: !ruby/object:Gem::Requirement
78
120
  requirements:
79
121
  - - ">="
@@ -86,6 +128,34 @@ dependencies:
86
128
  - - ">="
87
129
  - !ruby/object:Gem::Version
88
130
  version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rubocop-rspec
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 2.22.0
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 2.22.0
145
+ - !ruby/object:Gem::Dependency
146
+ name: simplecov
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: 0.22.0
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: 0.22.0
89
159
  description: |2
90
160
  A new check for puppet-lint that checks all template paths are in the
91
161
  template('example/template.erb') form rather than
@@ -100,7 +170,7 @@ files:
100
170
  - lib/puppet-lint/plugins/absolute_template_path.rb
101
171
  - spec/puppet-lint/plugins/absolute_template_path_spec.rb
102
172
  - spec/spec_helper.rb
103
- homepage: https://github.com/deanwilson/puppet-lint-absolute_template_path
173
+ homepage: https://github.com/deanwilson/puppet-lint-absolute_template_path-check
104
174
  licenses:
105
175
  - MIT
106
176
  metadata: {}
@@ -112,19 +182,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
182
  requirements:
113
183
  - - ">="
114
184
  - !ruby/object:Gem::Version
115
- version: '0'
185
+ version: 2.7.0
116
186
  required_rubygems_version: !ruby/object:Gem::Requirement
117
187
  requirements:
118
188
  - - ">="
119
189
  - !ruby/object:Gem::Version
120
190
  version: '0'
121
191
  requirements: []
122
- rubyforge_project:
123
- rubygems_version: 2.4.8
192
+ rubygems_version: 3.1.6
124
193
  signing_key:
125
194
  specification_version: 4
126
195
  summary: puppet-lint absolute template path check
127
196
  test_files:
128
- - spec/spec_helper.rb
129
197
  - spec/puppet-lint/plugins/absolute_template_path_spec.rb
130
- has_rdoc:
198
+ - spec/spec_helper.rb