Skip to content

Commit 8c36884

Browse files
committed
Match the indent for a single semicolon with the Puppet documentation
1 parent 86d0bb8 commit 8c36884

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

lib/puppet-lint/plugins/check_strict_indent.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ def check
120120
next_token = next_token.next_token
121121
end
122122

123+
# For a lone semicolon within a block decrement immediately. Use temp_indent because
124+
# indent will be decremented in the next line by the prev_token logic above.
125+
temp_indent -= 1 if !colon_indent.nil? and
126+
token.next_token.type == :INDENT and
127+
token.next_token.next_token.type == :SEMIC and
128+
token.next_token.next_token.next_token.type == :NEWLINE
129+
123130
# obviously we have a problem
124131
if indent < 0
125132
notify :error, {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
file {
2+
default:
3+
ensure => file,
4+
owner => 'root',
5+
group => 'wheel',
6+
mode => '0600',
7+
;
8+
['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:
9+
# use all defaults
10+
;
11+
['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:
12+
# override mode
13+
mode => '0644',
14+
;
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
file {
2+
default:
3+
ensure => file,
4+
owner => 'root',
5+
group => 'wheel',
6+
mode => '0600',
7+
;
8+
['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:
9+
# use all defaults
10+
;
11+
['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:
12+
# override mode
13+
mode => '0644',
14+
;
15+
}

spec/fixtures/pass/semicolon.pp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
file {
2+
default:
3+
ensure => file,
4+
owner => 'root',
5+
group => 'wheel',
6+
mode => '0600',
7+
;
8+
['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:
9+
# use all defaults
10+
;
11+
['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:
12+
# override mode
13+
mode => '0644',
14+
;
15+
}

0 commit comments

Comments
 (0)