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

puppet-lint reports incorrect line numbers #403

Closed
utoddl opened this issue Mar 15, 2015 · 6 comments
Closed

puppet-lint reports incorrect line numbers #403

utoddl opened this issue Mar 15, 2015 · 6 comments

Comments

@utoddl
Copy link

utoddl commented Mar 15, 2015

puppet-lint reports incorrect line numbers for issues it finds if there are multi-line string constants preceding the issue. For example, if the .pp file being examined has a 6 line string starting on line 100 and a 46 line string starting on line 150, then a problem with line 250 is reported as being on line 200. Also, the --with-context option will show the text of line 200 rather than the text of line 250 where the actual error is.

In short, multi-line strings throw puppet-lint's error reporting off.That is, line counting gets thrown off by N-1 for each N-line string.

Our "puppet-lint --version" returns "puppet-lint 1.1.0" if that helps.

@cmckendry
Copy link

This also breaks on multi-line comments (of the form /* comment */)

I know this is frowned upon in the formatting guidelines, but it's still legal syntax and is used widely enough that it'd be nice to have the lint checks work correctly.

@rnelson0
Copy link
Collaborator

@utoddl @cmckendry Can you provide a link to example code that suffers from this issue, please? Thank you!

@utoddl
Copy link
Author

utoddl commented Jun 30, 2016

Here's a complete example. Create foo.pp with the following content:

class {
    some::other::thing { 'thingname':
        multiline_string => 'This string spans
                             multiple lines.',
        thing3 => 'unaligned rocket on line 5, reported as line 4.',
    }
}

Then run "puppet-lint foo.pp" to get the following output:

$ puppet-lint ./foo.pp 
WARNING: indentation of => is not properly aligned on line 4

It should say, " ...on line 5". The line counter isn't being incremented in multi-line strings (or comments according to @cmckendry )

@paran1
Copy link
Contributor

paran1 commented Dec 12, 2016

I missed this and reported #565 (a duplicate). A fix for this problem is already in the master branch, but only handles single quoted strings. My pull request #577 handles double quoted strings the same way, however, I see in this issue that this also happens for multi line comments and that is not fixed.

@rnelson0
Copy link
Collaborator

I merged #577 which should address this issue. @utoddl can you confirm that by pointing to HEAD it addresses your issue? We'll look at a Rubygems release soon.

@rnelson0
Copy link
Collaborator

@utoddl I tested with your sample code and it looks okay so I am closing this. Please re-open if you find a related fault. Thanks!

$ be puppet-lint 403.pp  --no-code_on_top_scope-check
WARNING: indentation of => is not properly aligned (expected in column 26, but found it in column 16) on line 5

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

No branches or pull requests

4 participants