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

Error fixing indent for variable in possion 0 #4

Closed
DrOwl opened this issue Jun 27, 2016 · 5 comments
Closed

Error fixing indent for variable in possion 0 #4

DrOwl opened this issue Jun 27, 2016 · 5 comments

Comments

@DrOwl
Copy link

DrOwl commented Jun 27, 2016

Hi, I original raised this issue with the puppet-lint code but its actually with this plug in instead
[https://github.com/rodjek/puppet-lint/issues/489](puppet-lint issue 489)

I am having an issue where if i let lint fix an error like "WARNING: indent should be 2 chars and is 0 on line 1" it tends to fix it incorrectly as it adds the 2 chars at possession 1 instead of 0.

I have done some extra digging and this seems to be because the way tokens of type "VARIABLE" work, there value is the name of the variable with out the $ (this seems logical). so in this case adding indent to the token.value will not work. Seems you would have to add a new token of type WHITESPACE instead

Example of bug

=== Original file ===
class agent(
$group = "",
$server = "",
$serial = "",
$service_name = "",
$server_ip = "",
$version = "",
$enabled = true,
){

=== Fixed file ===

class agent(
$ group = '',
$ server = '',
$ serial = '',
$ service_name = '',
$ server_ip = '',
$ version = '',
$ enabled = true,
){

== Example runs ==

$ puppet-lint init.pp
./manifests/init.pp - WARNING: indent should be 2 chars and is 0 on line 1
./manifests/init.pp - WARNING: indent should be 2 chars and is 0 on line 2
./manifests/init.pp - WARNING: indent should be 2 chars and is 0 on line 3
./manifests/init.pp - WARNING: indent should be 2 chars and is 0 on line 4
./manifests/init.pp - WARNING: indent should be 2 chars and is 0 on line 5
./manifests/init.pp - WARNING: indent should be 2 chars and is 0 on line 6
./manifests/init.pp - WARNING: indent should be 2 chars and is 0 on line 7

$ puppet-lint -f init.pp
./manifests/init.pp - FIXED: indent should be 2 chars and is 0 on line 1
./manifests/init.pp - FIXED: indent should be 2 chars and is 0 on line 2
./manifests/init.pp - FIXED: indent should be 2 chars and is 0 on line 3
./manifests/init.pp - FIXED: indent should be 2 chars and is 0 on line 4
./manifests/init.pp - FIXED: indent should be 2 chars and is 0 on line 5
./manifests/init.pp - FIXED: indent should be 2 chars and is 0 on line 6
./manifests/init.pp - FIXED: indent should be 2 chars and is 0 on line 7

@DrOwl
Copy link
Author

DrOwl commented Jun 27, 2016

I have created a fix for this but my Ruby foo isn't that good...
https://github.com/DrOwl/puppet-lint-strict_indent-check/commit/668e092a5503dd2f3062aeb063bbb84451bfed71

@relud
Copy link
Contributor

relud commented Jun 27, 2016

fixed in 84f039f

@relud relud closed this as completed Jun 27, 2016
@DrOwl
Copy link
Author

DrOwl commented Jun 27, 2016

Thanks

@DrOwl
Copy link
Author

DrOwl commented Jun 27, 2016

A follow up to this I noted at the same time the line numbers are reported incorrectly.
Warning issues for line 1 but problem was on line 2.

@relud
Copy link
Contributor

relud commented Jun 27, 2016

thanks, i'll look into it

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

2 participants