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 --fix incorrectly removes commas, creating syntax error #127

Open
alisonatwork opened this issue May 29, 2023 · 0 comments
Open

Comments

@alisonatwork
Copy link

alisonatwork commented May 29, 2023

We recently encountered a bug when applying puppet-lint fixes in a CI pipeline that did not have a subsequent syntax check. The issue is that in some cases, puppet-lint --fix will "fix" the code in such a way that it is broken.

Test case:

file{'/abc':
  ensure=>directory,owner=>test,group=>test,
  mode=>'0755',
}

When running puppet-lint against this file, it complains about the indentation of => being wrong. But if you run puppet-lint --fix, it will produce a file that looks like this:

file{'/abc':
  ensure =>directory
  owner  =>test
  group  =>test,
  mode   =>'0755',
}

Note the missing commas. I guess what is happening is some kind of off-by-one error where the commas are replaced by newline+indent, because this doesn't happen if the source file had spaces after the commas.

Something that might be nice (although I am not sure how easy it would be to do) is if puppet-lint could also run a syntax check on the files it supposedly fixed as a sanity check.

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

No branches or pull requests

2 participants