puppet-lint-improved_arrow_alignment 0.0.1 → 0.0.2

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: c99848491e74f1bd13f483d306162aa7471ded63e223e40f0d4829685f9c2510
4
- data.tar.gz: eb43057ff3f2b48773860d15618d2708f55e41fb8296d3ee14d30e4839f9aac9
3
+ metadata.gz: 85c367296dc00fb0a6246f5e1196a866e7b6b12a7c141d51063dc09ea40ef4dd
4
+ data.tar.gz: 2fc71152a36b0220ced03b6a3679d7c81986ab85a5707fb0bd9d2df0e3b30d1c
5
5
  SHA512:
6
- metadata.gz: cce4814a5d75d9a529b0c72240913296a71d7651e693b5492a4c83feec12c81823b10640e9ea7ed0a16ba1e782360b494fa765b456d0745a8b567e160384dba0
7
- data.tar.gz: 043d6d59ef125e0c7e67fa0b1c13eb5ea2646672f6b99ebbe98d22f2bbd1e574e74d24b2315ce5c3d080d73b1362616baba1c0270f58c06f870d73b4ed876685
6
+ metadata.gz: 7c024abbe21847ba053a1a62e8146564b19e62a375c0ebe0b17c40c02775e42fee1e873320f0b00d21e8e569f6fab77bcd745e674f73f2f5cd1a1ecf9b79ef99
7
+ data.tar.gz: 91584c8ae1b8151a77c884367c9f420534dd42a903d6b5743d5ee529abfe54551ae0e15b2078e6a343c96e08615b5a11fe987277cde884c6a7af378209cffb5a
@@ -1,6 +1,6 @@
1
1
  PuppetLint.new_check(:improved_arrow_alignment) do
2
2
  def check
3
- class_indexes.each do |res_idx|
3
+ (class_indexes + defined_type_indexes).each do |res_idx|
4
4
  arrow_column = [0]
5
5
  level_idx = 0
6
6
  level_tokens = []
@@ -18,6 +18,13 @@ PuppetLint.new_check(:improved_arrow_alignment) do
18
18
  next if resource_tokens[first_arrow].line == resource_tokens[last_arrow].line
19
19
 
20
20
  resource_tokens.each do |token|
21
+ # don't step on arrow_alignment check from puppet-lint
22
+ in_resource = false
23
+ resource_indexes.each do |res|
24
+ in_resource = res[:tokens].include?(token)
25
+ end
26
+ next if in_resource
27
+
21
28
  if token.type == :FARROW
22
29
  param_token = token.prev_code_token
23
30
 
@@ -18,6 +18,41 @@ describe 'improved_arrow_alignment' do
18
18
  end
19
19
  end
20
20
 
21
+ context 'defined type with correctly alligned' do
22
+ let(:code) do
23
+ <<-EOS
24
+ define imatest::type {
25
+ File {
26
+ ensure => present,
27
+ mode => '0755'
28
+ }
29
+ }
30
+ EOS
31
+ end
32
+
33
+ it 'should not detect any problems' do
34
+ expect(problems).to have(0).problems
35
+ end
36
+ end
37
+
38
+ context 'resource misalign let arrow_align check handle' do
39
+ let(:code) do
40
+ <<-EOS
41
+ class imatest {
42
+ file { '/tmp/test.txt':
43
+ ensure => present,
44
+ mode => '0655',
45
+ }
46
+ }
47
+ EOS
48
+ end
49
+
50
+ it 'should not detect any problems' do
51
+ expect(problems).to have(0).problems
52
+ end
53
+ end
54
+
55
+
21
56
  # and these should cause failiures
22
57
 
23
58
  context 'resource default with misaligned' do
@@ -45,4 +80,59 @@ describe 'improved_arrow_alignment' do
45
80
  end
46
81
  end
47
82
 
83
+ context 'resource misalign let arrow_align check handle with resource default' do
84
+ let(:msg) { 'indentation of => is not properly aligned (expected in column %d, but found it in column %d)' }
85
+
86
+ let(:code) do
87
+ <<-EOS
88
+ class imatest {
89
+ File {
90
+ ensure => present,
91
+ mode => '0755',
92
+ owner => root,
93
+ }
94
+
95
+ file { '/tmp/test.txt':
96
+ ensure => present,
97
+ mode => '0655',
98
+ }
99
+ }
100
+ EOS
101
+ end
102
+
103
+ it 'should not detect any problems' do
104
+ expect(problems).to have(2).problems
105
+ end
106
+
107
+ it 'should create a warning' do
108
+ expect(problems).to contain_warning(format(msg, 20, 19)).on_line(4).in_column(19)
109
+ expect(problems).to contain_warning(format(msg, 20, 22)).on_line(5).in_column(22)
110
+ end
111
+ end
112
+
113
+ context 'defined type with misaligned' do
114
+ let(:msg) { 'indentation of => is not properly aligned (expected in column %d, but found it in column %d)' }
115
+
116
+ let(:code) do
117
+ <<-EOS
118
+ define imatest::type {
119
+ File {
120
+ ensure => present,
121
+ mode => '0755',
122
+ owner => root,
123
+ }
124
+ }
125
+ EOS
126
+ end
127
+
128
+ it 'should detect two problems' do
129
+ expect(problems).to have(2).problem
130
+ end
131
+
132
+ it 'should create a warning' do
133
+ expect(problems).to contain_warning(format(msg, 20, 19)).on_line(4).in_column(19)
134
+ expect(problems).to contain_warning(format(msg, 20, 22)).on_line(5).in_column(22)
135
+ end
136
+ end
137
+
48
138
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-improved_arrow_alignment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garrett Rowell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint