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

Move PathFilters from detekt-api to detekt-utils #6866

Merged
merged 3 commits into from May 6, 2024
Merged

Conversation

BraisGabin
Copy link
Member

@BraisGabin BraisGabin commented Jan 14, 2024

Also see #6814

We had a little mess around this class. I splitted some tests and move them to the correct locations and then move PathFilters to :detekt-tooling.

We have far too much "utils" subprojects and I'm not 100% sure the responsability of which one, but this one seems the correct one. We don't want this at :detekt-api because it is only used by :detekt-core and by :detekt-cli. And it would be really nice to move it to :detekt-core but, as I said it is also used by :detekt-cli.

If someone create some documentation about which is the responsabilities of each subproject it would be great.

Move PathFilters to :detekt-utils. This class is used on detekt-cli and detekt-core but we don't want it to be part of our public API so I'm moving it to :detekt-utils.

Waiting for #7009

Copy link

codecov bot commented Jan 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.75%. Comparing base (731735b) to head (9360ab5).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #6866   +/-   ##
=========================================
  Coverage     84.75%   84.75%           
  Complexity     3996     3996           
=========================================
  Files           577      577           
  Lines         12133    12133           
  Branches       2486     2486           
=========================================
  Hits          10283    10283           
  Misses          624      624           
  Partials       1226     1226           

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

@BraisGabin BraisGabin added the breaking change Marker for breaking changes which should be highlighted in the changelog label Jan 14, 2024
@BraisGabin BraisGabin added this to the 2.0.0 milestone Jan 14, 2024
@BraisGabin BraisGabin marked this pull request as ready for review January 16, 2024 08:52
@3flex
Copy link
Member

3flex commented Feb 28, 2024

Thinking about this, I don't think the includes/excludes belongs in detekt-tooling at all, and it makes sense to remove them from ProjectSpec. Calls to start an analysis session should include the list of files to scan, but the filtering of those should be done by whatever is calling tooling. Different clients will have different methods of filtering file lists.

As an example, the Gradle plugin doesn't pass exclude rules. It already filters and just sends the file list to the CLI. I think it makes more sense to move the path filters to CLI, and remove includes/excludes from tooling and bring everything up a level.

What do you think?

@BraisGabin
Copy link
Member Author

BraisGabin commented Feb 28, 2024

What do you think?

That you are completely right. I'm moving this PR to draft to block it and I'll create another PR removing includes/excludes from ProjectSpec. Then I'll go back to this PR and see if it still have sense or not.

I like to move logic from rules to core. And then from core to clients. The rules and the core are complex enough already.

@BraisGabin
Copy link
Member Author

I rebased this on top of #7009.

Now instead of moving PathFilters to detekt-tooling I move it to detekt-utils. We still use PathFilters on detetk-cli and detekt-core but now it is not part of any API, it is just an implementation detail.

I'm not a big fan of detekt-utils but it is handy to share code between parts of detekt without making it public API.

@BraisGabin BraisGabin changed the title Move PathFilters from detekt-api to detekt-tooling Move PathFilters from detekt-api to detekt-utils Apr 6, 2024
Base automatically changed from remove-dead-code-2 to main April 6, 2024 22:48
@BraisGabin BraisGabin marked this pull request as ready for review April 6, 2024 22:50
@BraisGabin
Copy link
Member Author

BraisGabin commented May 5, 2024

This PR changed a bit since the last review. @3flex can you take a look again? I see two options here.

  1. This PR (move to detekt-utils).
  2. Move the code to core and duplicate it on the cli.

Neither of those seems like a bad idea to me.

@3flex
Copy link
Member

3flex commented May 6, 2024

I'm not a big fan of detekt-utils but it is handy to share code between parts of detekt without making it public API.

Completely agree - it's useful though unless someone comes up with a better idea. LGTM after merge conflict is addressed.

@BraisGabin BraisGabin enabled auto-merge (squash) May 6, 2024 11:39
@BraisGabin BraisGabin merged commit 60b2413 into main May 6, 2024
21 checks passed
@BraisGabin BraisGabin deleted the move-path-filters branch May 6, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api breaking change Marker for breaking changes which should be highlighted in the changelog build cli core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants