Skip to content

Conversation

@ppkarwasz
Copy link
Contributor

This PR adds a Spotless configuration that uses:

Review tips

This PR contains two commits:

  • febb123 is a manual change the POM file.
  • fc1972e was generated by calling:
    mvn spotless:apply
    and should be easy to reproduce.

Closes #183

@ppkarwasz ppkarwasz mentioned this pull request Mar 14, 2025
@ppkarwasz
Copy link
Contributor Author

Since this PR formats code, it will cause a lot of conflicts with other PRs.
When more important PRs are merged, let me know and I'll rebase this one.

Comment on lines 95 to 101
public PackageURL(
final String type,
final String namespace,
final String name,
final String version,
final TreeMap<String, String> qualifiers,
final String subpath)
Copy link
Contributor

Choose a reason for hiding this comment

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

This change has something to do with the number of parameters? Maybe increase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The formatter limits the line to 120 characters and starts wrapping if it's more.

*/
public MalformedPackageURLException() {
}
public MalformedPackageURLException() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I am against this change since braces are not supposed to be on a single line, empty or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a choice in the palantir-java-format, not modifiable.

Comment on lines +312 to +317
throw new MalformedPackageURLException(
"The PackageURL " + component + " '" + value + "' contains invalid characters: " + invalidChars);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe increase the line length? What is it currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The line length chosen by the palantir-java-format is 120. Non-modifiable.

In general I like the fact that the formatter does not accept any parameters. At a previous job we spent 3 months deciding on all the hundreds of options of the Eclipse formatter and everybody hated the result anyway.

Comment on lines +297 to +302
private static void validateChars(String value, IntPredicate predicate, String component)
throws MalformedPackageURLException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is a line length issue as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything in fc1972e has been generated by running:

mvn spotless:apply

@jeremylong
Copy link
Collaborator

@ppkarwasz due to how GH works, I can't figure out how to easily merge this without fixing the merge conflicts. While that sounds easy (revert the last commit, rebase or merge master, run spotlessApply), doing this on someone else's PR appears to be a bit more challenging. Mind updating this one?

@ppkarwasz ppkarwasz force-pushed the feature/spotless branch 2 times, most recently from f155571 to e30d6f3 Compare March 19, 2025 10:44
@ppkarwasz ppkarwasz changed the title Add Spotless formatter configuration style: add Spotless formatter configuration Mar 19, 2025
@ppkarwasz
Copy link
Contributor Author

@jeremylong, done!

@jeremylong jeremylong merged commit fe90327 into package-url:master Mar 19, 2025
3 checks passed
@jeremylong
Copy link
Collaborator

Thanks!

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.

Use deterministic code formatter

3 participants