Skip to content

Commit 93c5ec3

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

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

lib/puppet-lint/plugins/check_strict_indent.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ def check
116116
indent -= 1
117117
colon_indent = nil
118118
end
119+
elsif next_token.type == :SEMIC and !colon_indent.nil? and
120+
%i[INDENT NEWLINE].include?(next_token.prev_token.type) and
121+
(next_token.next_token.nil? or next_token.next_token.type == :NEWLINE)
122+
# For a lone semicolon within a block decrement immediately. Use temp_indent because
123+
# indent will be decremented in the next line by the prev_token logic above.
124+
temp_indent -= 1
119125
end
120126
next_token = next_token.next_token
121127
end
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)