puppet-lint-appends-check 0.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +32 -7
- data/lib/puppet-lint/plugins/check_appends.rb +9 -9
- data/spec/puppet-lint/plugins/check_appends/appends_spec.rb +105 -0
- data/spec/spec_helper.rb +24 -3
- metadata +31 -92
- data/spec/puppet-lint/plugins/check_absolute_classname/relative_classname_inclusion_spec.rb +0 -113
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ab3e65beafd5bcfc694834485017bd3de56fe2c200bd68cdebcbe09baf02be1e
|
4
|
+
data.tar.gz: b7a6a13d0fea22170bc93f19b46108f284ea1bbffccb145fe9971c9ab9670757
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fb109206d0dfe091fea1696e71ef5851289f362d91a441c2e9e69bcb622b0123d43a92a2964e3bc75bf696c16e0c0bbb5ae35b877ce8d1efdee9b9e61c882d2
|
7
|
+
data.tar.gz: a5cd26e63f172046311ede0672b61eaa69fd616cad219f0431463638427221049643f429e3a9254091000d407e162eab35acfa4eba0f889323c2c9d7d16d71f6
|
data/README.md
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
puppet-lint-appends-check
|
2
2
|
====================================
|
3
3
|
|
4
|
-
[![
|
5
|
-
[![
|
6
|
-
[![
|
7
|
-
|
8
|
-
|
4
|
+
[![License](https://img.shields.io/github/license/voxpupuli/puppet-lint-appends-check.svg)](https://github.com/voxpupuli/puppet-lint-appends-check/blob/master/LICENSE)
|
5
|
+
[![Test](https://github.com/voxpupuli/puppet-lint-appends-check/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/puppet-lint-appends-check/actions/workflows/test.yml)
|
6
|
+
[![Release](https://github.com/voxpupuli/puppet-lint-appends-check/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/puppet-lint-appends-check/actions/workflows/release.yml)
|
7
|
+
[![RubyGem Version](https://img.shields.io/gem/v/puppet-lint-appends-check.svg)](https://rubygems.org/gems/puppet-lint-appends-check)
|
8
|
+
[![RubyGem Downloads](https://img.shields.io/gem/dt/puppet-lint-appends-check.svg)](https://rubygems.org/gems/puppet-lint-appends-check)
|
9
|
+
[![Donated by Puppet Inc](https://img.shields.io/badge/donated%20by-Puppet%20Inc-fb7047.svg)](#transfer-notice)
|
10
|
+
A puppet-lint plugin to check that the append (+=) operator is unused.
|
9
11
|
|
10
12
|
## Installing
|
11
13
|
|
@@ -23,9 +25,9 @@ gem 'puppet-lint-appends-check', :require => false
|
|
23
25
|
|
24
26
|
## Checks
|
25
27
|
|
26
|
-
###
|
28
|
+
### Append operator use
|
27
29
|
|
28
|
-
|
30
|
+
Use of the append operator can lead to unexpected behavior.
|
29
31
|
|
30
32
|
#### What you have done
|
31
33
|
|
@@ -46,6 +48,11 @@ $ssh_users = ['myself', 'someone', 'someone_else']
|
|
46
48
|
$ssh_users = hiera('ssh_users')
|
47
49
|
```
|
48
50
|
|
51
|
+
#### Auto fixing
|
52
|
+
|
53
|
+
There is not one way to properly fix this type of style error, so
|
54
|
+
running puppet-lint's fix feature will not have any effect.
|
55
|
+
|
49
56
|
#### Disabling the check
|
50
57
|
|
51
58
|
To disable this check, you can add `--no-appends-check` to your puppet-lint command line.
|
@@ -59,4 +66,22 @@ Alternatively, if you’re calling puppet-lint via the Rake task, you should ins
|
|
59
66
|
```ruby
|
60
67
|
PuppetLint.configuration.send('disable_appends')
|
61
68
|
```
|
69
|
+
## Transfer Notice
|
70
|
+
|
71
|
+
This plugin was originally authored by [Puppet Inc](http://puppet.com).
|
72
|
+
The maintainer preferred that Puppet Community take ownership of the module for future improvement and maintenance.
|
73
|
+
Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of Puppet Inc.
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
This gem is licensed under the Apache-2 license.
|
78
|
+
|
79
|
+
## Release information
|
62
80
|
|
81
|
+
To make a new release, please do:
|
82
|
+
* update the version in the gemspec file
|
83
|
+
* Install gems with `bundle install --with release --path .vendor`
|
84
|
+
* generate the changelog with `bundle exec rake changelog`
|
85
|
+
* Check if the new version matches the closed issues/PRs in the changelog
|
86
|
+
* Create a PR with it
|
87
|
+
* After it got merged, push a tag. GitHub actions will do the actual release to rubygems and GitHub Packages
|
@@ -1,14 +1,14 @@
|
|
1
1
|
PuppetLint.new_check(:appends) do
|
2
2
|
def check
|
3
|
-
tokens.each_with_index do |token,
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
tokens.each_with_index do |token, _token_idx|
|
4
|
+
next unless token.type == :APPENDS
|
5
|
+
|
6
|
+
notify :warning, {
|
7
|
+
message: 'The appends (+=) operator was used.',
|
8
|
+
line: token.line,
|
9
|
+
column: token.column,
|
10
|
+
token: token,
|
11
|
+
}
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'appends' do
|
4
|
+
let(:msg) { 'The appends (+=) operator was used.' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'when the appends operator is not used' do
|
8
|
+
let(:code) do
|
9
|
+
<<-EOS
|
10
|
+
$foo = ['bar', 'baz']
|
11
|
+
$gary = 'is loud'
|
12
|
+
$people = {
|
13
|
+
'tim' => 'is beardy',
|
14
|
+
'nigel' => "isn't so much"
|
15
|
+
}
|
16
|
+
EOS
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'does not detect any problems' do
|
20
|
+
expect(problems).to have(0).problems
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when the appends operator is used' do
|
25
|
+
let(:code) do
|
26
|
+
<<-EOS
|
27
|
+
$foo += ['bar', 'baz']
|
28
|
+
$gary += 'is loud'
|
29
|
+
$people += {
|
30
|
+
'tim' => 'is beardy',
|
31
|
+
'nigel' => "isn't so much"
|
32
|
+
}
|
33
|
+
EOS
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'detects 3 problems' do
|
37
|
+
expect(problems).to have(3).problems
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'creates warnings' do
|
41
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(17)
|
42
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(17)
|
43
|
+
expect(problems).to contain_warning(msg).on_line(3).in_column(17)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'with fix enabled' do
|
49
|
+
before do
|
50
|
+
PuppetLint.configuration.fix = true
|
51
|
+
end
|
52
|
+
|
53
|
+
after do
|
54
|
+
PuppetLint.configuration.fix = false
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when the appends operator is not used' do
|
58
|
+
let(:code) do
|
59
|
+
<<-EOS
|
60
|
+
$foo = ['bar', 'baz']
|
61
|
+
$gary = 'is loud'
|
62
|
+
$people = {
|
63
|
+
'tim' => 'is beardy',
|
64
|
+
'nigel' => "isn't so much"
|
65
|
+
}
|
66
|
+
EOS
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'does not detect any problems' do
|
70
|
+
expect(problems).to have(0).problems
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'does not modify the manifest' do
|
74
|
+
expect(manifest).to eq(code)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when the appends operator is used' do
|
79
|
+
let(:code) do
|
80
|
+
<<-EOS
|
81
|
+
$foo += ['bar', 'baz']
|
82
|
+
$gary += 'is loud'
|
83
|
+
$people += {
|
84
|
+
'tim' => 'is beardy',
|
85
|
+
'nigel' => "isn't so much"
|
86
|
+
}
|
87
|
+
EOS
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'detects 3 problems' do
|
91
|
+
expect(problems).to have(3).problems
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'creates warnings' do
|
95
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(17)
|
96
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(17)
|
97
|
+
expect(problems).to contain_warning(msg).on_line(3).in_column(17)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'does not fix the ensure parameter because that is not implemented' do
|
101
|
+
expect(manifest).to eq(code)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
+
]
|
4
25
|
end
|
5
26
|
|
6
27
|
require 'puppet-lint'
|
metadata
CHANGED
@@ -1,126 +1,68 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-appends-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
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
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ~>
|
19
|
+
version: '3'
|
20
|
+
- - "<"
|
32
21
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
22
|
+
version: '5'
|
23
|
+
type: :runtime
|
35
24
|
prerelease: false
|
36
25
|
version_requirements: !ruby/object:Gem::Requirement
|
37
26
|
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec-its
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
27
|
+
- - ">="
|
46
28
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ~>
|
29
|
+
version: '3'
|
30
|
+
- - "<"
|
53
31
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec-collection_matchers
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.0'
|
32
|
+
version: '5'
|
69
33
|
- !ruby/object:Gem::Dependency
|
70
34
|
name: mime-types
|
71
35
|
requirement: !ruby/object:Gem::Requirement
|
72
36
|
requirements:
|
73
|
-
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ~>
|
37
|
+
- - "~>"
|
81
38
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
83
|
-
-
|
84
|
-
name: coveralls
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ~>
|
39
|
+
version: '3.4'
|
40
|
+
- - ">="
|
88
41
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
42
|
+
version: 3.4.1
|
90
43
|
type: :development
|
91
44
|
prerelease: false
|
92
45
|
version_requirements: !ruby/object:Gem::Requirement
|
93
46
|
requirements:
|
94
|
-
- - ~>
|
47
|
+
- - "~>"
|
95
48
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
97
|
-
-
|
98
|
-
name: rake
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - '>='
|
49
|
+
version: '3.4'
|
50
|
+
- - ">="
|
102
51
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
requirements:
|
108
|
-
- - '>='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
description: |2
|
112
|
-
A puppet-lint plugin to check that the appends operator (+=) is not used (removed in Puppet 4.0.0).
|
113
|
-
email: gary@puppetlabs.com
|
52
|
+
version: 3.4.1
|
53
|
+
description: " A puppet-lint plugin to check that the appends operator (+=) is
|
54
|
+
not used (removed in Puppet 4.0.0).\n"
|
55
|
+
email: voxpupuli@groups.io
|
114
56
|
executables: []
|
115
57
|
extensions: []
|
116
58
|
extra_rdoc_files: []
|
117
59
|
files:
|
118
|
-
- README.md
|
119
60
|
- LICENSE
|
61
|
+
- README.md
|
120
62
|
- lib/puppet-lint/plugins/check_appends.rb
|
121
|
-
- spec/puppet-lint/plugins/
|
63
|
+
- spec/puppet-lint/plugins/check_appends/appends_spec.rb
|
122
64
|
- spec/spec_helper.rb
|
123
|
-
homepage: https://github.com/
|
65
|
+
homepage: https://github.com/voxpupuli/puppet-lint-appends-check
|
124
66
|
licenses:
|
125
67
|
- Apache-2.0
|
126
68
|
metadata: {}
|
@@ -130,21 +72,18 @@ require_paths:
|
|
130
72
|
- lib
|
131
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
74
|
requirements:
|
133
|
-
- -
|
75
|
+
- - ">="
|
134
76
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
77
|
+
version: 2.7.0
|
136
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
79
|
requirements:
|
138
|
-
- -
|
80
|
+
- - ">="
|
139
81
|
- !ruby/object:Gem::Version
|
140
82
|
version: '0'
|
141
83
|
requirements: []
|
142
|
-
|
143
|
-
rubygems_version: 2.0.14
|
84
|
+
rubygems_version: 3.2.33
|
144
85
|
signing_key:
|
145
86
|
specification_version: 4
|
146
87
|
summary: A puppet-lint plugin to check that the appends operator (+=) is not used
|
147
88
|
(removed in Puppet 4.0.0).
|
148
|
-
test_files:
|
149
|
-
- spec/puppet-lint/plugins/check_absolute_classname/relative_classname_inclusion_spec.rb
|
150
|
-
- spec/spec_helper.rb
|
89
|
+
test_files: []
|
@@ -1,113 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'relative_classname_inclusion' do
|
4
|
-
let(:msg) { 'class included by relative name' }
|
5
|
-
|
6
|
-
context 'with fix disabled' do
|
7
|
-
context 'when absolute names are used' do
|
8
|
-
let(:code) do
|
9
|
-
<<-EOS
|
10
|
-
include ::foobar
|
11
|
-
include('::foobar')
|
12
|
-
include(foobar(baz))
|
13
|
-
include(foobar('baz'))
|
14
|
-
|
15
|
-
include ::foo, ::bar
|
16
|
-
include('::foo', '::bar')
|
17
|
-
|
18
|
-
class { '::foobar': }
|
19
|
-
|
20
|
-
class foobar {
|
21
|
-
}
|
22
|
-
EOS
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should not detect any problems' do
|
26
|
-
expect(problems).to have(0).problems
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'when relative names are used' do
|
31
|
-
let(:code) do
|
32
|
-
<<-EOS
|
33
|
-
include foobar
|
34
|
-
include(foobar)
|
35
|
-
class { 'foobar': }
|
36
|
-
EOS
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should detect 3 problems' do
|
40
|
-
expect(problems).to have(3).problems
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should create warnings' do
|
44
|
-
expect(problems).to contain_warning(msg).on_line(1).in_column(17)
|
45
|
-
expect(problems).to contain_warning(msg).on_line(2).in_column(17)
|
46
|
-
expect(problems).to contain_warning(msg).on_line(3).in_column(17)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'with fix enabled' do
|
52
|
-
before do
|
53
|
-
PuppetLint.configuration.fix = true
|
54
|
-
end
|
55
|
-
|
56
|
-
after do
|
57
|
-
PuppetLint.configuration.fix = false
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when absolute names are used' do
|
61
|
-
let(:code) do
|
62
|
-
<<-EOS
|
63
|
-
include ::foobar
|
64
|
-
include('::foobar')
|
65
|
-
include(foobar(baz))
|
66
|
-
include(foobar('baz'))
|
67
|
-
|
68
|
-
include ::foo, ::bar
|
69
|
-
include('::foo', '::bar')
|
70
|
-
|
71
|
-
class { '::foobar': }
|
72
|
-
|
73
|
-
class foobar {
|
74
|
-
}
|
75
|
-
EOS
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should not detect any problems' do
|
79
|
-
expect(problems).to have(0).problems
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'when relative names are used' do
|
84
|
-
let(:code) do
|
85
|
-
<<-EOS
|
86
|
-
include foobar
|
87
|
-
include(foobar)
|
88
|
-
class { 'foobar': }
|
89
|
-
EOS
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'should detect 3 problems' do
|
93
|
-
expect(problems).to have(3).problems
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'should fix the problems' do
|
97
|
-
expect(problems).to contain_fixed(msg).on_line(1).in_column(17)
|
98
|
-
expect(problems).to contain_fixed(msg).on_line(2).in_column(17)
|
99
|
-
expect(problems).to contain_fixed(msg).on_line(3).in_column(17)
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should should add colons' do
|
103
|
-
expect(manifest).to eq(
|
104
|
-
<<-EOS
|
105
|
-
include ::foobar
|
106
|
-
include(::foobar)
|
107
|
-
class { '::foobar': }
|
108
|
-
EOS
|
109
|
-
)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|