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

Format yaml files using Spotless. #1688

Merged
merged 1 commit into from
Sep 15, 2024
Merged

Conversation

motlin
Copy link
Contributor

@motlin motlin commented Aug 31, 2024

Another example based on #1687, to show off the kind of thing that Spotless can do, this time in a language other than Java.

This was created with the command:

mvn spotless:apply --activate-profiles 'spotless-apply,spotless-yaml'

Copy link
Contributor

@donraab donraab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@motlin This looks to be replacing single quotes with double quotes. Are double quotes preferred in YAML?

@motlin
Copy link
Contributor Author

motlin commented Sep 2, 2024

@motlin This looks to be replacing single quotes with double quotes. Are double quotes preferred in YAML?

Honestly, I'm not sure. I just noticed we are inconsistent and it's one of the things that's easy to demo with Spotless. Searching for this question:

Single quotes (''):

  • Preserve the literal value of all characters inside
  • Don't allow escaping of characters
  • To include a single quote in the string, you need to double it

Double quotes (""):

  • Allow for escaped characters using backslashes
  • Enable the use of special characters like \n for newline

General recommendations:

Use single quotes as the default for most strings, especially if they don't contain special characters or escapes.

I can switch to single!

@motlin
Copy link
Contributor Author

motlin commented Sep 2, 2024

@motlin This looks to be replacing single quotes with double quotes. Are double quotes preferred in YAML?

Switched to single quotes.

Copy link
Contributor

@donraab donraab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@motlin motlin merged commit f6d78f5 into eclipse:master Sep 15, 2024
18 checks passed
@motlin motlin deleted the spotless-yaml branch September 15, 2024 13:32
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

Successfully merging this pull request may close these issues.

2 participants