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

Detekt #6038

Merged
merged 22 commits into from
May 13, 2022
Merged

Detekt #6038

merged 22 commits into from
May 13, 2022

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented May 12, 2022

Let the CI fails first!

Now the CI should not fail.

This PR setup detekt and fix a few issues detected by detekt.

Some rule have been disabled temporarily, to avoid having too many changes.

Change on generated analytics file has been reported in matrix-org/matrix-analytics-events#62

@github-actions
Copy link

github-actions bot commented May 12, 2022

Unit Test Results

0 files   - 122  0 suites   - 122   0s ⏱️ - 2m 8s
0 tests  - 205  0 ✔️  - 205  0 💤 ±0  0 ±0 
0 runs   - 690  0 ✔️  - 690  0 💤 ±0  0 ±0 

Results for commit a312115. ± Comparison against base commit 3f8ddbe.

This pull request removes 205 tests.
im.vector.app.features.analytics.impl.DefaultVectorAnalyticsTest ‑ given lateinit user properties when valid analytics id updates then identify with lateinit properties
im.vector.app.features.analytics.impl.DefaultVectorAnalyticsTest ‑ given user consent when tracking events then submits to posthog
im.vector.app.features.analytics.impl.DefaultVectorAnalyticsTest ‑ given user consent when tracking screen events then submits to posthog
im.vector.app.features.analytics.impl.DefaultVectorAnalyticsTest ‑ given user has not consented when tracking events then does not track
im.vector.app.features.analytics.impl.DefaultVectorAnalyticsTest ‑ given user has not consented when tracking screen events then does not track
im.vector.app.features.analytics.impl.DefaultVectorAnalyticsTest ‑ when consenting to analytics then updates posthog opt out to false
im.vector.app.features.analytics.impl.DefaultVectorAnalyticsTest ‑ when revoking consent to analytics then updates posthog opt out to true
im.vector.app.features.analytics.impl.DefaultVectorAnalyticsTest ‑ when setting the analytics id then updates analytics store
im.vector.app.features.analytics.impl.DefaultVectorAnalyticsTest ‑ when setting user consent then updates analytics store
im.vector.app.features.analytics.impl.DefaultVectorAnalyticsTest ‑ when signing out then resets posthog
…

♻️ This comment has been updated with latest results.

@bmarty bmarty requested review from a team, yostyle and ganfra and removed request for a team May 12, 2022 20:59
@bmarty bmarty marked this pull request as ready for review May 12, 2022 21:00
@bmarty bmarty requested a review from ouchadam May 12, 2022 21:00
build.gradle Outdated
// preconfigure defaults
buildUponDefaultConfig = true
// activate all available (even unstable) rules.
allRules = false
Copy link
Contributor

@ouchadam ouchadam May 13, 2022

Choose a reason for hiding this comment

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

we can generate a baseline if we want to enable more rules without having to fix them straight away https://detekt.dev/docs/introduction/baseline/

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, thanks, I have seen that. Good to prevent new issues. I would prefer to enable the disabled rules one by one and fix the existing issues though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have set this value to true and the output is the same.


performance:
SpreadOperator:
active: false
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't mind enabling this for production code but it can be handy to be able to use them in tests

@ouchadam
Copy link
Contributor

detekt can be quite quick to run, on previous projects I've included it as part of the prebuild tasks to trigger detekt to run on every compile (makes the feedback loop super quick)

// module build.gradle
preBuild.dependsOn(project.tasks.getByName("detekt"))

@bmarty
Copy link
Member Author

bmarty commented May 13, 2022

Detekt can also analyses documentation issues 🎉 , but this is disabled by default. I was looking for such tools when setting up Dokka!

To add to the file detekt.yml:

comments:
  OutdatedDocumentation:
    active: true
  UndocumentedPublicClass:
    active: true
  UndocumentedPublicFunction:
    active: true
  UndocumentedPublicProperty:
    active: true

I will probably add those rules in the file now, but disabled by default, so that it can be handled in dedicated PRs (there are many issues :/). The top priority one will be OutdatedDocumentation

@bmarty
Copy link
Member Author

bmarty commented May 13, 2022

detekt can be quite quick to run, on previous projects I've included it as part of the prebuild tasks to trigger detekt to run on every compile (makes the feedback loop super quick)

// module build.gradle
preBuild.dependsOn(project.tasks.getByName("detekt"))

It can be painful when developing to be blocked by for instance a temporary unused private fun (even if this specific rule is disabled now).

On the other side, it's painful to not see the error locally, but only after the CI checks.

We could have some check_code_before_creating_pr.sh which will run all that can be run locally and will be anyway run by the CI. I'm thinking about compiling android tests, run ktlint, run detekt, etc. WDYT?

@ouchadam
Copy link
Contributor

ouchadam commented May 13, 2022

We could have some check_code_before_creating_pr.sh which will run all that can be run locally and will be anyway run by the CI. I'm thinking about compiling android tests, run ktlint, run detekt, etc. WDYT?

having a script to run all our tools detekt, ktlint and the other code quality script would be helpful
there's already a check that causes the build to fail for unused variables 🤔 (which I agree can be quite annoying during development)

@bmarty bmarty enabled auto-merge May 13, 2022 15:34
@bmarty bmarty disabled auto-merge May 13, 2022 21:40
@bmarty bmarty merged commit 9234c60 into develop May 13, 2022
@bmarty bmarty deleted the feature/bma/detekt branch May 13, 2022 21:40
@github-actions
Copy link

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
    = passed=15 failures=5 errors=0 skipped=3
  • [org.matrix.android.sdk.account]
    = passed=3 failures=0 errors=0 skipped=2
  • [org.matrix.android.sdk.internal]
    = passed=5 failures=1 errors=0 skipped=0
  • [org.matrix.android.sdk.ordering]
    = passed=16 failures=0 errors=0 skipped=0
  • [org.matrix.android.sdk.PermalinkParserTest]
    = passed=2 failures=0 errors=0 skipped=0

@bmarty bmarty mentioned this pull request May 16, 2022
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.

2 participants