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

Code Formatter #785

Closed
wants to merge 3 commits into from
Closed

Code Formatter #785

wants to merge 3 commits into from

Conversation

AllanWang
Copy link
Contributor

Resolves #778

Adds the codestyle by ktlint along with spotless.

The continuation indent is back to 4 in ktlint, as they claim there isn't an official spec (pinterest/ktlint#410)

Main point is that this allows you to enforce a certain style so new PRs will not modify the formatting.
If you'd like to go through with this, there are probably ways to change certain settings so that it matches what you'd like. For instance, right now wildcard imports are also disabled.

There are check and apply commands in spotless if you wish to test it out. You will need to format through AS to fix wildcard imports first though.

@@ -47,3 +48,7 @@ allprojects {
maven { url "https://jitpack.io" }
}
}

subprojects {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As a note, for the section above, should that apply to all projects or just subprojects? I'm using subprojects below since the relative gradle path matters

@mikepenz mikepenz self-requested a review June 14, 2019 07:50
@mikepenz mikepenz self-assigned this Jun 14, 2019
@mikepenz
Copy link
Owner

I have looked into it.

As far as I can say spotless or ktlint are more strict than necessary.

Also tried to find a way to disable the wildcard rule as this one does not make any sense, and is a default from AS. (the latest version of ktlint actually disables that rule, but beside that it complains about space after "//" which should not really be a concern)

I will check alternatives, as I think the check should be 100% happy, if the default AS formatter is applied

@mikepenz mikepenz mentioned this pull request Jun 14, 2019
@AllanWang
Copy link
Contributor Author

There is also detekt, which seems to offer better configuration options

pinterest/ktlint#48 (comment)

Might be worth taking a look at if it can also disable verifications for comments

@AllanWang AllanWang changed the title Spotless Code Formatter Jun 14, 2019
@mikepenz
Copy link
Owner

@AllanWang 1 minute late :D #786

@mikepenz
Copy link
Owner

Thank you so much for this PR. I decided to go with a little bit less strict detekt configuration.

@mikepenz mikepenz closed this Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upload codestyle
2 participants