puppet-lint-manifest_whitespace-check 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'manifest_whitespace_double_newline_end_of_file' do
6
+ context 'with good example' do
7
+ let(:code) do
8
+ <<~EOF
9
+ class example (
10
+
11
+
12
+
13
+ ) {
14
+
15
+
16
+ }
17
+ EOF
18
+ end
19
+
20
+ it 'should not detect any problems' do
21
+ expect(problems).to have(0).problems
22
+ end
23
+ end
24
+
25
+ let(:single_newline_end_of_file_msg) { 'there should be a single newline at the end of a manifest' }
26
+
27
+ context 'with fix disabled' do
28
+ context 'with 1 empty line at the end of a manifest' do
29
+ let(:code) do
30
+ <<~EOF
31
+ class example {
32
+ }
33
+
34
+ EOF
35
+ end
36
+
37
+ it 'should detect a single problem' do
38
+ expect(problems).to have(1).problem
39
+ end
40
+
41
+ it 'should create a error' do
42
+ expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(3).in_column(1)
43
+ end
44
+ end
45
+
46
+ context 'with 3 empty lines at the end of a manifest' do
47
+ let(:code) do
48
+ <<~EOF
49
+ class example {
50
+ }
51
+
52
+
53
+
54
+ EOF
55
+ end
56
+
57
+ it 'should detect 3 problems' do
58
+ expect(problems).to have(3).problem
59
+ end
60
+
61
+ it 'should create a error' do
62
+ expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(3).in_column(1)
63
+ expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(4).in_column(1)
64
+ expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(5).in_column(1)
65
+ end
66
+ end
67
+ end
68
+
69
+ context 'with fix enabled' do
70
+ before do
71
+ PuppetLint.configuration.fix = true
72
+ end
73
+
74
+ after do
75
+ PuppetLint.configuration.fix = false
76
+ end
77
+
78
+ context 'with 1 empty line at the end of a manifest' do
79
+ let(:code) do
80
+ <<~EOF
81
+ class example {
82
+ }
83
+
84
+ EOF
85
+ end
86
+
87
+ it 'should detect a single problem' do
88
+ expect(problems).to have(1).problem
89
+ end
90
+
91
+ it 'should fix the manifest' do
92
+ expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(3).in_column(1)
93
+ end
94
+
95
+ it 'should add the final newline' do
96
+ expect(manifest).to eq(
97
+ <<~EOF
98
+ class example {
99
+ }
100
+ EOF
101
+ )
102
+ end
103
+ end
104
+
105
+ context 'with 3 empty lines at the end of a manifest' do
106
+ let(:code) do
107
+ <<~EOF
108
+ class example {
109
+ }
110
+
111
+
112
+
113
+ EOF
114
+ end
115
+
116
+ it 'should detect 3 problems' do
117
+ expect(problems).to have(3).problem
118
+ end
119
+
120
+ it 'should fix the manifest' do
121
+ expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(3).in_column(1)
122
+ expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(4).in_column(1)
123
+ expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(5).in_column(1)
124
+ end
125
+
126
+ it 'should add the final newline' do
127
+ expect(manifest).to eq(
128
+ <<~EOF
129
+ class example {
130
+ }
131
+ EOF
132
+ )
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'manifest_whitespace_missing_newline_end_of_file' do
6
+ let(:single_newline_end_of_file_msg) { 'there should be a single newline at the end of a manifest' }
7
+
8
+ context 'with fix disabled' do
9
+ context 'with no new line at the end of a manifest' do
10
+ let(:code) do
11
+ 'class example { }'
12
+ end
13
+
14
+ it 'should detect a single problem' do
15
+ expect(problems).to have(1).problem
16
+ end
17
+
18
+ it 'should create a error' do
19
+ expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(1).in_column(17)
20
+ end
21
+ end
22
+ end
23
+
24
+ context 'with fix enabled' do
25
+ before do
26
+ PuppetLint.configuration.fix = true
27
+ end
28
+
29
+ after do
30
+ PuppetLint.configuration.fix = false
31
+ end
32
+
33
+ context 'with no new line at the end of a manifest' do
34
+ let(:code) do
35
+ 'class example { }'
36
+ end
37
+
38
+ it 'should detect a single problem' do
39
+ expect(problems).to have(1).problem
40
+ end
41
+
42
+ it 'should fix the manifest' do
43
+ expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(1).in_column(17)
44
+ end
45
+
46
+ it 'should add the final newline' do
47
+ expect(manifest).to eq("class example { }\n")
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'manifest_whitespace_newline_beginning_of_file' do
6
+ let(:single_beginning_of_file_msg) { 'there should not be a newline at the beginning of a manifest' }
7
+
8
+ context 'with good example' do
9
+ let(:code) do
10
+ <<~EOF
11
+ class example (
12
+
13
+
14
+
15
+ ) {
16
+
17
+
18
+ }
19
+ EOF
20
+ end
21
+
22
+ it 'should not detect any problems' do
23
+ expect(problems).to have(0).problems
24
+ end
25
+ end
26
+
27
+ context 'with fix disabled' do
28
+ context 'with 1 empty line at the beginning of a manifest' do
29
+ let(:code) do
30
+ <<~EOF
31
+
32
+ class example {
33
+ }
34
+ EOF
35
+ end
36
+
37
+ it 'should detect a single problem' do
38
+ expect(problems).to have(1).problem
39
+ end
40
+
41
+ it 'should create a error' do
42
+ expect(problems).to contain_error(single_beginning_of_file_msg).on_line(1).in_column(1)
43
+ end
44
+ end
45
+
46
+ context 'with 3 empty lines at the beginning of a manifest' do
47
+ let(:code) do
48
+ <<~EOF
49
+
50
+
51
+
52
+ class example {
53
+ }
54
+ EOF
55
+ end
56
+
57
+ it 'should detect 3 problems' do
58
+ expect(problems).to have(3).problem
59
+ end
60
+
61
+ it 'should create a error' do
62
+ expect(problems).to contain_error(single_beginning_of_file_msg).on_line(1).in_column(1)
63
+ expect(problems).to contain_error(single_beginning_of_file_msg).on_line(2).in_column(1)
64
+ expect(problems).to contain_error(single_beginning_of_file_msg).on_line(3).in_column(1)
65
+ end
66
+ end
67
+ end
68
+
69
+ context 'with fix enabled' do
70
+ before do
71
+ PuppetLint.configuration.fix = true
72
+ end
73
+
74
+ after do
75
+ PuppetLint.configuration.fix = false
76
+ end
77
+
78
+ context 'with 1 empty line at the beginning of a manifest' do
79
+ let(:code) do
80
+ <<~EOF
81
+
82
+ class example {
83
+ }
84
+ EOF
85
+ end
86
+
87
+ it 'should detect a single problem' do
88
+ expect(problems).to have(1).problem
89
+ end
90
+
91
+ it 'should fix the manifest' do
92
+ expect(problems).to contain_fixed(single_beginning_of_file_msg).on_line(1).in_column(1)
93
+ end
94
+
95
+ it 'should add the final newline' do
96
+ expect(manifest).to eq(
97
+ <<~EOF,
98
+ class example {
99
+ }
100
+ EOF
101
+ )
102
+ end
103
+ end
104
+
105
+ context 'with 3 empty lines at the beginning of a manifest' do
106
+ let(:code) do
107
+ <<~EOF
108
+
109
+
110
+
111
+ class example {
112
+ }
113
+ EOF
114
+ end
115
+
116
+ it 'should detect 3 problem' do
117
+ expect(problems).to have(3).problem
118
+ end
119
+
120
+ it 'should fix the manifest' do
121
+ expect(problems).to contain_fixed(single_beginning_of_file_msg).on_line(1).in_column(1)
122
+ expect(problems).to contain_fixed(single_beginning_of_file_msg).on_line(2).in_column(1)
123
+ expect(problems).to contain_fixed(single_beginning_of_file_msg).on_line(3).in_column(1)
124
+ end
125
+
126
+ it 'should add the final newline' do
127
+ expect(manifest).to eq(
128
+ <<~EOF,
129
+ class example {
130
+ }
131
+ EOF
132
+ )
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,6 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require 'puppet-lint'
5
+
6
+ PuppetLint::Plugins.load_spec_helper
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-lint-manifest_whitespace-check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jo Vandeginste
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-19 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: '1.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: '1.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
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: mime-types
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: coveralls
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'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rake
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ description: " A new check for puppet-lint that validates generic whitespace issues
118
+ in manifests.\n"
119
+ email: jo.vandeginste@kuleuven.be
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - LICENSE
125
+ - README.md
126
+ - lib/puppet-lint/plugins/check_manifest_whitespace_arrow_spaces.rb
127
+ - lib/puppet-lint/plugins/check_manifest_whitespace_class_name_single_space.rb
128
+ - lib/puppet-lint/plugins/check_manifest_whitespace_class_opening_curly_brace.rb
129
+ - lib/puppet-lint/plugins/check_manifest_whitespace_newline_beginning_of_file.rb
130
+ - lib/puppet-lint/plugins/check_manifest_whitespace_newline_end_of_file.rb
131
+ - lib/puppet-lint/plugins/tools.rb
132
+ - spec/puppet-lint/plugins/manifest_whitespace_arrow_spaces_spec.rb
133
+ - spec/puppet-lint/plugins/manifest_whitespace_class_header_spec.rb
134
+ - spec/puppet-lint/plugins/manifest_whitespace_double_newline_end_of_file_spec.rb
135
+ - spec/puppet-lint/plugins/manifest_whitespace_missing_newline_end_of_file_spec.rb
136
+ - spec/puppet-lint/plugins/manifest_whitespace_newline_begin_of_file_spec.rb
137
+ - spec/spec_helper.rb
138
+ homepage: https://github.com/kuleuven/puppet-lint-manifest_whitespace-check
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '2.0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.6.14
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: A puppet-lint check to validate whitespace in manifests
162
+ test_files:
163
+ - spec/puppet-lint/plugins/manifest_whitespace_class_header_spec.rb
164
+ - spec/puppet-lint/plugins/manifest_whitespace_double_newline_end_of_file_spec.rb
165
+ - spec/puppet-lint/plugins/manifest_whitespace_missing_newline_end_of_file_spec.rb
166
+ - spec/puppet-lint/plugins/manifest_whitespace_arrow_spaces_spec.rb
167
+ - spec/puppet-lint/plugins/manifest_whitespace_newline_begin_of_file_spec.rb
168
+ - spec/spec_helper.rb