-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove ktlint & update detekt to 1.19.0
#16819
Conversation
…lost during merge
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
You can test the Jetpack changes on this Pull Request by downloading an installable build (jetpack-installable-build-pr16819-480d38c.apk), or scanning this QR code: |
You can test the WordPress changes on this Pull Request by downloading an installable build (wordpress-installable-build-pr16819-480d38c.apk), or scanning this QR code: |
# Conflicts: # WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/dashboard/bloggingprompts/BloggingPromptCardBuilderTest.kt
👋 @ovitrif !
Good question, since |
👋 @ovitrif !
👍 🥇 💯
Yes, let's then add them to the baseline and maybe create a few target GitHub issues to fix those as part of separate and multiple PRs, just to make sure that eventually the baseline will at least become as small as it was before this change. PS: The only other thing I can add here is that if I were you I would have split this PR into 2, one where |
👋 @ovitrif !
FYI: If you are, don't worry about this too much. As soon as this PR is reviewed and ready to be merge, I can delete this check from here, as it would not longer be necessary, and so that everything goes 🟢 ! |
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.
👋 @ovitrif !
Thank you so much for creating this PR, both on the KtLint
removal and on the Detekt Upgrade
. I have reviewed and tested this PR as per the description, everything works as expected. 👍
However, I do have a but
for you on the Detekt Upgrade
(see section below)... 🤔
Detekt Upgrade
- There are two ways of configuring
Detekt
and thedetekt.yml
file that contains the rules. For WPAndroid we are using buildUponDefaultConfig = false, which means that we totally control thedetekt.yml
file and need to update that accordingly with everyDetekt
update as well. For WCAndroid, they are using buildUponDefaultConfig = true, which means that they depend on the defaultdetekt.yml
file, per version, and then only override that default with their own configuration (see WCAndroid detekt.yml file). Both approaches have pros and cons, and for what is worth maybe us adopting WCAndroid approach will make it easier for us to updateDetekt
in the future too. Why you ask? I will connect this point with the below. - When using the
buildUponDefaultConfig = false
approach, that means that in order to updateDetekt
from one version to another, and make sure that you also respect the new rules and updates to the rules, one would need to re-generate thedetekt.yml
file and carefully apply the new changes to the diff. For example, you might want to follow a process like the below:
- Delete (or rename) the existing
detekt.yml
file. Without doing that, you won't be able to generate the newdetekt.yml
asDetekt
will note it already exists. - Run this Gradle command to generate the default
detekt.yml
file for this version (1.19.0
):./gradlew WordPress:detektGenerateConfig
- Compare the diff, enable/disable those rules/configuration that we already agreed on.
- Enable/disable any new rules/configuration that come with the new version.
- Run the Gradle command to check whether
Detekt
passes with the new rule/configuration:./gradlew WordPress:detekt
- Disable any new rules/configuration that doesn't make sense for WPAndroid.
- Fix any new issues that come from those new rules/configuration.
- To the above point and if you do it as per the mentioned process, you will notice that the updated
detekt.yml
file looks quite different to what we have now. I can share a file with you if you would like me to (since I did this work already as part of review). But, doing this work with also add new warnings that we might need to resolve and/or suppress (after disablingIndentation
which was enabled by default, I am not counting173
weighted issues). Thus, I am requesting changes to get us talking about this topic a bit more before merging this totrunk
.
Let me know about all the above and we can pair on it if you like. Or, you might want to separate KtLint
removal to the Detekt Update
work to unblock the Compose
work. There is no need to block Compose
because of Detekt Update
, especially since the change from 1.15.0
to 1.19.0
is quit long, wdyt? 🤔
@@ -114,32 +117,6 @@ allprojects { | |||
} | |||
|
|||
subprojects { |
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.
Minor (🔍): Since the subprojects
block is now empty, consider removing it altogether.
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.
Thanks 🙇
@@ -14,6 +16,7 @@ import org.wordpress.android.util.helpers.MediaFile | |||
|
|||
/* ktlint-disable max-line-length */ | |||
/* ktlint-disable parameter-list-wrapping */ |
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.
Minor (🔍): Consider removing the above two KtLint
related lines.
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.
Oh, did this change and reverted 2 times and now I forgot to remove the two comments 🤦 .
Thanks for spotting it! 🙇
Now after doing the work and learning more context about it I think it would be fine splitting it into two 👍 I wasn't sure of it while working on the PR, because I kept this thought in mind: "you have to make sure the
True on this 😺 ! |
Cool, thank you 🙇♂️ 🟢 🚀 |
👋 @ovitrif !
Great, maybe this is for the best. Then, I would suggest the following for you (if I may): 😊
Wdyt? 🤔
👍 Totally, this makes sense and I want to take half the blame on that! 😅 😊 |
Thank you @ParaskP7 for the great insight into how we're using As I mentioned here the reason for updating detekt was to be more sure that we're not losing too many checks that I also played with But if the process of regenerating the I do agree it's better to split the work into two PR-s that are concerned only with solving their own problem:
That way following the conversation will also become easier 👍 . I'll do that 🚀 |
This sounds good @ParaskP7! Thank you 🙇 |
Thank YOU @ovitrif , and for anything you might need, I'll be at your disposal ! 🚀 🥇 💯 |
Created a separate PR for handling the Ktlint removal: #16828 |
Closing this in favor of:
|
Thank you so much for all this wonderful work and preparation to kick-off work @ovitrif , you rock! ❤️ 🚀 🪨 |
Fixes #14012
Why? Ktlint is no friend of the
@Composable
annotation on parameters (see paqN3M-v8-p2), and we plan to start adopting Jetpack Compose for building UIs.📃 Changes:
coding-style
doc to suggest using detekt instead of ktlintEmptyFunctionBlock
detekt errors by using expression body (= UNIT
)MultiLineIfElse
inSubfilterPageViewModelTest
MayBeConst
detekt errorsMaxLineLength
detekt error inPostUtilsUnitTest
MySiteViewModelTest
& restore test lost during a merge1.15.0
to1.19.0
🤔 Questions:
@ParaskP7 Is this point still relevant considering we're adding the ktlint ruleset with the
detektPlugins
declaration?My understanding from two pages in the detekt docs ([formatting rules] (https://detekt.dev/docs/rules/formatting/) & adding more rule-sets) is that the rules are already included when the
detektPlugins
dependency is added 🤷♂️.Why the changes of rules names in
detekt.yml
?Apparently these have changed with the new version, it was easy enough to figure them out as there were build errors pointing to the deprecated rule names. Mostly this concerns the renames into
ignoreAnnotated
.Is it ok to add yet another 118 suppressions to the
baseline
file?I started with the idea of fixing all the errors, but they proved to be too many (e.g. most of those are one error per file, which makes the job much more time consuming.
If agreed we can continue with new suppressions in the baseline and consider fixing these rather sooner than later.
I did some exploration and I tend to agree with most of the errors outlined, ideally we'd fix them 😃 .
🧪 To test:
1.15.0
up to1.19.0
and check the migration notes against the changes to verify the migration was done correctly.issue/14012-remove-ktlint
locally./gradlew WordPress:detekt
andexpect a successful build.
config/detekt/baseline.xml
file./gradlew WordPress:detektBaseline
git status
andexpect no changes in the
detekt/baseline.xml
file.🔴 Not Ready for Merge
label.Regression Notes
Potential unintended areas of impact
N/a
What I did to test those areas of impact (or what existing automated tests I relied on)
N/a
What automated tests I added (or what prevented me from doing so)
N/a
PR submission checklist:
RELEASE-NOTES.txt
if necessary.