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

Adds Detekt rules for Compose. Updates detekt to 1.23.6. #1822

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

JayShortway
Copy link
Member

@JayShortway JayShortway commented Aug 22, 2024

Motivation

Compose has many footguns that are easy to forget. (Think state restoration, remembering, modifier parameters, viewmodel forwarding.) It's unrealistic to expect everyone to always remember all of these. These Detekt rules help to avoid these issues a lot, in my experience. Static checks also ease the pressure on code reviews to spot these issues.

You can find a description of the rules here. They were originally developed at Twitter (1.0), and are currently maintained by the engineer who started the project. Slack is maintaining the Lint version of these same rules.

Note: the Detekt IntelliJ plugin doesn't show violations of these rules (running via Gradle / CI does). For that we'd need to point it to a 66 Mb plugin jar file, which is probably a bad idea to add to the repo. We can do something fancy with Gradle to download it automatically, but that's less of a quick win than just adding the rules. So I figured we can do that later.

@JayShortway JayShortway added build pr:dependencies Changes on external dependencies labels Aug 22, 2024
@JayShortway JayShortway self-assigned this Aug 22, 2024
@JayShortway JayShortway changed the title Adds detekt rules for Compose. Updates detekt to 1.23.6. Adds Detekt rules for Compose. Updates detekt to 1.23.6. Aug 22, 2024
@JayShortway JayShortway marked this pull request as ready for review August 22, 2024 11:46
@JayShortway JayShortway requested a review from a team August 22, 2024 11:46
Copy link

codecov bot commented Aug 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.78%. Comparing base (09444eb) to head (915a5a5).
Report is 20 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1822   +/-   ##
=======================================
  Coverage   82.78%   82.78%           
=======================================
  Files         222      222           
  Lines        7680     7680           
  Branches     1081     1081           
=======================================
  Hits         6358     6358           
  Misses        899      899           
  Partials      423      423           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jamesrb1 jamesrb1 left a comment

Choose a reason for hiding this comment

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

Excellent

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

Haven't used this set of rules, but I think they make sense! I'm afraid of having the smells in the baseline will make us forget it... But I think at least it enables us to fix things moving forward 👍

@JayShortway
Copy link
Member Author

JayShortway commented Aug 23, 2024

@tonidero I was debating that in my mind as well. In the end I figured that if we want to fix the smells before adding these rules, it'd be a while before we reap the benefits. Maybe we add tickets or something, to tackle 1 offended rule at a time from the baseline?

@tonidero
Copy link
Contributor

I think that makes sense yeah. I wouldn't consider it a priority, but we can dedicate some time if we have some downtime

@JayShortway JayShortway merged commit 968e870 into main Aug 23, 2024
9 checks passed
@JayShortway JayShortway deleted the detekt-rules-compose branch August 23, 2024 12:42
tonidero pushed a commit that referenced this pull request Aug 29, 2024
**This is an automatic release.**

### New Features
* Paywalls can use custom in-app purchase/restore code (#1777) via James
Borthwick (@jamesrb1)
### Bugfixes
* [Paywalls] Add spacing between paragraphs and make text go full width
so text align applies (#1824) via Josh Holtz (@joshdholtz)
### Dependency Updates
* Bump rexml from 3.3.4 to 3.3.6 (#1823) via dependabot[bot]
(@dependabot[bot])
* Bump fastlane-plugin-revenuecat_internal from `4c4b8ce` to `85e1c83`
(#1812) via dependabot[bot] (@dependabot[bot])
* Adds Detekt rules for Compose. Updates detekt to 1.23.6. (#1822) via
JayShortway (@JayShortway)
### Other Changes
* Converts MagicWeather's Gradle files to Kotlin (#1821) via JayShortway
(@JayShortway)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
@vegaro vegaro added pr:other and removed pr:build labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:dependencies Changes on external dependencies pr:other
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants