puppetlabs / puppet-lint

Check that your Puppet manifests conform to the style guide
https://puppetlabs.github.io/puppet-lint/
MIT License
18 stars 12 forks source link

Lint behaves weird when fixing a top-level structured fact reference #189

Closed jay7x closed 4 months ago

jay7x commented 5 months ago

What Versions are you running?

OS Version: MacOS 14.2.1 (arm64) VSCode Version: VSCodium Version: 1.85.2 Puppet Extension Version: v1.5.1 (from the open-vsx repo) PDK Version: 3.0.1

What You Are Seeing?

Let's say I have the following example manifest with a (custom) top-level structured fact reference:

$foo = $::my_structured_fact['foo']

When I select "Format Document" from the context menu I got this:

$foo = $facts['my_structured_fact['foo']']

As you may see it's wrong syntax and it breaks the future file checks and formatting.

What is Expected?

$foo = $facts['my_structured_fact']['foo']
# -OR-
$foo = $facts.get('my_structured_fact.foo')

Though I'm not sure if it's easy to fix at all. So mostly leaving it here for your awareness.

jordanbreen28 commented 5 months ago

found to be an issue with puppet-lint, issue can be replicated using the above manifest example and running lint with the -f flag.

jordanbreen28 commented 4 months ago

@jay7x I've raised https://github.com/puppetlabs/puppet-lint/pull/190 to fix this. All looks good on my end from my testing, would be great if you could verify this too :)

jay7x commented 4 months ago

@jordanbreen28 Thank you! 🙏🏻 Not sure if I can test it quickly though..

jordanbreen28 commented 4 months ago

Not too worry! Always like to get the stamp of approval but im fairly certain it fixes the issue at hand anyway, we will get this merged in and released some time this week. It might a week or two to roll this out to puppet-editor-services and subsequently puppet-vscode, but I'll be sure to update this thread when i do! Thanks for raising this!

jordanbreen28 commented 4 months ago

@jay7x this was shipped as part of v1.5.2 of puppet-vscode :)

jay7x commented 4 months ago

@jordanbreen28 tyvm! Heading to try it later today!