puppet-lint-empty_trailing_lines 0.0.1 → 1.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
2
  SHA256:
3
- metadata.gz: 63566c23dfbecc1869cfcc8c47df00154713d49c4509bfe2536a9b977223c8dd
4
- data.tar.gz: '090fd98728a66866c1afe3eac21c51d2a6979ed6f09f988bfbb0118ff63a310e'
3
+ metadata.gz: '086a73bc19cbeb146a546829950c64bc028fc3ab31831b5d0f3521a1a49ccd5a'
4
+ data.tar.gz: 35fb6fbfa646fc859d3b3aa1fcd7869bca8ed9f2f0f5655abc42b6353b4ce2ca
5
5
  SHA512:
6
- metadata.gz: 0db2caeca0703fcd6160493af14944981041c026290f0ecdade43b6ec1e31513cc9b9d2572a1296d18de3925b435a9c30f50385714893ad3856d05551bcbff32
7
- data.tar.gz: dcb7532bd161b635fc9ba8b838b1f0291bce76f320ac821a57d34bb14afc6c848ef319dd080f0b0d9bf491853e7bf6def760363c3ff2dfe32d3239b1a9648d4d
6
+ metadata.gz: 9278506115ddba69597b13ab44d7c9e7518824a56fccde745deec01f737f7f4af49db6b3c42b5d5eca0dc14cab37c8c2c1080eeb4d499a8dab42128383a5c27a
7
+ data.tar.gz: f21a9bbf8302de74146a9982721f01b919ace0b96c8e1b2aba098ea087a99452293a86d88a18c18d5d3e5d23a60ed48eac2c92ca4b287cb01730c6ba6d57fee7
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2019 Garrett Honeycutt <code@garretthoneycutt.com>
1
+ Copyright (C) 2019-2020 Garrett Honeycutt <code@garretthoneycutt.com>
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -37,7 +37,7 @@ This plugin provides a new check to `puppet-lint`.
37
37
  ### What you should have done
38
38
 
39
39
  ```puppet
40
- # Not left empty lines at the end of the file
40
+ # No empty lines left at the end of the file
41
41
  file { '/foo':
42
42
  ensure => 'file',
43
43
  }
@@ -46,6 +46,20 @@ This plugin provides a new check to `puppet-lint`.
46
46
 
47
47
  ### Disabling the check
48
48
 
49
+ #### Control comment
50
+
51
+ ```
52
+ # lint:ignore:empty_trailing_lines
53
+ ```
54
+
49
55
  #### From the command line
50
56
 
57
+ ```
58
+ --no-empty_trailing_lines-check
59
+ ```
60
+
51
61
  #### In your `Rakefile`
62
+
63
+ ```
64
+ PuppetLint.configuration.send("disable_empty_trailing_lines")
65
+ ```
@@ -1,20 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  PuppetLint.new_check(:empty_trailing_lines) do
2
4
  def check
3
5
  last_token = tokens.last
4
6
 
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
7
+ return unless %i[NEWLINE WHITESPACE INDENT].include?(last_token.prev_token.type)
8
+
9
+ notify :warning, {
10
+ message: 'too many empty lines at the end of the file',
11
+ line: last_token.prev_token.line,
12
+ column: manifest_lines.last.length
13
+ }
12
14
  end
13
15
 
14
16
  def fix(problem)
15
17
  remove_token(tokens.last.prev_token)
16
- if tokens.last.prev_token.type == :NEWLINE && tokens.last.type == :NEWLINE
17
- fix(problem)
18
- end
18
+ fix(problem) if tokens.last.prev_token.type == :NEWLINE && tokens.last.type == :NEWLINE
19
19
  end
20
20
  end
@@ -1,37 +1,39 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'empty_trailing_lines' do
4
6
  let(:msg) { 'too many empty lines at the end of the file' }
5
7
 
6
8
  context 'with fix disabled' do
7
- context 'code ending with an extra newline' do
9
+ context 'when code ending with an extra newline' do
8
10
  let(:code) { "foo\n\n\n'test'\n\n" }
9
11
 
10
- it 'should detect a single problem' do
12
+ it 'detects a single problem' do
11
13
  expect(problems).to have(1).problem
12
14
  end
13
15
 
14
- it 'should create a warning' do
16
+ it 'creates a warning' do
15
17
  expect(problems).to contain_warning(msg).on_line(4).in_column(0)
16
18
  end
17
19
  end
18
20
 
19
- context 'code ending with many extra newlines' do
21
+ context 'when code ending with many extra newlines' do
20
22
  let(:code) { "foo\n\n\n'test'\n\n\n\n" }
21
23
 
22
- it 'should detect a single problem' do
24
+ it 'detects a single problem' do
23
25
  expect(problems).to have(1).problem
24
26
  end
25
27
 
26
- it 'should create a warning' do
28
+ it 'creates a warning' do
27
29
  expect(problems).to contain_warning(msg).on_line(6).in_column(0)
28
30
  end
29
31
  end
30
32
 
31
- context 'code ending with a newline' do
33
+ context 'when code ending with a newline' do
32
34
  let(:code) { "foo\n\n\n'test'\n" }
33
35
 
34
- it 'should not detect any problems' do
36
+ it 'does not detect any problems' do
35
37
  expect(problems).to have(0).problems
36
38
  end
37
39
  end
@@ -46,46 +48,46 @@ describe 'empty_trailing_lines' do
46
48
  PuppetLint.configuration.fix = false
47
49
  end
48
50
 
49
- context 'code ending with an extra newline' do
51
+ context 'when code ending with an extra newline' do
50
52
  let(:code) { "foo\n\n\n'test'\n\n" }
51
53
 
52
- it 'should only detect a single problem' do
54
+ it 'onlies detect a single problem' do
53
55
  expect(problems).to have(1).problem
54
56
  end
55
57
 
56
- it 'should fix the problem' do
58
+ it 'fixes the problem' do
57
59
  expect(problems).to contain_fixed(msg).on_line(4).in_column(0)
58
60
  end
59
61
 
60
- it 'should add a newline to the end of the manifest' do
62
+ it 'adds a newline to the end of the manifest' do
61
63
  expect(manifest).to eq("foo\n\n\n'test'\n")
62
64
  end
63
65
  end
64
66
 
65
- context 'code ending with many extra newlines' do
67
+ context 'when code ending with many extra newlines' do
66
68
  let(:code) { "foo\n\n\n'test'\n\n\n\n" }
67
69
 
68
- it 'should only detect a single problem' do
70
+ it 'onlies detect a single problem' do
69
71
  expect(problems).to have(1).problem
70
72
  end
71
73
 
72
- it 'should fix the problem' do
74
+ it 'fixes the problem' do
73
75
  expect(problems).to contain_fixed(msg).on_line(6).in_column(0)
74
76
  end
75
77
 
76
- it 'should add a newline to the end of the manifest' do
78
+ it 'adds a newline to the end of the manifest' do
77
79
  expect(manifest).to eq("foo\n\n\n'test'\n")
78
80
  end
79
81
  end
80
82
 
81
- context 'code ending in a newline' do
83
+ context 'when code ending in a newline' do
82
84
  let(:code) { "foo\n\n\n'test'\n" }
83
85
 
84
- it 'should not detect any problems' do
86
+ it 'does not detect any problems' do
85
87
  expect(problems).to have(0).problems
86
88
  end
87
89
 
88
- it 'should not modify the manifest' do
90
+ it 'does not modify the manifest' do
89
91
  expect(manifest).to eq(code)
90
92
  end
91
93
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'puppet-lint'
2
4
 
3
5
  PuppetLint::Plugins.load_spec_helper
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-empty_trailing_lines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tailored Automation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-26 00:00:00.000000000 Z
11
+ date: 2023-06-12 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: '2.0'
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,7 +29,7 @@ dependencies:
29
29
  version: '2.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '3.0'
32
+ version: '5.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rake
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -93,12 +93,12 @@ dependencies:
93
93
  - !ruby/object:Gem::Version
94
94
  version: '1.0'
95
95
  - !ruby/object:Gem::Dependency
96
- name: rubocop-rspec
96
+ name: rubocop
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
- version: '1.0'
101
+ version: 1.22.3
102
102
  - - "<"
103
103
  - !ruby/object:Gem::Version
104
104
  version: '2.0'
@@ -108,10 +108,30 @@ dependencies:
108
108
  requirements:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: '1.0'
111
+ version: 1.22.3
112
112
  - - "<"
113
113
  - !ruby/object:Gem::Version
114
114
  version: '2.0'
115
+ - !ruby/object:Gem::Dependency
116
+ name: rubocop-rspec
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '2.0'
122
+ - - "<"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '2.0'
132
+ - - "<"
133
+ - !ruby/object:Gem::Version
134
+ version: '3.0'
115
135
  - !ruby/object:Gem::Dependency
116
136
  name: simplecov
117
137
  requirement: !ruby/object:Gem::Requirement
@@ -163,11 +183,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
183
  - !ruby/object:Gem::Version
164
184
  version: '0'
165
185
  requirements: []
166
- rubyforge_project:
167
- rubygems_version: 2.7.6.2
186
+ rubygems_version: 3.4.10
168
187
  signing_key:
169
188
  specification_version: 4
170
189
  summary: puppet-lint empty_trailing_line check
171
190
  test_files:
172
- - spec/spec_helper.rb
173
191
  - spec/puppet-lint/plugins/check_empty_trailing_lines_spec.rb
192
+ - spec/spec_helper.rb