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

Respect RunAfterRule constraint from ktlint #6159

Merged
merged 8 commits into from
Sep 4, 2023
Merged

Conversation

chao2zhang
Copy link
Member

@chao2zhang chao2zhang commented May 27, 2023

Resolves #5259

Consulted with ktlint in pinterest/ktlint#2062, we are building a consistent sorting logic in detekt to match ktlint.

@chao2zhang chao2zhang marked this pull request as draft May 27, 2023 23:50
@codecov
Copy link

codecov bot commented May 27, 2023

Codecov Report

Patch coverage: 94.11% and project coverage change: +0.01% 🎉

Comparison is base (70fc164) 85.21% compared to head (67fc1a0) 85.23%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6159      +/-   ##
============================================
+ Coverage     85.21%   85.23%   +0.01%     
+ Complexity     4055     4051       -4     
============================================
  Files           566      565       -1     
  Lines         13252    13278      +26     
  Branches       2382     2384       +2     
============================================
+ Hits          11293    11317      +24     
- Misses          774      775       +1     
- Partials       1185     1186       +1     
Files Changed Coverage Δ
...lab/arturbosch/detekt/formatting/FormattingRule.kt 95.00% <ø> (-0.09%) ⬇️
...arturbosch/detekt/formatting/FormattingProvider.kt 98.40% <94.11%> (-1.60%) ⬇️

... and 4 files with indirect coverage changes

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

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

detekt found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.


@Test
fun `run as late as possible is observed`() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Shall we disable the test until pinterest/ktlint#2062 is merged and updated in detekt?

Copy link
Contributor

Choose a reason for hiding this comment

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

The rule sorter first runs all rules without any VisitorModifier.
The next group of rules are the rules marked with RunAsLateAsPossible.
The last group are the rules marked with RunAfter.

Should we update this PR to emulate the same mechanics as ktlint.

Copy link
Member Author

Choose a reason for hiding this comment

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

We are following the same logic in this PR, let me add some comments for posterity

@detekt-ci
Copy link
Collaborator

This PR is stale because it has been open 90 days with no activity. Please comment or this will be closed in 7 days.

@chao2zhang chao2zhang added this to the 2.0.0 milestone Sep 3, 2023
@chao2zhang chao2zhang merged commit b3b699b into main Sep 4, 2023
23 checks passed
@chao2zhang chao2zhang deleted the chao/topologysort branch September 4, 2023 16:59
mgroth0 pushed a commit to mgroth0/detekt that referenced this pull request Feb 11, 2024
* Respect `RunAfterRule` constraint from ktlint

* Fix detekt

* Suppress detekt

* Add more tests

* Implement using ktlint's algorithms

* Address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

detekt doesn't respect ktlint RunAfterRule constraints
4 participants