Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
traylenator opened this issue Sep 14, 2020 · 3 comments
Open

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

traylenator opened this issue Sep 14, 2020 · 3 comments

Comments

@traylenator
Copy link

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 relud closed this as completed Sep 14, 2020
@relud
Copy link
Contributor

relud commented Sep 14, 2020

this behavior is intentional

@alexjfisher
Copy link
Member

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
Copy link
Contributor

relud commented Jan 4, 2021

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',
  }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants