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

Display puppet parser warnings #211

Open
SPIRIT-Betrieb opened this issue Dec 16, 2019 · 7 comments
Open

Display puppet parser warnings #211

SPIRIT-Betrieb opened this issue Dec 16, 2019 · 7 comments
Assignees
Labels
enhancement New feature or request language

Comments

@SPIRIT-Betrieb
Copy link

Summary of the new feature

The puppet parser validate command display some problematic lexical construct as warnings.
Examples:

$server = 'localhost'
notify{"Path: ${server}\foo":}

Parser Warning:
Unrecognized escape sequence '\f' (file: lexer.pp, line: 2, column: 29)

$number1 = 5000
$number2 = '6000'
$sum = $number1 + $number2
notify{"Sum: $sum":}

Parser Warning:
The string '6000' was automatically coerced to the numerical value 6000 (file: lexer.pp, line: 3, column: 19)

I would like VSCode to show that warnings to the developer, so that they are aware of the problematic lexical construct they are using.


As a puppet code developer I want to be able to see lexer warning that puppet parser validates provides, so that I'm aware of problematical constructs in my code.

@glennsarti glennsarti transferred this issue from puppetlabs/puppet-vscode Dec 19, 2019
@glennsarti
Copy link
Contributor

Thanks @SPIRIT-Betrieb . We will try and repo this

@glennsarti glennsarti added this to the 0.24.0 milestone Dec 19, 2019
@glennsarti glennsarti added enhancement New feature or request Language Server labels Dec 19, 2019
@glennsarti glennsarti self-assigned this Dec 19, 2019
@glennsarti
Copy link
Contributor

Okay, so the parser validation is only outputing the warnings to the console:

I, [2019-12-19T16:57:12.247540 #34376]  INFO -- : Initializing settings...
I, [2019-12-19T16:57:12.248104 #34376]  INFO -- : Using Facter v2.5.6
I, [2019-12-19T16:57:12.248658 #34376]  INFO -- : Skipping preloading Puppet
--- Time to rock-n-roll
D, [2019-12-19T16:57:12.262523 #34376] DEBUG -- : [PUPPET LOG] [warning] Unrecognized escape sequence '\f'
---

@glennsarti
Copy link
Contributor

@glennsarti
Copy link
Contributor

glennsarti commented Dec 19, 2019

We won't be able to do the number coercion though. That happens during a catalog compile, not parser validation. And compilations are an "expensive" thing to do.

Given a manifest of

$server = 'localhost'
notify{"Path: ${server}\foo":}

$number1 = 5000
$number2 = '6000'
$sum = $number1 + $number2
notify{"Sum: $sum":}
C:\Source\puppet-editor-services [master ≡ +0 ~1 -0 !]> puppet parser validate tmp/bah.pp
Warning: Unrecognized escape sequence '\f' (file: C:/Source/puppet-editor-services/tmp/bah.pp, line: 2, column: 29)

C:\Source\puppet-editor-services [master ≡ +0 ~1 -0 !]> puppet apply tmp/bah.pp
Failed to load feature test for cfpropertylist: cannot load such file -- CFPropertyList
Warning: Unrecognized escape sequence '\f' (file: C:/Source/puppet-editor-services/tmp/bah.pp, line: 2, column: 29)
Warning: The string '6000' was automatically coerced to the numerical value 6000 (file: C:/Source/puppet-editor-services/tmp/bah.pp, line: 6, column: 19)
Notice: Compiled catalog for xxxx in environment workstation_production in 0.10 seconds
Notice: Path: localhost\foo
Notice: /Stage[main]/Main/Notify[Path: localhost\foo]/message: defined 'message' as 'Path: localhost\foo'
Notice: Sum: 11000
Notice: /Stage[main]/Main/Notify[Sum: 11000]/message: defined 'message' as 'Sum: 11000'
Notice: Applied catalog in 0.06 seconds

@glennsarti
Copy link
Contributor

I've raised a bug in puppet-lint as it appears it should be raising the warnings already

rodjek/puppet-lint#907

@glennsarti
Copy link
Contributor

I've got a WIP PR up to detect the issue. https://github.com/glennsarti/puppet-editor-services/tree/gh-211-lexer-warnings

I'll hold off a bit to see if puppet-lint fix the error first.

@Raskil
Copy link

Raskil commented Jan 8, 2020

Just for your information: I raised a ticket for the compiler as well: https://tickets.puppetlabs.com/browse/PUP-10176 (I was the one raising this FR).

@glennsarti glennsarti modified the milestones: 0.24.0, 0.25.0 Jan 27, 2020
@jpogran jpogran removed this from the 0.25.0 milestone Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request language
Projects
None yet
Development

No branches or pull requests

4 participants