voxpupuli / puppet-lint-strict_indent-check

indent check for puppet-lint
Mozilla Public License 2.0
4 stars 11 forks source link

Error fixing indent for variable in possion 0 #4

Closed DrOwl closed 8 years ago

DrOwl commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

fixed in 84f039f

DrOwl commented 8 years ago

Thanks

DrOwl commented 8 years ago

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 commented 8 years ago

thanks, i'll look into it