littlerobots / version-catalog-update-plugin

Gradle plugin for updating a project version catalog
Apache License 2.0
565 stars 23 forks source link

Allow control of bundle formatting #44

Closed dalewking closed 2 years ago

dalewking commented 2 years ago

If you have a log of items in a bundle it is much better to put them on multiple lines as in:

myBundle = [
    "dependency1",
    "dependency2",
    "dependency3",
]

I also prefer the trailing comma to reduce diffs when adding a line

However this plugin always forces it into one line which makes for very long, unreadable lines. In my project I have a bundle that it forces into a 275 character line.

You should allow control of whether it is broken up, with perhaps a break it up if if is over x line length and also whether to use trailing comma when you do.

hvisser commented 2 years ago

Agreed that one single line is not ideal :) Would limiting the line length and adding a trailing comma be acceptable for your use case? I rather not have tons of options to configure this vs having a sensible, opinionated default.

dalewking commented 2 years ago

If, you put the values in the array on separate lines if it does not fit on one line, then yes. My use case is that I always want all entries in the bundle to be on separate lines, so the sensible, opinionated default in my mind is never try to squeeze it into one line.

hvisser commented 2 years ago
myBundle = [
    "dependency1",
    "dependency2",
    "dependency3",
]

Also gets very verbose when you have a lot in the bundle, so I was suggesting to have them span a fixed amount of characters before wrapping to the next line. There are of course many flavours and opinions here, but like other formatters, if there's no or little customisation there's also nothing to argue about :)

dalewking commented 2 years ago

I would probably set the value to something like 1 or 0 to always force multiple lines.

Also to be clear, If you do put them all in one line then you should not add the trailing comma.

hvisser commented 2 years ago

0.5.0 implements the proposed formatting, should be available on Maven Central soon.