Skip to content

Conversation

@msalway
Copy link
Contributor

@msalway msalway commented Aug 4, 2025

Change the handling of indent on the semicolon separator in resource statements so it matches the Puppet documentation example:
https://www.puppet.com/docs/puppet/7/lang_resources#resource-declaration-default-attributes

Fixes #19

Example from Puppet docs:

file {
  default:
    ensure => file,
    owner  => "root",
    group  => "wheel",
    mode   => "0600",
  ;
  ['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:
    # use all defaults
  ;
  ['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:
    # override mode
    mode => "0644",
  ;
}

Currently the plugin expects this to be indented like this:

file {
  default:
    ensure => file,
    owner  => "root",
    group  => "wheel",
    mode   => "0600",
    ;
  ['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:
    # use all defaults
    ;
  ['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:
    # override mode
    mode => "0644",
    ;
}

@alexjfisher
Copy link
Member

The should indent for semi-colons not indented enough is wrong.

file {
  default:
    ensure => file,
    owner  => "root",
    group  => "wheel",
    mode   => "0600",
;
}
W: [strict_indent] indent should be 4 chars and is 0

It should be wanting 2 chars, not 4.

@alexjfisher
Copy link
Member

More tests you can pull in in 93b09f5

@msalway
Copy link
Contributor Author

msalway commented Aug 5, 2025

Fixed bug with incorrect indent when fixing semicolon at start of line and added @alexjfisher's tests.

Replaces existing fail cases
@@ -1,4 +1,7 @@
require 'spec_helper'
# rubocop:disable Lint/RedundantRequireStatement
require 'pp'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexjfisher alexjfisher merged commit f0f1240 into voxpupuli:main Aug 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update indent behaviour when semicolon is on a separate line

2 participants