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

RFE: Default ansible-lint params in settings to --fix #985

Open
cidrblock opened this issue Sep 28, 2023 · 2 comments
Open

RFE: Default ansible-lint params in settings to --fix #985

cidrblock opened this issue Sep 28, 2023 · 2 comments

Comments

@cidrblock
Copy link

This will enable fixing automatically for users.

We'll need to watch closely for feedback :)

@cidrblock
Copy link
Author

thinking about htis more, let's not do this.......

I think we need to support lint as a formatter e.g. python.formatting.provider

so the user can "File: Save without formatting"

@netopsengineer
Copy link

@cidrblock I was planning on creating an issue on a similar topic, but I think the overall challenge is better addressed as you mentioned, through a formatting provider. I encountered an issue trying to create this type of functionality, specifically when using the write_list: ["all"] configuration in ansible-lint, which is designed for auto-fixing. This configuration conflicts with VS Code's "files.autoSave": "afterDelay" setting it seems.

Here's the problem: if auto-save is triggered while you're still modifying a task (which is malformed in some way), the extension invokes ansible-lint and attempts to fix the file, sometimes it does this so quickly, that it is leading to a conflict in VS Code with the following error message:

Failed to save 'site.yml': The content of the file is newer. Please compare your version with the file contents or overwrite the content of the file with your changes.

I believe formatting providers can handle these scenarios more effectively, especially the formatting on save, in fact I saw you can even format only the parts of a file you modified now as well on save. Overall, I support this idea as it aligns with what I was trying to achieve. While you could use pre-commit hooks, you are likely to surprise new users, when the opinionated fixes take place, and force them to re-commit, for example. It would be much more transparent if they could see it while the file was open.

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

No branches or pull requests

2 participants