yamlfixer icon indicating copy to clipboard operation
yamlfixer copied to clipboard

Feature request > Fix `quoted-strings`

Open giggio opened this issue 1 year ago • 8 comments

❔ Context

Fix quoted-strings. Docs: https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.quoted_strings

💡 Proposed solution

  1. Change quote-type to double or single accordingly;
  2. Remove unnecessary quotes when required is set to only-when-needed;
  3. Add quotes when required is set to true;
  4. Remove quoted quotes when allow-quoted-quotes is false.

giggio avatar Oct 06 '22 02:10 giggio

Hi @tamere-allo-peter , what's your opinion about this feature request ?

adriens avatar Oct 06 '22 02:10 adriens

@adriens very complex. Currently we don't use yamllint's configuration file, we only pass it as-is to yamllint when needed, and we "fix" by doing what yamllint suggests, whenever it does suggest something, and do our best the remaining of the time. Closing this one is very hard work because if we begin to parse yamllint's configuration file, this opens the door to a number of other fixes we should do according to this file that we don't right now.

tamere-allo-peter avatar Oct 06 '22 03:10 tamere-allo-peter

So should we flag this as a wontfix because of lack of time ?

adriens avatar Oct 06 '22 04:10 adriens

@adriens we'll leave it open for now, maybe I'll have more time for this at the end of the year.

tamere-allo-peter avatar Oct 06 '22 04:10 tamere-allo-peter

So it will stay on : image

⏸️

adriens avatar Oct 06 '22 05:10 adriens

this opens the door to a number of other fixes we should do according to this file that we don't right now.

Perhaps that it opens the door to different fixes, but the scope of the current github issue would remain "to automatically fix quoted-strings" and so the other fixes that could be made can be put in a backlog for future contributions.

This said, another issue would need to be created & resolved first (i.e. Adding a yamllint configuration parser)

ps: thanks for this package, it's really great!

fortin-alex avatar Dec 19 '22 20:12 fortin-alex

Re-reading my previous comment, it might be something that yamllint can fix on their end (i.e. they could write a better message when reporting a quoted-strings error)

On my end, I see this message from yamllint:

>>> cat .yamllint
rules:
 quoted-strings:
    quote-type: double
    required: true
    allow-quoted-quotes: true

>>> yamllint --format parsable .
./path/to/file/config.yaml:31:11: [error] string value is not quoted with double quotes (quoted-strings)

And I am wondering if this message is informative enough to be actionable? it seems to suggest to replace the single quotes by double quotes or to add double-quotes.

fortin-alex avatar Dec 19 '22 20:12 fortin-alex

Yes it seems to be informative enough in the general case, however unfortunately I don't have the time to work on this project at the moment.

tamere-allo-peter avatar Dec 19 '22 20:12 tamere-allo-peter