puppet-lint-empty_trailing_lines 0.0.1
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 +7 -0
- data/LICENSE +13 -0
- data/README.md +51 -0
- data/lib/puppet-lint/plugins/check_empty_trailing_lines.rb +20 -0
- data/spec/puppet-lint/plugins/check_empty_trailing_lines_spec.rb +93 -0
- data/spec/spec_helper.rb +3 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 63566c23dfbecc1869cfcc8c47df00154713d49c4509bfe2536a9b977223c8dd
|
4
|
+
data.tar.gz: '090fd98728a66866c1afe3eac21c51d2a6979ed6f09f988bfbb0118ff63a310e'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0db2caeca0703fcd6160493af14944981041c026290f0ecdade43b6ec1e31513cc9b9d2572a1296d18de3925b435a9c30f50385714893ad3856d05551bcbff32
|
7
|
+
data.tar.gz: dcb7532bd161b635fc9ba8b838b1f0291bce76f320ac821a57d34bb14afc6c848ef319dd080f0b0d9bf491853e7bf6def760363c3ff2dfe32d3239b1a9648d4d
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (C) 2019 Garrett Honeycutt <code@garretthoneycutt.com>
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# puppet-lint-empty_trailing_lines
|
2
|
+
|
3
|
+
This plugin will check to see if a manifest has trailing empty lines.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
|
9
|
+
### From the command line
|
10
|
+
|
11
|
+
```sh
|
12
|
+
gem install puppet-lint-empty_trailing_lines
|
13
|
+
```
|
14
|
+
|
15
|
+
### In a `Gemfile`
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'puppet-lint-empty_trailing_lines', :require => false
|
19
|
+
```
|
20
|
+
|
21
|
+
## Checks
|
22
|
+
|
23
|
+
This plugin provides a new check to `puppet-lint`.
|
24
|
+
|
25
|
+
### What you have done
|
26
|
+
|
27
|
+
```puppet
|
28
|
+
# There are two empty lines after the code has ended
|
29
|
+
file { '/foo':
|
30
|
+
ensure => 'file',
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
### What you should have done
|
38
|
+
|
39
|
+
```puppet
|
40
|
+
# Not left empty lines at the end of the file
|
41
|
+
file { '/foo':
|
42
|
+
ensure => 'file',
|
43
|
+
}
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
### Disabling the check
|
48
|
+
|
49
|
+
#### From the command line
|
50
|
+
|
51
|
+
#### In your `Rakefile`
|
@@ -0,0 +1,20 @@
|
|
1
|
+
PuppetLint.new_check(:empty_trailing_lines) do
|
2
|
+
def check
|
3
|
+
last_token = tokens.last
|
4
|
+
|
5
|
+
if [:NEWLINE, :WHITESPACE, :INDENT].include?(last_token.prev_token.type)
|
6
|
+
notify :warning, {
|
7
|
+
:message => 'too many empty lines at the end of the file',
|
8
|
+
:line => last_token.prev_token.line,
|
9
|
+
:column => manifest_lines.last.length,
|
10
|
+
}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def fix(problem)
|
15
|
+
remove_token(tokens.last.prev_token)
|
16
|
+
if tokens.last.prev_token.type == :NEWLINE && tokens.last.type == :NEWLINE
|
17
|
+
fix(problem)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'empty_trailing_lines' do
|
4
|
+
let(:msg) { 'too many empty lines at the end of the file' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'code ending with an extra newline' do
|
8
|
+
let(:code) { "foo\n\n\n'test'\n\n" }
|
9
|
+
|
10
|
+
it 'should detect a single problem' do
|
11
|
+
expect(problems).to have(1).problem
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should create a warning' do
|
15
|
+
expect(problems).to contain_warning(msg).on_line(4).in_column(0)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'code ending with many extra newlines' do
|
20
|
+
let(:code) { "foo\n\n\n'test'\n\n\n\n" }
|
21
|
+
|
22
|
+
it 'should detect a single problem' do
|
23
|
+
expect(problems).to have(1).problem
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should create a warning' do
|
27
|
+
expect(problems).to contain_warning(msg).on_line(6).in_column(0)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'code ending with a newline' do
|
32
|
+
let(:code) { "foo\n\n\n'test'\n" }
|
33
|
+
|
34
|
+
it 'should not detect any problems' do
|
35
|
+
expect(problems).to have(0).problems
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with fix enabled' do
|
41
|
+
before do
|
42
|
+
PuppetLint.configuration.fix = true
|
43
|
+
end
|
44
|
+
|
45
|
+
after do
|
46
|
+
PuppetLint.configuration.fix = false
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'code ending with an extra newline' do
|
50
|
+
let(:code) { "foo\n\n\n'test'\n\n" }
|
51
|
+
|
52
|
+
it 'should only detect a single problem' do
|
53
|
+
expect(problems).to have(1).problem
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should fix the problem' do
|
57
|
+
expect(problems).to contain_fixed(msg).on_line(4).in_column(0)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should add a newline to the end of the manifest' do
|
61
|
+
expect(manifest).to eq("foo\n\n\n'test'\n")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'code ending with many extra newlines' do
|
66
|
+
let(:code) { "foo\n\n\n'test'\n\n\n\n" }
|
67
|
+
|
68
|
+
it 'should only detect a single problem' do
|
69
|
+
expect(problems).to have(1).problem
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should fix the problem' do
|
73
|
+
expect(problems).to contain_fixed(msg).on_line(6).in_column(0)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should add a newline to the end of the manifest' do
|
77
|
+
expect(manifest).to eq("foo\n\n\n'test'\n")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'code ending in a newline' do
|
82
|
+
let(:code) { "foo\n\n\n'test'\n" }
|
83
|
+
|
84
|
+
it 'should not detect any problems' do
|
85
|
+
expect(problems).to have(0).problems
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should not modify the manifest' do
|
89
|
+
expect(manifest).to eq(code)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppet-lint-empty_trailing_lines
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tailored Automation
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: puppet-lint
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.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'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '14.0'
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '13.0'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '14.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '3.0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '3.0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rspec-collection_matchers
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1.0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '1.0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec-its
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '1.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rubocop-rspec
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.0'
|
102
|
+
- - "<"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '2.0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.0'
|
112
|
+
- - "<"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '2.0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: simplecov
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 0.17.1
|
122
|
+
- - "<"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.0'
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.17.1
|
132
|
+
- - "<"
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '2.0'
|
135
|
+
description: " Extends puppet-lint to ensure that your manifest files do not end
|
136
|
+
with extra empty lines\n"
|
137
|
+
email: code@tailoredautomation.io
|
138
|
+
executables: []
|
139
|
+
extensions: []
|
140
|
+
extra_rdoc_files: []
|
141
|
+
files:
|
142
|
+
- LICENSE
|
143
|
+
- README.md
|
144
|
+
- lib/puppet-lint/plugins/check_empty_trailing_lines.rb
|
145
|
+
- spec/puppet-lint/plugins/check_empty_trailing_lines_spec.rb
|
146
|
+
- spec/spec_helper.rb
|
147
|
+
homepage: https://github.com/ghoneycutt/puppet-lint-empty_trailing_lines
|
148
|
+
licenses:
|
149
|
+
- Apache-2.0
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.7.6.2
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: puppet-lint empty_trailing_line check
|
171
|
+
test_files:
|
172
|
+
- spec/spec_helper.rb
|
173
|
+
- spec/puppet-lint/plugins/check_empty_trailing_lines_spec.rb
|