voxpupuli / puppet-lint-strict_indent-check

indent check for puppet-lint
Mozilla Public License 2.0
4 stars 11 forks source link

Extra indent requested with two opens on same line. #21

Open traylenator opened 4 years ago

traylenator commented 4 years ago

With the following

$content = epp('file.epp',{
  'options' => '124',
})
puppet-lint-strict_indent-check (2.0.7)

gives.

WARNING: indent should be 4 chars and is 2 on line 2

this seems wrong to me.

Maybe it should be rewritten as

$content = epp('file.epp',
  {
    'options' => '124',
  }
)

but the first seems valid to me.

relud commented 4 years ago

this behavior is intentional

alexjfisher commented 3 years ago

this behavior is intentional

That's a shame. IMO, it's not correct and conflicts with what other tools do. eg. vim-puppet's indentation.

It's not just a puppet thing, eg ruby and rubocop.

Puppet code following the rules from this plugin.

$a = [{
    foo => bar,
}]

Almost identical ruby code following same style.

a = [{
    foo: 'bar'
}]

Layout/FirstHashElementIndentation: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.

relud commented 3 years ago

this behavior is intentional

That's a shame. IMO, it's not correct and conflicts with what other tools do.

I agree. When I wrote this plugin I had to choose how to indent for these cases:

$content = epp(
  'file.epp',{
    'options' => '124',
})
$content = epp('file.epp',{
    'options' => '124',
  }
)

This plugin does not assert that multiple brackets in a single line must also be closed in a single line, so the simpler code implementation was to increase or decrease indent for every bracket.

I no longer write new code for this plugin, but I will reopen this issue and mark it as help wanted.

If someone wants to implement a fix for this issue, I will publish it as a major version bump, and the following indents should all be valid:

$content = epp('file.epp',{
  'options' => '124',
})
$content = epp(
  'file.epp',{
    'options' => '124',
})
$content = epp('file.epp',{
    'options' => '124',
  }
)