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

Format dependencies in order to have consitent look and feel #6

Open
ghilainm opened this issue Oct 5, 2018 · 6 comments
Open

Format dependencies in order to have consitent look and feel #6

ghilainm opened this issue Oct 5, 2018 · 6 comments

Comments

@ghilainm
Copy link

ghilainm commented Oct 5, 2018

The plugin should in addition of reordering dependencies also format them in order to have consistent look and feel.

Example:

    implementation 'org.apache.commons:commons-lang3:3.7'
    implementation "org.springframework.hateoas:spring-hateoas"
    annotationProcessor("org.projectlombok:lombok:1.18.2")

->

    implementation("org.apache.commons:commons-lang3:3.7")
    implementation("org.springframework.hateoas:spring-hateoas")
    annotationProcessor("org.projectlombok:lombok:1.18.2")
@ghilainm ghilainm changed the title Format dependencies Format dependencies in order to have same look and feel Oct 5, 2018
@ghilainm ghilainm changed the title Format dependencies in order to have same look and feel Format dependencies in order to have consitent look and feel Oct 5, 2018
@platan
Copy link
Owner

platan commented Oct 5, 2018

Thanks for an idea and reporting it.
I can see one important challenge here. Which format to choose? The simplest? The most common one? What if preferred format cannot be applied to all dependencies (e.g. we want to use format without brackets, but we have to because of closures). What does it mean 'the simplest format'? I prefer format without brackes and you added brackets to all dependences in your example.
It wood be good to discuss these issues with examples.

@ghilainm
Copy link
Author

ghilainm commented Oct 5, 2018

I would go for the format which can be used with closures and I would use Groovy string in order to support variable replacement.

-> implementation("org.apache.commons:commons-lang3:$commonLangVersion")

Gradle (understand Groovy) is confusing because of the numerous syntax that are available. It would be good for développeuse to have all the time the same format.

I think that this format also helps clarifying that behind it corresponds to a standard method call.

Other options if you don't like forcing people:

  • [easy to implement] Add enable/disable formatting, so that people can choose.
  • [maybe harder] Add an option to choose the preferred format in your plugin. And in case format is not syntactically valid, choose a valid one for this line.

@LSafer
Copy link

LSafer commented Aug 30, 2021

Why not making it configurable in the settings?

@LSafer
Copy link

LSafer commented Aug 30, 2021

Or better, why not making it project level thing? because every project might have its own better convention.

@LSafer
Copy link

LSafer commented Aug 30, 2021

The settings might be like this:

  • invoke methods with braces or not
  • prefer GString over string or the way around with the exception of always using GString when a variable been injected.
  • sort by scope or by name, some may prefer leaving test dependencies at the bottom and some may prefer sorting by the name.

@trajano
Copy link

trajano commented Jan 8, 2023

I generally prefer

implementation 'org.apache.commons:commons-lang3:3.7'
implementation "org.springframework.hateoas:spring-hateoas"

The parenthesis adds too much visual distraction and I would only want that distraction if the above version is not able to do it (e.g. if exclusions are needed) as it will visually indicate deviating from the defaults.

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

4 participants