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

ANDROID-11179 detekt implementation #386

Merged

Conversation

jmanriquehiberus
Copy link
Contributor

@jmanriquehiberus jmanriquehiberus commented Sep 18, 2024

🎟️ Jira ticket

ANDROID-11179

πŸ₯… What's the goal?

We need to implement detekt.

🚧 How do we do it?

mistica-android/detekt-baseline.xml
Some custom code smells added so detekt can spot them (taken from android-messenger).

mistica-android/build-tools/detekt/detekt.yml
Custom definition of detekt's behaviour.

mistica-android/build-tools/detekt.gradle
Gradle file, applied from the project's build.gradle in order to override gradle's detekt.

I also fixed 57 detekt issues, most of them are fixed in atomic commits in order to ease the review. Still, there are 39 issues to be addressed which are suppressed by now. I will create now some jira tickets to tackle them.

πŸ§ͺ How can I test this?

Run the command ./gradlew detekt in order to run the task, modify detekt.yml and see that those new changes affect the output of the task.

@jmanriquehiberus
Copy link
Contributor Author

Should we include detekt in any of our GAs?

@jmanriquehiberus jmanriquehiberus requested review from a team, dpastor and juangardi21 and removed request for a team September 18, 2024 15:38
Copy link

πŸ“± New catalog for testing generated: Download

Copy link
Contributor

@juangardi21 juangardi21 left a comment

Choose a reason for hiding this comment

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

LGTM, just one suggestion πŸ‘πŸΌ

buildUponDefaultConfig = true
config = files("$projectDir/build-tools/detekt/detekt.yml")
input = files("$projectDir")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You could exclude some folders like:

    source.from(fileTree(rootProject.projectDir) {
        exclude("**/.gradle/")
        exclude("**/build/")
        exclude("**/tmp/**")
    })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, just did it, thanks ☺️

Copy link

πŸ“± New catalog for testing generated: Download

@jmanriquehiberus jmanriquehiberus self-assigned this Sep 19, 2024
@@ -0,0 +1,12 @@

detekt {
Copy link
Contributor

Choose a reason for hiding this comment

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

No files to adapt in mistica after adding detekt? Did you check this is executed with the ./gradlew check command? (which is the one executed on preintegration GA)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, there are 96 issues to address after running detekt.

I am sorry but could not find any preintegration GA in mistica, should there be or should we include detekt in any GA? πŸ€”

Copy link
Contributor

Choose a reason for hiding this comment

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

It's the tests.yml file, the checks which are run on each PR commit, detekt should run as part of them.

Normally, when invoking "check" gradle target (executed on that GA), detekt is also executed with just applying the plugin, but please check it just to ensure it.

Copy link
Contributor

Choose a reason for hiding this comment

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

In order to add detekt we need to also fix the current issues repository has (or ignoring them someway to do that work afterwards), if it's too complicated, please check with the team how to proceed on next weekly or by chat (I'm on vacations next week).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. By now, I have addressed 53 issues and still have 43 to be fixed (most of them related to long functions or too complex functions). I will address simpler issues alone and will keep potentially troublesome ones to be tackled along with the team.

Copy link

πŸ“± New catalog for testing generated: Download

Copy link

πŸ“± New catalog for testing generated: Download

Copy link

πŸ“± New catalog for testing generated: Download

Copy link

πŸ“± New catalog for testing generated: Download

@jmanriquehiberus jmanriquehiberus requested review from jeprubio and removed request for a team September 24, 2024 08:48
Copy link
Contributor

@jeprubio jeprubio left a comment

Choose a reason for hiding this comment

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

πŸ‘

build.gradle Outdated
Comment on lines 51 to 56
tasks.withType(io.gitlab.arturbosch.detekt.Detekt).all {
exclude("build/")
exclude("**/build/**")
exclude("**/resources/**")
exclude("**/tmp/**")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

these are also in detekt.gradle ΒΏare they needed in both places? ΒΏPerhaps if this is here the ones from detekt.gradle are not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, just committed a code cleanup. Thanks!

Comment on lines 1 to 8
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>WildcardImport:protect_android_task.gradle.kts$import java.io.*</ID>
<ID>WildcardImport:protect_android_task.gradle.kts$import java.lang.*</ID>
</CurrentIssues>
</SmellBaseline>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could either fix these imports or use @Supress* in that files in order not to need this baseline. I fear we'll fix this at some point and forget to remove the baseline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not have to fix any issues here, it was my bad. Thanks for spotting it.

Thinking it twice, it makes no sense to have an empty detekt-baseline.xml file for now, so I am deleting it.

Copy link

πŸ“± New catalog for testing generated: Download

Copy link

πŸ“± New catalog for testing generated: Download

Copy link
Contributor

@juangardi21 juangardi21 left a comment

Choose a reason for hiding this comment

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

Awesome

…nrique/ANDROID-11179-enable-detekt-in-mistica-android

# Conflicts:
#	README.md
Copy link

πŸ“± New catalog for testing generated: Download

Copy link

πŸ“± New catalog for testing generated: Download

@nimeacuerdo nimeacuerdo requested review from jeslat and removed request for dpastor September 24, 2024 13:40
@nimeacuerdo
Copy link
Contributor

nimeacuerdo commented Sep 24, 2024

Breaking changes that require a new major release? if so I would expect updates in https://github.com/Telefonica/mistica-android/blob/jmanrique/ANDROID-11179-enable-detekt-in-mistica-android/UPGRADING.md

Any ticket created to tackle pending issues?

@jmanriquehiberus
Copy link
Contributor Author

Breaking changes that require a new major release? if so I would expect updates in https://github.com/Telefonica/mistica-android/blob/jmanrique/ANDROID-11179-enable-detekt-in-mistica-android/UPGRADING.md

Any ticket created to tackle pending issues?

I have just created these 3 tickets to tackle pending issues.

I have a doubt about this being a major release. I would say this is a minor one, since there are no breaking changes (I think), it is just adding new functionality (detekt) which is backward compatible. What am I missing?

@nimeacuerdo
Copy link
Contributor

nimeacuerdo commented Sep 24, 2024

Breaking changes that require a new major release? if so I would expect updates in https://github.com/Telefonica/mistica-android/blob/jmanrique/ANDROID-11179-enable-detekt-in-mistica-android/UPGRADING.md
Any ticket created to tackle pending issues?

I have just created these 3 tickets to tackle pending issues.

I have a doubt about this being a major release. I would say this is a minor one, since there are no breaking changes (I think), it is just adding new functionality (detekt) which is backward compatible. What am I missing?

Thanks for creating those tickets!

what about this https://github.com/Telefonica/mistica-android/pull/386/files#diff-16c7f6781a03c2127c9cfd4b50a25cd8ad71e464e4848fccbcc9a823e44f73bdL222-R222?

@jmanriquehiberus
Copy link
Contributor Author

Breaking changes that require a new major release? if so I would expect updates in https://github.com/Telefonica/mistica-android/blob/jmanrique/ANDROID-11179-enable-detekt-in-mistica-android/UPGRADING.md
Any ticket created to tackle pending issues?

I have just created these 3 tickets to tackle pending issues.

I have a doubt about this being a major release. I would say this is a minor one, since there are no breaking changes (I think), it is just adding new functionality (detekt) which is backward compatible. What am I missing?

Thanks for creating those tickets!

what about this https://github.com/Telefonica/mistica-android/pull/386/files#diff-16c7f6781a03c2127c9cfd4b50a25cd8ad71e464e4848fccbcc9a823e44f73bdL222-R222?

Sorry, thanks!! I did not know that was a breaking change, I am adding it to https://github.com/Telefonica/mistica-android/blob/jmanrique/ANDROID-11179-enable-detekt-in-mistica-android/UPGRADING.md as you mentioned.

@@ -50,6 +50,7 @@ fun Buttons() {
}

@Composable
@Suppress("LongMethod")
Copy link
Contributor

Choose a reason for hiding this comment

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

I would include an ignore to not take into account the composables as we do in platform:

  LongMethod:
    ignoreAnnotated: 'Composable'

In general, most of the composables will throw the long method error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, I have just included the ignore you mentioned and there are only 2 LongMethod flagged non composable functions. Thank you!!!

@jeslat
Copy link
Contributor

jeslat commented Sep 24, 2024

Breaking changes that require a new major release? if so I would expect updates in https://github.com/Telefonica/mistica-android/blob/jmanrique/ANDROID-11179-enable-detekt-in-mistica-android/UPGRADING.md
Any ticket created to tackle pending issues?

I have just created these 3 tickets to tackle pending issues.

I have a doubt about this being a major release. I would say this is a minor one, since there are no breaking changes (I think), it is just adding new functionality (detekt) which is backward compatible. What am I missing?

Thanks for creating those tickets!
what about this https://github.com/Telefonica/mistica-android/pull/386/files#diff-16c7f6781a03c2127c9cfd4b50a25cd8ad71e464e4848fccbcc9a823e44f73bdL222-R222?

Sorry, thanks!! I did not know that was a breaking change, I am adding it to https://github.com/Telefonica/mistica-android/blob/jmanrique/ANDROID-11179-enable-detekt-in-mistica-android/UPGRADING.md as you mentioned.

@jmanriquehiberus as it's explained in that document, now the breaking changes are explained in the release notes of the new version, in this case 15.0.0. You have an example here https://github.com/Telefonica/mistica-android/releases/tag/14.0.0

@jmanriquehiberus
Copy link
Contributor Author

Breaking changes that require a new major release? if so I would expect updates in https://github.com/Telefonica/mistica-android/blob/jmanrique/ANDROID-11179-enable-detekt-in-mistica-android/UPGRADING.md
Any ticket created to tackle pending issues?

I have just created these 3 tickets to tackle pending issues.

I have a doubt about this being a major release. I would say this is a minor one, since there are no breaking changes (I think), it is just adding new functionality (detekt) which is backward compatible. What am I missing?

Thanks for creating those tickets!
what about this https://github.com/Telefonica/mistica-android/pull/386/files#diff-16c7f6781a03c2127c9cfd4b50a25cd8ad71e464e4848fccbcc9a823e44f73bdL222-R222?

Sorry, thanks!! I did not know that was a breaking change, I am adding it to https://github.com/Telefonica/mistica-android/blob/jmanrique/ANDROID-11179-enable-detekt-in-mistica-android/UPGRADING.md as you mentioned.

@jmanriquehiberus as it's explained in that document, now the breaking changes are explained in the release notes of the new version, in this case 15.0.0. You have an example here https://github.com/Telefonica/mistica-android/releases/tag/14.0.0

Thank you!

Copy link
Contributor

@jeslat jeslat left a comment

Choose a reason for hiding this comment

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

Thanks, good job!

Copy link

πŸ“± New catalog for testing generated: Download

@jmanriquehiberus jmanriquehiberus removed the request for review from dpastor September 24, 2024 15:57
@jmanriquehiberus jmanriquehiberus merged commit 4d44396 into main Sep 24, 2024
5 checks passed
@jmanriquehiberus jmanriquehiberus deleted the jmanrique/ANDROID-11179-enable-detekt-in-mistica-android branch September 24, 2024 15:57
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.

6 participants