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

Treewide codestyle cleanup #765

Merged
merged 3 commits into from
May 10, 2020
Merged

Treewide codestyle cleanup #765

merged 3 commits into from
May 10, 2020

Conversation

msfjarvis
Copy link
Member

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

I've split the PR up in 3 commits to separate logical parts:

  • Updated gitignore and checked in the IDE's codestyle config
  • Removed spotless as the underlying ktlint backend has failed to resolve the super frustrating import order bug in nearly a year
  • Reformat the entire codebase based on the previously committed code style configuration.

💡 Motivation and Context

The cycle of Write code in the IDE -> Run spotlessApply -> Go back to make a change -> Run spotlessApply again because import order changed got extremely tiring.

💚 How did you test it?

📝 Checklist

  • I reviewed submitted code

🔮 Next steps

There seems to be no other formatter available, so none. Might be worth exploring detekt for static analysis.

📸 Screenshots / GIFs

@@ -20,7 +20,7 @@

## :pencil: Checklist
<!--- Put an `x` in the boxes that apply -->
- [ ] I ran `./gradlew spotlessApply` before submitting the PR
- [ ] I formatted the code with the IDE's reformat action (Ctrl + Shift + L/Cmd + Shift + L)
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better if we give directions to the UI element ?
IDE shortcuts may not be available if they are used by the system. (I had this issue on KDE)

Copy link
Member Author

Choose a reason for hiding this comment

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

No way to do that without making the entire thing very wordy. I'm trying to keep this as small as it can be. I intentionally used the wording IntelliJ uses so you can just plop this into a search engine and get the right results should there be a case as yours.

@fmeum
Copy link
Member

fmeum commented May 6, 2020

When I apply the code style to reproduce the reformat of the last commit, I get a non-trivial diff that consists entirely of empty lines after definitions. Is it possible that you have code styles set locally that are not part of the first commit?

@msfjarvis
Copy link
Member Author

When I apply the code style to reproduce the reformat of the last commit, I get a non-trivial diff that consists entirely of empty lines after definitions. Is it possible that you have code styles set locally that are not part of the first commit?

Pretty unlikely, I double checked my settings. As a test I did a manual export of the project settings and replaced the codestyle config in .idea with it. Give that a go?

@fmeum
Copy link
Member

fmeum commented May 6, 2020

Pretty unlikely, I double checked my settings. As a test I did a manual export of the project settings and replaced the codestyle config in .idea with it. Give that a go?

I think that this is caused by KEEP_* settings which make this not 100% reproducible. Maybe we should set BLANK_LINES_AFTER_CLASS_HEADER to 1 to explicitly insert a blank line after class definitions which are implicitly kept by KEEP_BLANK_LINES_IN_DECLARATIONS.

Also I think that even though KEEP_BLANK_LINES_IN_CODE is set to 0 in the checked in settings, not all empty lines in the code have been deleted, e.g.

.

@msfjarvis
Copy link
Member Author

Pretty unlikely, I double checked my settings. As a test I did a manual export of the project settings and replaced the codestyle config in .idea with it. Give that a go?

I think that this is caused by KEEP_* settings which make this not 100% reproducible. Maybe we should set BLANK_LINES_AFTER_CLASS_HEADER to 1 to explicitly insert a blank line after class definitions which are implicitly kept by KEEP_BLANK_LINES_IN_DECLARATIONS.

Also I think that even though KEEP_BLANK_LINES_IN_CODE is set to 0 in the checked in settings, not all empty lines in the code have been deleted, e.g.

.

Hmm that's wrong yeah. I'll tweak this to make it all more reproducible. Thanks for looking into it!

@msfjarvis msfjarvis force-pushed the codestyle-cleanup branch 3 times, most recently from 7579680 to 2b8efca Compare May 10, 2020 12:12
@msfjarvis msfjarvis self-assigned this May 10, 2020
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Spotless wraps around ktlint for us which has not worked with IntelliJ/Android Studio formatting
for over a year now. I am sick of waiting, so ktlint will not be making a return until that
is fixed.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
@msfjarvis msfjarvis force-pushed the codestyle-cleanup branch 2 times, most recently from a0bb1bc to ebca21d Compare May 10, 2020 12:18
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
@msfjarvis
Copy link
Member Author

Alright I *think* this is reproducible now. Wanna give it another try @FabianHenneke @Skrilltrax?

@fmeum
Copy link
Member

fmeum commented May 10, 2020

Yes, this got rid of all the KEEP_* rules.

@msfjarvis msfjarvis merged commit 041cf00 into master May 10, 2020
@msfjarvis msfjarvis deleted the codestyle-cleanup branch May 10, 2020 13:51
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.

None yet

3 participants