Skip to content

style: add Spotless formatter configuration - #189

Merged
jeremylong merged 4 commits into
package-url:masterfrom
ppkarwasz:feature/spotless
Mar 19, 2025
Merged

style: add Spotless formatter configuration#189
jeremylong merged 4 commits into
package-url:masterfrom
ppkarwasz:feature/spotless

Conversation

@ppkarwasz

Copy link
Copy Markdown
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

@ppkarwaszppkarwasz mentioned this pull request Mar 14, 2025
@ppkarwasz

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
ppkarwaszforce-pushed the feature/spotless branch 2 times, most recently from f155571 to e30d6f3CompareMarch 19, 2025 10:44
@ppkarwaszppkarwasz changed the title Add Spotless formatter configurationstyle: add Spotless formatter configurationMar 19, 2025
@ppkarwasz

Copy link
Copy Markdown
ContributorAuthor

@jeremylong, done!

@jeremylong
jeremylong merged commit fe90327 into package-url:masterMar 19, 2025
@jeremylong

Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for freeto 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

@ppkarwasz@jeremylong@dwalluck