Skip to content

Update VSCode Code Formatting #43

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

Closed
doulikecookiedough opened this issue Jul 18, 2023 · 1 comment
Closed

Update VSCode Code Formatting #43

doulikecookiedough opened this issue Jul 18, 2023 · 1 comment

Comments

@doulikecookiedough
Copy link
Contributor

doulikecookiedough commented Jul 18, 2023

When time-permitting, adjust the VSCode format settings to accurately reflect the expected formatting settings (reference IntelliJ's formatting as it is more accurate to the Google Style).

Examples:

  • closing parameters/methods with ); and ) does not get placed on its own lines.
  • Indenting inconsistencies (double indent where one is expected)
@doulikecookiedough
Copy link
Contributor Author

doulikecookiedough commented Sep 8, 2023

The current documentation for VSCode for formatting Java points is outdated, is discussed here and can be confirmed by checking the last updated date on GitHub (as well as the differences noticed during our code review). It also looks like Google does not want to support configuration files, but instead push users wishing to follow the Google Java Format to a .jar file which can be called to format documents: google-java-format

This .jar file is not immediately compatible with VSCode. It is a formatter/library which must be called through Java. There is a maven plugin that can assist with automating this process, but this requires a java version upgrade:

  • Execution validate-code-format of goal com.cosium.code:git-code-format-maven-plugin:3.3:validate-code-format failed: An API incompatibility was encountered while executing com.cosium.code:git-code-format-maven-plugin:3.3:validate-code-format: java.lang.UnsupportedClassVersionError: com/google/googlejavaformat/java/FormatterException has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

While I do not believe there would be an issue with upgrading java versions, doing so for the sole purpose of adding a new dependency does not sit quite right with me. I do not want to potentially introduce a dependency issue in the future (for a non-critical issue related to code formatting).

The differences of formatting between IntelliJ and VSCode cannot be addressed (for now, maybe I've missed something) because there are no settings that can be adjusted to speak directly to the affected formatting issues discovered during code review.

  • To see what can be adjusted in VSCode, you can open the editor command window and select Java: Open Java Formatter Settings with Preview.

The majority of these differences are related to tab settings and new lines, which do not affect the functionality of HashStore, and are more of an aesthetic issue. Any additional time spent trying to sync the two perfectly does not feel productive (or possible), so I am opting to stick with the current EclipseJava_GoogleStyle.xml - which is actually a settings file exported directly from IntelliJ (where the formatting is what we're trying to reproduce).

I am closing this issue, and will re-open if it is felt that we should allocate resources to ensure code formatting is 'perfect'.

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

No branches or pull requests

1 participant