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

Formatting follow-up #2540

Merged

Conversation

Marcono1234
Copy link
Collaborator

Purpose

Follow-up for #2531, #2536 and #2537

Description

  • Adds formatting commits to .git-blame-ignore-revs so that they don't distract during Git blame; see also the GitHub documentation
  • Restores hard line breaks in Troubleshooting.md using \ instead of trailing spaces
  • Changes formatting of some string literals and comments
  • Fixes accidental Javadoc and comment issues introduced by manual changes of formatting commit
  • Fixes license header in $Gson$Types.java erroneously being a Javadoc comment and being reformatted
  • Slightly changes JsonReader getPath and getPreviousPath documentation to help Javadoc detect first sentence as summary
  • Adjusts pull request template to mention Maven commands for checking and fixing formatting issues

Checklist

  • New code follows the Google Java Style Guide
  • If necessary, new public API validates arguments, for example rejects null
  • New public API has Javadoc
    • Javadoc uses @since $next-version$
      ($next-version$ is a special placeholder which is automatically replaced during release)
  • If necessary, new unit tests have been added
    • Assertions in unit tests use Truth, see existing tests
    • No JUnit 3 features are used (such as extending class TestCase)
    • If this pull request fixes a bug, a new test was added for a situation which failed previously and is now fixed
  • mvn clean verify javadoc:jar passes without errors

- Adds formatting commits to .git-blame-ignore-revs so that they don't
  distract during Git blame
- Restores hard line breaks in Troubleshooting.md using `\` instead of
  trailing spaces
- Changes formatting of some string literals and comments
- Fixes accidental Javadoc and comment issues introduced by manual changes
  of formatting commit
- Fixes license header in $Gson$Types.java erroneously being a Javadoc
  comment and being reformatted
- Slightly changes `JsonReader` `getPath` and `getPreviousPath` documentation
  to help Javadoc detect first sentence as summary
Copy link
Member

@eamonnmcmanus eamonnmcmanus left a comment

Choose a reason for hiding this comment

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

Thanks for putting in all this effort! Just some small remarks.

assertThat(json).isEqualTo("{\n" + " \"a\": [\n" + " 1,\n" + " 2\n" + " ]\n" + "}");
assertThat(json)
.isEqualTo(
// spotless:off
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be necessary. If you put an empty // comment at the end of any line then google-java-format will not try to join them:

assertThat(json).isEqualTo(
    "{\n" //
    + ...);

Though I don't really know whether the Spotless plugin applies exactly the same logic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you put an empty // comment at the end of any line then google-java-format will not try to join them

Yes that works, and I guess here it is ok because there are always multiple lines with //, but a single trailing // on its own looks to me rather like someone forgot to finish a comment.

Though I don't really know whether the Spotless plugin applies exactly the same logic.

I think it should. If I understand it correctly it just delegates the formatting to google-java-format (and optionally applies additional formatting steps).

Copy link
Member

@eamonnmcmanus eamonnmcmanus left a comment

Choose a reason for hiding this comment

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

Thanks again!

@eamonnmcmanus eamonnmcmanus merged commit c7c645d into google:main Nov 14, 2023
9 checks passed
@Marcono1234 Marcono1234 deleted the marcono1234/formatting-follow-up branch November 14, 2023 23:39
tibor-universe pushed a commit to getuniverse/gson that referenced this pull request Sep 14, 2024
* Formatting follow-up

- Adds formatting commits to .git-blame-ignore-revs so that they don't
  distract during Git blame
- Restores hard line breaks in Troubleshooting.md using `\` instead of
  trailing spaces
- Changes formatting of some string literals and comments
- Fixes accidental Javadoc and comment issues introduced by manual changes
  of formatting commit
- Fixes license header in $Gson$Types.java erroneously being a Javadoc
  comment and being reformatted
- Slightly changes `JsonReader` `getPath` and `getPreviousPath` documentation
  to help Javadoc detect first sentence as summary

* Remove `spotless:off` markers

* Add empty line before comment

* Check format for .github YAML files
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