-
Notifications
You must be signed in to change notification settings - Fork 14
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
Include code format tools #49
Conversation
code/.editorconfig
Outdated
ij_visual_guides = 120 | ||
ij_wrap_on_typing = false | ||
|
||
[*.java] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only included the configurations for Java and Kotlin as those were the only two languages I've configured. I manually removed the configs for other languages when exporting the file from Android Studio.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these mostly custom or default settings? Can we keep only the custom ones for easier maintenance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any updates on this one?
spotless { | ||
kotlin { | ||
target "src/*/java/**/*.kt" | ||
ktlint('0.41.0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to use ktlint here to format the Kotlin test app. There were minimal changes to the app files after running the formatting.
format: | ||
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) spotlessApply) | ||
(./code/gradlew -p code/$(TEST-APP-FOLDER-NAME) spotlessApply) | ||
|
||
format-check: | ||
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) spotlessCheck) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set the make targets to apply formatting to both the source code and test app, but only to check the formatting on the source code. I can add a check to the test app code as well, but I was thinking we wouldn't want to fail a build if the test app source wasn't formatted correctly. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it doesn't hurt to add the check for the test app if we anyway run the hook/format cmd on both.
|
||
jacoco { | ||
toolVersion = rootProject.ext.jacocoVersion | ||
} | ||
|
||
preBuild.dependsOn spotlessApply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will apply the formatting when the project is built. I feel this could be convenient, but as there is the pre-commit hook, if this ends up adding too much time to every build we can remove it.
Codecov Report
@@ Coverage Diff @@
## dev #49 +/- ##
==========================================
+ Coverage 79.67% 80.05% +0.38%
==========================================
Files 18 18
Lines 777 817 +40
Branches 115 124 +9
==========================================
+ Hits 619 654 +35
- Misses 114 117 +3
- Partials 44 46 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevinlind I think the changes look great overall, as I was going through the code I felt it much easier to read and more organized 👍
format: | ||
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) spotlessApply) | ||
(./code/gradlew -p code/$(TEST-APP-FOLDER-NAME) spotlessApply) | ||
|
||
format-check: | ||
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) spotlessCheck) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it doesn't hurt to add the check for the test app if we anyway run the hook/format cmd on both.
code/.editorconfig
Outdated
ij_visual_guides = 120 | ||
ij_wrap_on_typing = false | ||
|
||
[*.java] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these mostly custom or default settings? Can we keep only the custom ones for easier maintenance?
) | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one looks kind of odd for builders but looks good in the Mokito usage for example in testBootupIfReady_whenIdentityDirectRegistered_onFirstBoot_whenIdentityDirectECIDNull_generatesNew
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is much I can do here as it's how Prettier is conforming to the Google Java Code Style. The issue is really that the builder takes parameters to the constructor, so there are multiple rules being applied. The rule to close the parenthesis puts it in line with the start of the statement, however chained method calls are indented one indentation size. As you pointed out, chained calls without constructor parameters are lined up correctly.
code/edgeidentity/src/androidTest/java/com/adobe/marketing/mobile/TestHelper.java
Outdated
Show resolved
Hide resolved
code/edgeidentity/src/androidTest/java/com/adobe/marketing/mobile/TestHelper.java
Show resolved
Hide resolved
code/edgeidentity/src/androidTest/java/com/adobe/marketing/mobile/TestPersistenceHelper.java
Show resolved
Hide resolved
IdentityConstants.EventType.GENERIC_IDENTITY, | ||
IdentityConstants.EventSource.REQUEST_RESET, | ||
ListenerIdentityRequestReset.class, | ||
listenerErrorCallback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I actually like this a lot better
code/edgeidentity/src/test/java/com/adobe/marketing/mobile/edge/identity/IdentityMapTests.java
Outdated
Show resolved
Hide resolved
" ],\n" + | ||
" \"USERID\": [\n" + | ||
" {\n" + | ||
" \"id\":someUserID,\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should have been the string"someUserID"
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That isn't what it was originally, \"id\":" + "someUserID" + ",\n"
. If it was supposed to quoted, then the original string should be \"id\":" + "\"someUserID\"" + ",\n"
.
code/.editorconfig
Outdated
ij_visual_guides = 120 | ||
ij_wrap_on_typing = false | ||
|
||
[*.java] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any updates on this one?
We decided not to include the .editorconfig file for now |
Description
Includes code format tools to build system.
edgeidentity
module (Java files)app
module (Kotlin files)config/formatter/adobe.header.txt
used by Spotless to apply copyright header to all Java and Kotlin files.githook
folder with pre-commit hook to apply formatting on each commit. Includeinit
Makefile target to set git'score.hooksPath
to this folder.Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: