puppet-lint-resource_reference_syntax 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +120 -0
- data/README.md +28 -3
- data/lib/puppet-lint/plugins/resource_reference_chain_without_whitespace.rb +10 -10
- data/lib/puppet-lint/plugins/resource_reference_with_unquoted_title.rb +8 -8
- data/lib/puppet-lint/plugins/resource_reference_without_title_capital.rb +7 -8
- data/lib/puppet-lint/plugins/resource_reference_without_whitespace.rb +11 -11
- data/spec/puppet-lint/plugins/resource_reference_chain_without_whitespace_spec.rb +5 -5
- data/spec/puppet-lint/plugins/resource_reference_with_unquoted_title_spec.rb +19 -21
- data/spec/puppet-lint/plugins/resource_reference_without_title_capital_spec.rb +17 -18
- data/spec/puppet-lint/plugins/resource_reference_without_whitespace_spec.rb +19 -17
- data/spec/spec_helper.rb +26 -0
- metadata +13 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f32aeb42bb00beab070d3869e8ecf12b611d96b0559761bbac30d4ee9449160d
|
4
|
+
data.tar.gz: d4e486abfbc11b73d37c929c62de10a046a214520f9d0c90752df32fc3a96607
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2ec06471afc6e00d7502bbc92faa9dee391ccc28dba85349cfe50eaf0bb2636f3e70babdc6a7ad97accde1a9b9484bd4094ee2e5da48cdc340713e30c99d1b
|
7
|
+
data.tar.gz: 85ab216100d441cadc7045672db21c9e07026241d1da8fad0430576757ae952e23a647c7f0826ac362b0ab59368414783022f887688d6a992bd8e6dbe3c6bb3e
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
## [2.0.0](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/2.0.0) (2023-04-21)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.2.0...2.0.0)
|
8
|
+
|
9
|
+
**Breaking changes:**
|
10
|
+
|
11
|
+
- Drop Ruby \< 2.7; Add RuboCop [\#26](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/26) ([bastelfreak](https://github.com/bastelfreak))
|
12
|
+
|
13
|
+
## [1.2.0](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.2.0) (2022-11-29)
|
14
|
+
|
15
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.1.0...1.2.0)
|
16
|
+
|
17
|
+
**Implemented enhancements:**
|
18
|
+
|
19
|
+
- puppet-lint: Allow 3.x [\#24](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/24) ([bastelfreak](https://github.com/bastelfreak))
|
20
|
+
|
21
|
+
**Merged pull requests:**
|
22
|
+
|
23
|
+
- cleanup README.md/gemspec [\#21](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/21) ([bastelfreak](https://github.com/bastelfreak))
|
24
|
+
|
25
|
+
## [1.1.0](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.1.0) (2020-04-14)
|
26
|
+
|
27
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.0.14...1.1.0)
|
28
|
+
|
29
|
+
**Implemented enhancements:**
|
30
|
+
|
31
|
+
- Break out quoted refs check and add fix [\#16](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/16) ([danzilio](https://github.com/danzilio))
|
32
|
+
|
33
|
+
**Closed issues:**
|
34
|
+
|
35
|
+
- Doesn't detect spaces when using chaining arrows syntax \("Class \['A'\] -\> Class \['B'\]"\) [\#14](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/issues/14)
|
36
|
+
|
37
|
+
**Merged pull requests:**
|
38
|
+
|
39
|
+
- Remove ruby 1.9 from testing, add ruby 2.5 [\#17](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/17) ([tuxmea](https://github.com/tuxmea))
|
40
|
+
|
41
|
+
## [1.0.14](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.0.14) (2018-01-04)
|
42
|
+
|
43
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.0.13...1.0.14)
|
44
|
+
|
45
|
+
## [1.0.13](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.0.13) (2018-01-03)
|
46
|
+
|
47
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.0.12...1.0.13)
|
48
|
+
|
49
|
+
## [1.0.12](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.0.12) (2018-01-03)
|
50
|
+
|
51
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.0.11...1.0.12)
|
52
|
+
|
53
|
+
**Closed issues:**
|
54
|
+
|
55
|
+
- false resource\_reference\_without\_whitespace on resource collection [\#15](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/issues/15)
|
56
|
+
- resource\_reference\_without\_whitespace error on resource collection [\#9](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/issues/9)
|
57
|
+
|
58
|
+
## [1.0.11](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.0.11) (2017-12-30)
|
59
|
+
|
60
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.0.10...1.0.11)
|
61
|
+
|
62
|
+
**Merged pull requests:**
|
63
|
+
|
64
|
+
- release 1.0.10 [\#13](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/13) ([tuxmea](https://github.com/tuxmea))
|
65
|
+
|
66
|
+
## [1.0.10](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.0.10) (2016-11-17)
|
67
|
+
|
68
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.0.8...1.0.10)
|
69
|
+
|
70
|
+
**Closed issues:**
|
71
|
+
|
72
|
+
- False positive for require [\#10](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/issues/10)
|
73
|
+
|
74
|
+
**Merged pull requests:**
|
75
|
+
|
76
|
+
- Restrict checking to the matched parameter only [\#12](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/12) ([cbowman0](https://github.com/cbowman0))
|
77
|
+
- Improve message for resources missing quotes [\#11](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/11) ([domcleal](https://github.com/domcleal))
|
78
|
+
- add travis with voxpupili key [\#8](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/8) ([tuxmea](https://github.com/tuxmea))
|
79
|
+
- Release 1.0.9 [\#7](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/7) ([bastelfreak](https://github.com/bastelfreak))
|
80
|
+
|
81
|
+
## [1.0.8](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.0.8) (2016-03-17)
|
82
|
+
|
83
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.0.7...1.0.8)
|
84
|
+
|
85
|
+
**Closed issues:**
|
86
|
+
|
87
|
+
- False warning: resource reference with title with capital letter [\#4](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/issues/4)
|
88
|
+
- False warning: whitespce between reference type and title [\#3](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/issues/3)
|
89
|
+
|
90
|
+
## [1.0.7](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.0.7) (2016-03-16)
|
91
|
+
|
92
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.0.6...1.0.7)
|
93
|
+
|
94
|
+
**Merged pull requests:**
|
95
|
+
|
96
|
+
- iterate over resource reference arrays [\#5](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/5) ([tuxmea](https://github.com/tuxmea))
|
97
|
+
|
98
|
+
## [1.0.6](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.0.6) (2016-01-25)
|
99
|
+
|
100
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.0.5...1.0.6)
|
101
|
+
|
102
|
+
**Closed issues:**
|
103
|
+
|
104
|
+
- Wrong match when a variable is in the title [\#1](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/issues/1)
|
105
|
+
|
106
|
+
**Merged pull requests:**
|
107
|
+
|
108
|
+
- Fix wrong match on titles with variables \(fixes \#1\) [\#2](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/pull/2) ([vStone](https://github.com/vStone))
|
109
|
+
|
110
|
+
## [1.0.5](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.0.5) (2015-11-26)
|
111
|
+
|
112
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/1.0.4...1.0.5)
|
113
|
+
|
114
|
+
## [1.0.4](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/tree/1.0.4) (2015-10-18)
|
115
|
+
|
116
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/compare/5ef5832a944246df5d3e7c781085e3a76357b641...1.0.4)
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/README.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
# puppet-lint plugin resource reference check
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
[![License](https://img.shields.io/github/license/voxpupuli/puppet-lint-resource_reference_syntax.svg)](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/blob/master/LICENSE)
|
4
|
+
[![Test](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/actions/workflows/test.yml)
|
5
|
+
[![Release](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/puppet-lint-resource_reference_syntax/actions/workflows/release.yml)
|
6
|
+
[![RubyGem Version](https://img.shields.io/gem/v/puppet-lint-resource_reference_syntax.svg)](https://rubygems.org/gems/puppet-lint-resource_reference_syntax)
|
7
|
+
[![RubyGem Downloads](https://img.shields.io/gem/dt/puppet-lint-resource_reference_syntax.svg)](https://rubygems.org/gems/puppet-lint-resource_reference_syntax)
|
8
|
+
[![Donated by example42](https://img.shields.io/badge/donated%20by-example42-fb7047.svg)](#transfer-notice)
|
9
|
+
|
10
|
+
**Note, this plugin will check for Puppet resource reference syntax which will no longer work with Puppet 4.x.**
|
5
11
|
|
6
12
|
## Installation
|
7
13
|
|
@@ -55,7 +61,26 @@ The following references are good code for Puppet 4:
|
|
55
61
|
|
56
62
|
```
|
57
63
|
require => Service['apache'],
|
58
|
-
require => Service['apache', 'mysql'],
|
64
|
+
require => Service['apache', 'mysql'],
|
59
65
|
require => [ Service['apache'], Service['mysql'] ],
|
60
66
|
```
|
61
67
|
|
68
|
+
## Transfer Notice
|
69
|
+
|
70
|
+
This plugin was originally authored by [example42](https://example42.de).
|
71
|
+
The maintainer preferred that Puppet Community take ownership of the module for future improvement and maintenance.
|
72
|
+
Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of Camptocamp.
|
73
|
+
|
74
|
+
## License
|
75
|
+
|
76
|
+
This gem is licensed under the Apache-2 license.
|
77
|
+
|
78
|
+
## Release information
|
79
|
+
|
80
|
+
To make a new release, please do:
|
81
|
+
* update the version in the gemspec file
|
82
|
+
* Install gems with `bundle install --with release --path .vendor`
|
83
|
+
* generate the changelog with `bundle exec rake changelog`
|
84
|
+
* Check if the new version matches the closed issues/PRs in the changelog
|
85
|
+
* Create a PR with it
|
86
|
+
* After it got merged, push a tag. GitHub actions will do the actual release to rubygems and GitHub Packages
|
@@ -1,21 +1,21 @@
|
|
1
1
|
# Check for Class references
|
2
2
|
PuppetLint.new_check(:resource_reference_chain_without_whitespace) do
|
3
3
|
def check
|
4
|
-
tokens.select
|
4
|
+
tokens.select do |token|
|
5
5
|
[:TYPE].include? token.type
|
6
|
-
|
6
|
+
end.each do |param_token|
|
7
7
|
check = param_token
|
8
8
|
case check.type
|
9
9
|
when :TYPE
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
10
|
+
|
11
|
+
if check.next_token.type == :WHITESPACE and check.next_code_token.type == :LBRACK
|
12
|
+
notify :error, {
|
13
|
+
message: 'whitespce between reference type and title',
|
14
|
+
line: check.line,
|
15
|
+
column: check.column,
|
16
|
+
}
|
18
17
|
end
|
18
|
+
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
PuppetLint.new_check(:resource_reference_with_unquoted_title) do
|
2
2
|
def check
|
3
3
|
resource_indexes.each do |resource|
|
4
|
-
resource[:param_tokens].select
|
5
|
-
[
|
6
|
-
|
4
|
+
resource[:param_tokens].select do |param_token|
|
5
|
+
%w[require subscribe notify before consume export].include? param_token.value
|
6
|
+
end.each do |param_token|
|
7
7
|
value_token = param_token.next_code_token
|
8
8
|
check = value_token.next_token
|
9
|
-
until resource[:param_tokens].include? check or
|
9
|
+
until resource[:param_tokens].include? check or !resource[:tokens].include? check or check.nil?
|
10
10
|
case value_token.next_token.type
|
11
11
|
when :CLASSREF
|
12
12
|
begin
|
@@ -14,10 +14,10 @@ PuppetLint.new_check(:resource_reference_with_unquoted_title) do
|
|
14
14
|
check_token = value_token.next_token.next_token.next_token
|
15
15
|
if check_token.type == :NAME
|
16
16
|
notify :error, {
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
17
|
+
message: 'unquoted title in resource reference',
|
18
|
+
line: check_token.line,
|
19
|
+
column: check_token.column,
|
20
|
+
token: check_token,
|
21
21
|
}
|
22
22
|
end
|
23
23
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
PuppetLint.new_check(:resource_reference_without_title_capital) do
|
2
2
|
def check
|
3
3
|
resource_indexes.each do |resource|
|
4
|
-
resource[:param_tokens].select
|
5
|
-
[
|
6
|
-
|
4
|
+
resource[:param_tokens].select do |param_token|
|
5
|
+
%w[require subscribe notify before consume export].include? param_token.value
|
6
|
+
end.each do |param_token|
|
7
7
|
value_token = param_token.next_code_token
|
8
8
|
check = value_token.next_token
|
9
|
-
until resource[:param_tokens].include? check or
|
9
|
+
until resource[:param_tokens].include? check or !resource[:tokens].include? check or check.nil?
|
10
10
|
case value_token.next_token.type
|
11
11
|
when :CLASSREF
|
12
12
|
begin
|
@@ -14,9 +14,9 @@ PuppetLint.new_check(:resource_reference_without_title_capital) do
|
|
14
14
|
check_token = value_token.next_token.next_token.next_token
|
15
15
|
if check_token.type == :CLASSREF
|
16
16
|
notify :error, {
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
17
|
+
message: 'resource reference with title with capital letter',
|
18
|
+
line: check_token.line,
|
19
|
+
column: check_token.column,
|
20
20
|
}
|
21
21
|
end
|
22
22
|
end
|
@@ -32,4 +32,3 @@ PuppetLint.new_check(:resource_reference_without_title_capital) do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
@@ -1,22 +1,22 @@
|
|
1
1
|
# Check for resource references
|
2
2
|
PuppetLint.new_check(:resource_reference_without_whitespace) do
|
3
3
|
def check
|
4
|
-
resource_indexes.each do |
|
5
|
-
tokens.select
|
4
|
+
resource_indexes.each do |_resource|
|
5
|
+
tokens.select do |token|
|
6
6
|
[:CLASSREF].include? token.type
|
7
|
-
|
7
|
+
end.each do |param_token|
|
8
8
|
check = param_token
|
9
9
|
case check.type
|
10
10
|
when :CLASSREF
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
11
|
+
|
12
|
+
if check.next_token.type == :WHITESPACE and check.next_code_token.type == :LBRACK
|
13
|
+
notify :error, {
|
14
|
+
message: 'whitespce between reference type and title',
|
15
|
+
line: check.line,
|
16
|
+
column: check.column,
|
17
|
+
}
|
19
18
|
end
|
19
|
+
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'resource_reference_chain_without_whitespace' do
|
4
|
-
|
5
4
|
context 'a whitespace between reference and bracket on chains' do
|
6
5
|
let(:msg) { 'whitespce between reference type and title' }
|
7
|
-
let(:code)
|
6
|
+
let(:code) do
|
7
|
+
"class foo { include foo::install include foo::config include foo::service Class ['foo::install'] -> Class ['foo::config'] ~> Class ['foo::service'] } "
|
8
|
+
end
|
8
9
|
|
9
|
-
it '
|
10
|
+
it 'detects two problems' do
|
10
11
|
expect(problems).to have(3).problem
|
11
12
|
end
|
12
13
|
|
13
|
-
it '
|
14
|
+
it 'creates an error' do
|
14
15
|
expect(problems).to contain_error(msg).on_line(1)
|
15
16
|
end
|
16
17
|
end
|
17
|
-
|
18
18
|
end
|
@@ -7,7 +7,7 @@ describe 'resource_reference_with_unquoted_title' do
|
|
7
7
|
context 'quoted resource ref on single line resource' do
|
8
8
|
let(:code) { "file { 'foo': require => File['bar'] }" }
|
9
9
|
|
10
|
-
it '
|
10
|
+
it 'does not detect any problems' do
|
11
11
|
expect(problems).to have(0).problems
|
12
12
|
end
|
13
13
|
end
|
@@ -15,16 +15,15 @@ describe 'resource_reference_with_unquoted_title' do
|
|
15
15
|
context 'unquoted resource ref on single line resource' do
|
16
16
|
let(:code) { "file { 'foo': require => File[bar] }" }
|
17
17
|
|
18
|
-
it '
|
18
|
+
it 'onlies detect a single problem' do
|
19
19
|
expect(problems).to have(1).problem
|
20
20
|
end
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'raises an error' do
|
23
23
|
expect(problems).to contain_error(msg).on_line(1).in_column(31)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
27
|
context 'quoted resource ref on multi line resource' do
|
29
28
|
let(:code) do
|
30
29
|
<<-END
|
@@ -34,7 +33,7 @@ describe 'resource_reference_with_unquoted_title' do
|
|
34
33
|
END
|
35
34
|
end
|
36
35
|
|
37
|
-
it '
|
36
|
+
it 'does not detect any problems' do
|
38
37
|
expect(problems).to have(0).problems
|
39
38
|
end
|
40
39
|
end
|
@@ -48,11 +47,11 @@ describe 'resource_reference_with_unquoted_title' do
|
|
48
47
|
END
|
49
48
|
end
|
50
49
|
|
51
|
-
it '
|
50
|
+
it 'onlies detect a single problem' do
|
52
51
|
expect(problems).to have(1).problem
|
53
52
|
end
|
54
53
|
|
55
|
-
it '
|
54
|
+
it 'raises an error' do
|
56
55
|
expect(problems).to contain_error(msg).on_line(2).in_column(29)
|
57
56
|
end
|
58
57
|
end
|
@@ -69,7 +68,7 @@ describe 'resource_reference_with_unquoted_title' do
|
|
69
68
|
END
|
70
69
|
end
|
71
70
|
|
72
|
-
it '
|
71
|
+
it 'does not detect any problems' do
|
73
72
|
expect(problems).to have(0).problems
|
74
73
|
end
|
75
74
|
end
|
@@ -86,11 +85,11 @@ describe 'resource_reference_with_unquoted_title' do
|
|
86
85
|
END
|
87
86
|
end
|
88
87
|
|
89
|
-
it '
|
88
|
+
it 'onlies detect a single problem' do
|
90
89
|
expect(problems).to have(1).problem
|
91
90
|
end
|
92
91
|
|
93
|
-
it '
|
92
|
+
it 'raises an error' do
|
94
93
|
expect(problems).to contain_error(msg).on_line(3).in_column(31)
|
95
94
|
end
|
96
95
|
end
|
@@ -106,11 +105,10 @@ describe 'resource_reference_with_unquoted_title' do
|
|
106
105
|
END
|
107
106
|
end
|
108
107
|
|
109
|
-
it '
|
108
|
+
it 'does not detect any problems' do
|
110
109
|
expect(problems).to have(0).problems
|
111
110
|
end
|
112
111
|
end
|
113
|
-
|
114
112
|
end
|
115
113
|
|
116
114
|
context 'with fix enabled' do
|
@@ -125,15 +123,15 @@ describe 'resource_reference_with_unquoted_title' do
|
|
125
123
|
context 'unquoted resource ref on single line resource' do
|
126
124
|
let(:code) { "file { 'foo': require => File[bar] }" }
|
127
125
|
|
128
|
-
it '
|
126
|
+
it 'onlies detect a single problem' do
|
129
127
|
expect(problems).to have(1).problem
|
130
128
|
end
|
131
129
|
|
132
|
-
it '
|
130
|
+
it 'fixes the manifest' do
|
133
131
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(31)
|
134
132
|
end
|
135
133
|
|
136
|
-
it '
|
134
|
+
it 'singles quote the resource title' do
|
137
135
|
expect(manifest).to eq("file { 'foo': require => File['bar'] }")
|
138
136
|
end
|
139
137
|
end
|
@@ -155,15 +153,15 @@ describe 'resource_reference_with_unquoted_title' do
|
|
155
153
|
END
|
156
154
|
end
|
157
155
|
|
158
|
-
it '
|
156
|
+
it 'onlies detect a single problem' do
|
159
157
|
expect(problems).to have(1).problem
|
160
158
|
end
|
161
159
|
|
162
|
-
it '
|
160
|
+
it 'fixes the manifest' do
|
163
161
|
expect(problems).to contain_fixed(msg).on_line(2).in_column(29)
|
164
162
|
end
|
165
163
|
|
166
|
-
it '
|
164
|
+
it 'singles quote the resource ref' do
|
167
165
|
expect(manifest).to eq(fixed)
|
168
166
|
end
|
169
167
|
end
|
@@ -191,15 +189,15 @@ describe 'resource_reference_with_unquoted_title' do
|
|
191
189
|
END
|
192
190
|
end
|
193
191
|
|
194
|
-
it '
|
192
|
+
it 'onlies detect a single problem' do
|
195
193
|
expect(problems).to have(1).problem
|
196
194
|
end
|
197
195
|
|
198
|
-
it '
|
196
|
+
it 'fixes the manifest' do
|
199
197
|
expect(problems).to contain_fixed(msg).on_line(3).in_column(31)
|
200
198
|
end
|
201
199
|
|
202
|
-
it '
|
200
|
+
it 'singles quote the resource title' do
|
203
201
|
expect(manifest).to eq(fixed)
|
204
202
|
end
|
205
203
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'resource_reference_without_title_capital' do
|
4
|
-
|
5
4
|
context 'a proper reference' do
|
6
5
|
let(:msg) { 'whitespce between reference type and title' }
|
7
6
|
let(:code) { "file { 'foo': ensure => file, notify => Title['one'],}" }
|
8
7
|
|
9
|
-
it '
|
8
|
+
it 'detects no problem' do
|
10
9
|
expect(problems).to have(0).problem
|
11
10
|
end
|
12
11
|
end
|
@@ -14,7 +13,7 @@ describe 'resource_reference_without_title_capital' do
|
|
14
13
|
context 'a proper reference in quotes' do
|
15
14
|
let(:code) { "file { 'foo': ensure => file, notify => Title['One'],}" }
|
16
15
|
|
17
|
-
it '
|
16
|
+
it 'detects no problem' do
|
18
17
|
expect(problems).to have(0).problem
|
19
18
|
end
|
20
19
|
end
|
@@ -22,7 +21,7 @@ describe 'resource_reference_without_title_capital' do
|
|
22
21
|
context 'a proper reference as array in quotes' do
|
23
22
|
let(:code) { "file { 'foo': ensure => file, notify => Title['one', 'two'],}" }
|
24
23
|
|
25
|
-
it '
|
24
|
+
it 'detects no problem' do
|
26
25
|
expect(problems).to have(0).problem
|
27
26
|
end
|
28
27
|
end
|
@@ -30,7 +29,7 @@ describe 'resource_reference_without_title_capital' do
|
|
30
29
|
context 'multiple proper references as array in quotes' do
|
31
30
|
let(:code) { "file { 'foo': ensure => file, notify => [ Title['one'], Title['two'] ],}" }
|
32
31
|
|
33
|
-
it '
|
32
|
+
it 'detects no problem' do
|
34
33
|
expect(problems).to have(0).problem
|
35
34
|
end
|
36
35
|
end
|
@@ -38,7 +37,7 @@ describe 'resource_reference_without_title_capital' do
|
|
38
37
|
context 'multiple proper references as array one in quotes, one as variable' do
|
39
38
|
let(:code) { "file { 'foo': ensure => file, notify => [ Title['one'], Title[$foo_var] ],}" }
|
40
39
|
|
41
|
-
it '
|
40
|
+
it 'detects no problem' do
|
42
41
|
expect(problems).to have(0).problem
|
43
42
|
end
|
44
43
|
end
|
@@ -46,16 +45,17 @@ describe 'resource_reference_without_title_capital' do
|
|
46
45
|
context 'a proper reference as variable' do
|
47
46
|
let(:code) { "file { 'foo': ensure => file, notify => Title[$foo_var],}" }
|
48
47
|
|
49
|
-
it '
|
48
|
+
it 'detects no problem' do
|
50
49
|
expect(problems).to have(0).problem
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
54
53
|
context 'a proper reference with a variable enclosed' do
|
55
|
-
let(:code)
|
54
|
+
let(:code) do
|
56
55
|
%(file {'foo': ensure => file, notify => Title["with ${param}"],} )
|
57
|
-
|
58
|
-
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'detects no problem' do
|
59
59
|
expect(problems).to have(0).problem
|
60
60
|
end
|
61
61
|
end
|
@@ -64,11 +64,11 @@ describe 'resource_reference_without_title_capital' do
|
|
64
64
|
let(:msg) { 'resource reference with title with capital letter' }
|
65
65
|
let(:code) { "file { 'foo': ensure => file, notify => Title[One],}" }
|
66
66
|
|
67
|
-
it '
|
67
|
+
it 'onlies detect a single problem' do
|
68
68
|
expect(problems).to have(1).problem
|
69
69
|
end
|
70
70
|
|
71
|
-
it '
|
71
|
+
it 'creates an error' do
|
72
72
|
expect(problems).to contain_error(msg).on_line(1)
|
73
73
|
end
|
74
74
|
end
|
@@ -77,11 +77,11 @@ describe 'resource_reference_without_title_capital' do
|
|
77
77
|
let(:msg) { 'resource reference with title with capital letter' }
|
78
78
|
let(:code) { "file { 'foo': ensure => file, notify => Title[One, Two],}" }
|
79
79
|
|
80
|
-
it '
|
80
|
+
it 'onlies detect a single problem' do
|
81
81
|
expect(problems)
|
82
82
|
end
|
83
83
|
|
84
|
-
it '
|
84
|
+
it 'creates an error' do
|
85
85
|
expect(problems).to contain_error(msg).on_line(1)
|
86
86
|
end
|
87
87
|
end
|
@@ -90,11 +90,11 @@ describe 'resource_reference_without_title_capital' do
|
|
90
90
|
let(:msg) { 'resource reference with title with capital letter' }
|
91
91
|
let(:code) { "file { 'foo': ensure => file, notify => [Title[One], Title[Two],]}" }
|
92
92
|
|
93
|
-
it '
|
93
|
+
it 'onlies detect a single problem' do
|
94
94
|
expect(problems)
|
95
95
|
end
|
96
96
|
|
97
|
-
it '
|
97
|
+
it 'creates an error' do
|
98
98
|
expect(problems).to contain_error(msg).on_line(1)
|
99
99
|
end
|
100
100
|
end
|
@@ -102,9 +102,8 @@ describe 'resource_reference_without_title_capital' do
|
|
102
102
|
context 'stay within the parameter context' do
|
103
103
|
let(:code) { "file { 'foo': ensure => file, notify => Title['One'],} $var = [ Exec[runsomething] ]" }
|
104
104
|
|
105
|
-
it '
|
105
|
+
it 'detects no problem' do
|
106
106
|
expect(problems).to have(0).problem
|
107
107
|
end
|
108
108
|
end
|
109
|
-
|
110
109
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'resource_reference_without_whitespace' do
|
4
|
-
|
5
4
|
context 'a proper reference as array' do
|
6
5
|
let(:msg) { 'whitespce between reference type and title' }
|
7
6
|
let(:code) { "file { 'foo': ensure => file, notify => [ Title['one'], Title['two'] ]}" }
|
8
7
|
|
9
|
-
it '
|
8
|
+
it 'detects no problem' do
|
10
9
|
expect(problems).to have(0).problem
|
11
10
|
end
|
12
11
|
end
|
@@ -15,7 +14,7 @@ describe 'resource_reference_without_whitespace' do
|
|
15
14
|
let(:msg) { 'whitespce between reference type and title' }
|
16
15
|
let(:code) { "file { 'foo': ensure => file, notify => [ Title['one'], Title[$two] ]}" }
|
17
16
|
|
18
|
-
it '
|
17
|
+
it 'detects no problem' do
|
19
18
|
expect(problems).to have(0).problem
|
20
19
|
end
|
21
20
|
end
|
@@ -24,7 +23,7 @@ describe 'resource_reference_without_whitespace' do
|
|
24
23
|
let(:msg) { 'whitespce between reference type and title' }
|
25
24
|
let(:code) { "file { 'foo': ensure => file, notify => Title['one'],}" }
|
26
25
|
|
27
|
-
it '
|
26
|
+
it 'detects no problem' do
|
28
27
|
expect(problems).to have(0).problem
|
29
28
|
end
|
30
29
|
end
|
@@ -33,11 +32,11 @@ describe 'resource_reference_without_whitespace' do
|
|
33
32
|
let(:msg) { 'whitespce between reference type and title' }
|
34
33
|
let(:code) { "file { 'foo': ensure => file, consume => Title ['one'],}" }
|
35
34
|
|
36
|
-
it '
|
35
|
+
it 'onlies detect a single problem' do
|
37
36
|
expect(problems).to have(1).problem
|
38
37
|
end
|
39
38
|
|
40
|
-
it '
|
39
|
+
it 'creates an error' do
|
41
40
|
expect(problems).to contain_error(msg).on_line(1)
|
42
41
|
end
|
43
42
|
end
|
@@ -46,19 +45,21 @@ describe 'resource_reference_without_whitespace' do
|
|
46
45
|
let(:msg) { 'whitespce between reference type and title' }
|
47
46
|
let(:code) { "file { 'foo': ensure => file, consume => [ Title ['one'], Title['two']],}" }
|
48
47
|
|
49
|
-
it '
|
48
|
+
it 'onlies detect a single problem' do
|
50
49
|
expect(problems).to have(1).problem
|
51
50
|
end
|
52
51
|
|
53
|
-
it '
|
52
|
+
it 'creates an error' do
|
54
53
|
expect(problems).to contain_error(msg).on_line(1)
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
58
57
|
context 'stay within the parameter context' do
|
59
|
-
let(:code)
|
58
|
+
let(:code) do
|
59
|
+
"package { 'bar': ensure => installed,} exec { 'baz': require => Package['bar'],} file { 'foo': ensure => file,}"
|
60
|
+
end
|
60
61
|
|
61
|
-
it '
|
62
|
+
it 'detects no problem' do
|
62
63
|
expect(problems).to have(0).problem
|
63
64
|
end
|
64
65
|
end
|
@@ -67,24 +68,26 @@ describe 'resource_reference_without_whitespace' do
|
|
67
68
|
let(:msg) { 'whitespce between reference type and title' }
|
68
69
|
let(:code) { "package { 'one': ensure => present, } Package ['one'] ~> Service ['two']" }
|
69
70
|
|
70
|
-
it '
|
71
|
+
it 'detects two problems' do
|
71
72
|
expect(problems).to have(2).problem
|
72
73
|
end
|
73
74
|
|
74
|
-
it '
|
75
|
+
it 'creates an error' do
|
75
76
|
expect(problems).to contain_error(msg).on_line(1)
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
80
|
context 'more resources and a whitespace between reference and bracket on chains' do
|
80
81
|
let(:msg) { 'whitespce between reference type and title' }
|
81
|
-
let(:code)
|
82
|
+
let(:code) do
|
83
|
+
"package { 'one': ensure => present, } package { 'two': ensure => present, } Package ['one'] ~> Service['two']"
|
84
|
+
end
|
82
85
|
|
83
|
-
it '
|
86
|
+
it 'detects one problem' do
|
84
87
|
expect(problems).to have(2).problem
|
85
88
|
end
|
86
89
|
|
87
|
-
it '
|
90
|
+
it 'creates an error' do
|
88
91
|
expect(problems).to contain_error(msg).on_line(1)
|
89
92
|
end
|
90
93
|
end
|
@@ -92,9 +95,8 @@ describe 'resource_reference_without_whitespace' do
|
|
92
95
|
context 'collectors should not cause an error' do
|
93
96
|
let(:code) { "@package { 'bar': ensure => installed,} Package <| |>" }
|
94
97
|
|
95
|
-
it '
|
98
|
+
it 'detects no problem' do
|
96
99
|
expect(problems).to have(0).problem
|
97
100
|
end
|
98
101
|
end
|
99
|
-
|
100
102
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'simplecov'
|
5
|
+
require 'simplecov-console'
|
6
|
+
require 'codecov'
|
7
|
+
rescue LoadError
|
8
|
+
else
|
9
|
+
SimpleCov.start do
|
10
|
+
track_files 'lib/**/*.rb'
|
11
|
+
|
12
|
+
add_filter '/spec'
|
13
|
+
|
14
|
+
enable_coverage :branch
|
15
|
+
|
16
|
+
# do not track vendored files
|
17
|
+
add_filter '/vendor'
|
18
|
+
add_filter '/.vendor'
|
19
|
+
end
|
20
|
+
|
21
|
+
SimpleCov.formatters = [
|
22
|
+
SimpleCov::Formatter::Console,
|
23
|
+
SimpleCov::Formatter::Codecov,
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
1
27
|
require 'puppet-lint'
|
2
28
|
|
3
29
|
PuppetLint::Plugins.load_spec_helper
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-resource_reference_syntax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Vox Pupuli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -16,98 +16,29 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '5'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '3'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: rspec
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.0'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '3.0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rspec-its
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '1.0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '1.0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: rspec-collection_matchers
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '1.0'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '1.0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: rake
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - ">="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: simplecov
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - ">="
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '0'
|
32
|
+
version: '5'
|
103
33
|
description: " Extends puppet-lint to ensure that the reference syntax follows
|
104
34
|
Puppet 4 style\n"
|
105
|
-
email:
|
35
|
+
email: voxpupuli@groups.io
|
106
36
|
executables: []
|
107
37
|
extensions: []
|
108
38
|
extra_rdoc_files: []
|
109
39
|
files:
|
110
40
|
- ".rspec"
|
41
|
+
- CHANGELOG.md
|
111
42
|
- LICENSE
|
112
43
|
- README.md
|
113
44
|
- lib/puppet-lint/plugins/resource_reference_chain_without_whitespace.rb
|
@@ -121,7 +52,7 @@ files:
|
|
121
52
|
- spec/spec_helper.rb
|
122
53
|
homepage: https://github.com/voxpupuli/puppet-lint-resource_reference_syntax
|
123
54
|
licenses:
|
124
|
-
-
|
55
|
+
- Apache-2.0
|
125
56
|
metadata: {}
|
126
57
|
post_install_message:
|
127
58
|
rdoc_options: []
|
@@ -131,21 +62,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
62
|
requirements:
|
132
63
|
- - ">="
|
133
64
|
- !ruby/object:Gem::Version
|
134
|
-
version:
|
65
|
+
version: 2.7.0
|
135
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
67
|
requirements:
|
137
68
|
- - ">="
|
138
69
|
- !ruby/object:Gem::Version
|
139
70
|
version: '0'
|
140
71
|
requirements: []
|
141
|
-
|
142
|
-
rubygems_version: 2.7.7
|
72
|
+
rubygems_version: 3.2.33
|
143
73
|
signing_key:
|
144
74
|
specification_version: 4
|
145
75
|
summary: puppet-lint reference_syntax check
|
146
|
-
test_files:
|
147
|
-
- spec/spec_helper.rb
|
148
|
-
- spec/puppet-lint/plugins/resource_reference_without_whitespace_spec.rb
|
149
|
-
- spec/puppet-lint/plugins/resource_reference_without_title_capital_spec.rb
|
150
|
-
- spec/puppet-lint/plugins/resource_reference_chain_without_whitespace_spec.rb
|
151
|
-
- spec/puppet-lint/plugins/resource_reference_with_unquoted_title_spec.rb
|
76
|
+
test_files: []
|