puppet-lint-manifest_whitespace-check 0.3.0 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7a82b75562b3f216e849bb8b6600982ccfd262bb0eb7fe97a1669510187c061
4
- data.tar.gz: 1b00868a696b0dfeee05148f58d413244c579e50d35fcb47f05f3d68b5c18117
3
+ metadata.gz: 2ee41490e67bfffdcb28a118bb2ce3ebb79598e89e7fd16daf62aab500a461ac
4
+ data.tar.gz: 40effd33779386f983527c59fa521b09ccaa2b1e892ad17ee7a21b8095309131
5
5
  SHA512:
6
- metadata.gz: b2c308c27fb7b90390fddd309c125cd72036af8d24ae43ae871a8de1f0d97bfc9126099c0a30fdf052bc8fedb6da4c5800dbd6ca35d418d59e826578d7a540d6
7
- data.tar.gz: 7fda90bd22b2c51a73f6782874ba8ff2009532a54a233424537a6a5fe2cc234edc4e05ffc9038148ed225d3e0232f47ee69793bdad4ce5a3216ee755d30213c4
6
+ metadata.gz: 31de55ce099794ff4889e1bc36041dbdb23aefee3e3fee4e9dba36289a8d43053af0c86f5ab58166938b3ef4813c6e8d5200d9aeec26a321db87be24892f270f
7
+ data.tar.gz: cba7086044df90adc55c679b8fc6c7ec3441fa4af9549e4613b0eb2a9ff2fae74e4f5c709497762aec79caee06bba58d1fd0a89982e085ee976b81f74f11196d
data/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # puppet-lint manifest whitespace check
2
2
 
3
+ [![License](https://img.shields.io/github/license/voxpupuli/puppet-lint-manifest_whitespace-check.svg)](https://github.com/voxpupuli/puppet-lint-manifest_whitespace-check/blob/master/LICENSE)
4
+ [![Test](https://github.com/voxpupuli/puppet-lint-manifest_whitespace-check/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/puppet-lint-manifest_whitespace-check/actions/workflows/test.yml)
5
+ [![Release](https://github.com/voxpupuli/puppet-lint-manifest_whitespace-check/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/puppet-lint-manifest_whitespace-check/actions/workflows/release.yml)
6
+ [![RubyGem Version](https://img.shields.io/gem/v/puppet-lint-manifest_whitespace-check.svg)](https://rubygems.org/gems/puppet-lint-manifest_whitespace-check)
7
+ [![RubyGem Downloads](https://img.shields.io/gem/dt/puppet-lint-manifest_whitespace-check.svg)](https://rubygems.org/gems/puppet-lint-manifest_whitespace-check)
8
+ [![Donated by Jo Vandeginste](https://img.shields.io/badge/donated%20by-Jo%20Vandeginste-fb7047.svg)](#copyright)
9
+
3
10
  Adds a new puppet-lint check to verify a number of whitespace issues (newlines etc.)
4
11
 
5
12
  These checks are very opinionated.
@@ -173,3 +180,22 @@ class myclass
173
180
  # the body
174
181
  }
175
182
  ```
183
+
184
+ ## License
185
+
186
+ This project is licensed unter MIT
187
+
188
+ ## Transfer Notice
189
+
190
+ This plugin was originally maintained by [Jo Vandeginste](https://github.com/jovandeginste).
191
+ The maintainer preferred that [Vox Pupuli](https://voxpupuli.org/) take ownership of the module for future improvement and maintenance.
192
+
193
+ ## Release information
194
+
195
+ To make a new release, please do:
196
+ * update the version in the gemspec file
197
+ * Install gems with `bundle install --with release --path .vendor`
198
+ * generate the changelog with `bundle exec rake changelog`
199
+ * Check if the new version matches the closed issues/PRs in the changelog
200
+ * Create a PR with it
201
+ * After it got merged, push a tag. GitHub actions will do the actual release to rubygems and GitHub Packages
@@ -9,7 +9,9 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_before) do
9
9
  next unless prev_token && prev_code_token
10
10
  next if %i[LBRACE].include?(prev_token.type)
11
11
 
12
- next if !%i[LBRACE].include?(prev_code_token.type) && (is_single_space(prev_token) && tokens.index(prev_code_token) == tokens.index(brace_token) - 2)
12
+ if !%i[LBRACE].include?(prev_code_token.type) && (is_single_space(prev_token) && tokens.index(prev_code_token) == tokens.index(brace_token) - 2)
13
+ next
14
+ end
13
15
 
14
16
  next if prev_token.type == :INDENT && (tokens.index(prev_code_token) == tokens.index(brace_token) - 3)
15
17
 
@@ -39,7 +41,8 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_before) do
39
41
  next_token = next_token.next_token
40
42
  end
41
43
 
42
- add_token(tokens.index(next_token), new_single_space) if next_token.type == :RBRACE && !%i[LBRACE NEWLINE INDENT].include?(next_token.prev_token.type)
44
+ add_token(tokens.index(next_token), new_single_space) if next_token.type == :RBRACE && !%i[LBRACE NEWLINE
45
+ INDENT].include?(next_token.prev_token.type)
43
46
  end
44
47
  end
45
48
 
@@ -4,15 +4,15 @@ PuppetLint.new_check(:manifest_whitespace_missing_newline_end_of_file) do
4
4
  def check
5
5
  last_token = tokens.last
6
6
 
7
- if last_token && last_token.type != :NEWLINE
8
- notify(
9
- :error,
10
- message: 'there should be a single newline at the end of a manifest',
11
- line: last_token.line,
12
- column: last_token.column,
13
- token: last_token,
14
- )
15
- end
7
+ return unless last_token && last_token.type != :NEWLINE
8
+
9
+ notify(
10
+ :error,
11
+ message: 'there should be a single newline at the end of a manifest',
12
+ line: last_token.line,
13
+ column: last_token.column,
14
+ token: last_token,
15
+ )
16
16
  end
17
17
 
18
18
  def fix(problem)
@@ -25,18 +25,18 @@ PuppetLint.new_check(:manifest_whitespace_double_newline_end_of_file) do
25
25
  def check
26
26
  last_token = tokens.last
27
27
 
28
- if last_token && last_token.type == :NEWLINE
29
- while last_token.prev_token && last_token.prev_token.type == :NEWLINE
30
- notify(
31
- :error,
32
- message: 'there should be a single newline at the end of a manifest',
33
- line: last_token.line,
34
- column: last_token.column,
35
- token: last_token,
36
- )
37
-
38
- last_token = last_token.prev_token
39
- end
28
+ return unless last_token && last_token.type == :NEWLINE
29
+
30
+ while last_token.prev_token && last_token.prev_token.type == :NEWLINE
31
+ notify(
32
+ :error,
33
+ message: 'there should be a single newline at the end of a manifest',
34
+ line: last_token.line,
35
+ column: last_token.column,
36
+ token: last_token,
37
+ )
38
+
39
+ last_token = last_token.prev_token
40
40
  end
41
41
  end
42
42
 
@@ -11,9 +11,12 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_before) do
11
11
  next if %i[COMMA].include?(prev_code_token.type) && %i[INDENT NEWLINE].include?(prev_token.type)
12
12
  next if %i[COMMENT COLON].include?(prev_code_token.type)
13
13
 
14
- if %i[LPAREN LBRACK LBRACE].include?(prev_code_token.type)
14
+ if %i[LPAREN LBRACK].include?(prev_code_token.type)
15
15
  next if tokens.index(prev_code_token) == tokens.index(brace_token) - 1
16
16
  next if tokens[tokens.index(prev_code_token)..tokens.index(brace_token)].collect(&:type).include?(:NEWLINE)
17
+ elsif %i[LBRACE].include?(prev_code_token.type)
18
+ next if tokens[tokens.index(prev_code_token)..tokens.index(brace_token)].collect(&:type).include?(:NEWLINE)
19
+ next if tokens.index(prev_code_token) == tokens.index(brace_token) - 2 && is_single_space(prev_token)
17
20
  else
18
21
  next unless tokens.index(prev_code_token) != tokens.index(brace_token) - 2 ||
19
22
  !is_single_space(prev_token)
@@ -41,7 +44,7 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_before) do
41
44
  prev_token = prev_token.prev_token
42
45
  end
43
46
 
44
- add_token(tokens.index(token), new_single_space) unless %i[LPAREN LBRACK LBRACE].include?(prev_code_token.type)
47
+ add_token(tokens.index(token), new_single_space) unless %i[LPAREN LBRACK].include?(prev_code_token.type)
45
48
  end
46
49
  end
47
50
 
@@ -45,6 +45,78 @@ describe 'manifest_whitespace_opening_brace_before' do
45
45
  end
46
46
  end
47
47
 
48
+ context 'with a Hash-returning block' do
49
+ let(:code) do
50
+ <<~CODE
51
+ $result = $value.lest || { {} }
52
+ CODE
53
+ end
54
+
55
+ it 'detects no problems' do
56
+ expect(problems).to be_empty
57
+ end
58
+ end
59
+
60
+ context 'with a Hash-nested Hash' do
61
+ let(:code) do
62
+ <<~CODE
63
+ $result = { foo => {} }
64
+ CODE
65
+ end
66
+
67
+ it 'detects no problems' do
68
+ expect(problems).to be_empty
69
+ end
70
+ end
71
+
72
+ context 'with a Hash-nested Hash with a Hash key' do
73
+ let(:code) do
74
+ <<~CODE
75
+ $result = { { 'a' => 1 } => {} }
76
+ CODE
77
+ end
78
+
79
+ it 'detects no problems' do
80
+ expect(problems).to be_empty
81
+ end
82
+ end
83
+
84
+ context 'with a Hash-nested Hash with an empty Hash key' do
85
+ let(:code) do
86
+ <<~CODE
87
+ $result = { {} => {} }
88
+ CODE
89
+ end
90
+
91
+ it 'detects no problems' do
92
+ expect(problems).to be_empty
93
+ end
94
+ end
95
+
96
+ context 'with a Hash-returning block and no space' do
97
+ let(:code) do
98
+ <<~CODE
99
+ $result = $value.lest || {{} }
100
+ CODE
101
+ end
102
+
103
+ it 'detects one problems' do
104
+ expect(problems).to have(1).problem
105
+ end
106
+
107
+ context 'with fix enabled' do
108
+ before do
109
+ PuppetLint.configuration.fix = true
110
+ end
111
+
112
+ after do
113
+ PuppetLint.configuration.fix = false
114
+ end
115
+
116
+ it { expect(manifest).to eq("$result = $value.lest || { {} }\n") }
117
+ end
118
+ end
119
+
48
120
  context 'inside, inline with function' do
49
121
  let(:code) do
50
122
  <<~CODE
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'coveralls'
4
- Coveralls.wear!
5
-
6
3
  require 'puppet-lint'
4
+ require 'rspec/collection_matchers'
7
5
 
8
6
  PuppetLint::Plugins.load_spec_helper
metadata CHANGED
@@ -1,122 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-manifest_whitespace-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jo Vandeginste
8
- autorequire:
8
+ - Vox Pupuli
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-22 00:00:00.000000000 Z
11
+ date: 1980-01-02 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
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '5'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '1.0'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '5'
33
- - !ruby/object:Gem::Dependency
34
- name: coveralls
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- - !ruby/object:Gem::Dependency
48
- name: mime-types
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- - !ruby/object:Gem::Dependency
62
- name: rake
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- - !ruby/object:Gem::Dependency
76
- name: rspec
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '3.0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '3.0'
89
- - !ruby/object:Gem::Dependency
90
- name: rspec-collection_matchers
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '1.0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
16
  requirements:
100
17
  - - "~>"
101
18
  - !ruby/object:Gem::Version
102
- version: '1.0'
103
- - !ruby/object:Gem::Dependency
104
- name: rspec-its
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '1.0'
110
- type: :development
19
+ version: '5.1'
20
+ type: :runtime
111
21
  prerelease: false
112
22
  version_requirements: !ruby/object:Gem::Requirement
113
23
  requirements:
114
24
  - - "~>"
115
25
  - !ruby/object:Gem::Version
116
- version: '1.0'
26
+ version: '5.1'
117
27
  description: A new check for puppet-lint that validates generic whitespace issues
118
28
  in manifests.
119
- email: jo.vandeginste@kuleuven.be
29
+ email: voxpupuli@groups.io
120
30
  executables: []
121
31
  extensions: []
122
32
  extra_rdoc_files: []
@@ -146,12 +56,10 @@ files:
146
56
  - spec/puppet-lint/plugins/manifest_whitespace_opening_brace_spec.rb
147
57
  - spec/puppet-lint/plugins/manifest_whitespace_opening_bracket_spec.rb
148
58
  - spec/spec_helper.rb
149
- homepage: https://github.com/kuleuven/puppet-lint-manifest_whitespace-check
59
+ homepage: https://github.com/voxpupuli/puppet-lint-manifest_whitespace-check
150
60
  licenses:
151
61
  - MIT
152
- metadata:
153
- rubygems_mfa_required: 'true'
154
- post_install_message:
62
+ metadata: {}
155
63
  rdoc_options: []
156
64
  require_paths:
157
65
  - lib
@@ -159,15 +67,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
67
  requirements:
160
68
  - - ">="
161
69
  - !ruby/object:Gem::Version
162
- version: '2.4'
70
+ version: '3.2'
163
71
  required_rubygems_version: !ruby/object:Gem::Requirement
164
72
  requirements:
165
73
  - - ">="
166
74
  - !ruby/object:Gem::Version
167
75
  version: '0'
168
76
  requirements: []
169
- rubygems_version: 3.4.8
170
- signing_key:
77
+ rubygems_version: 3.6.9
171
78
  specification_version: 4
172
79
  summary: A puppet-lint check to validate whitespace in manifests
173
80
  test_files: []