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

Baseline incomplete if project located in "test" directory. #3728

Closed
ethauvin opened this issue May 1, 2021 · 8 comments · Fixed by #6330
Closed

Baseline incomplete if project located in "test" directory. #3728

ethauvin opened this issue May 1, 2021 · 8 comments · Fixed by #6330

Comments

@ethauvin
Copy link

ethauvin commented May 1, 2021

Expected Behavior

baseline.xml is complete.

Observed Behavior

baseline.xml is incomplete.

Steps to Reproduce

mkdir foo
cd foo
git clone https://github.com/ethauvin/mobibot.git
cd mobibot
git checkout 0.8
./gradlew detektBaseline
git status -s

No change, baseline.xml is correct.

mkdir test
cd test
git clone https://github.com/ethauvin/mobibot.git
cd mobibot
git checkout 0.8
./gradlew detektBaseline
git status -s
   M config/detekt/baseline.xml

baseline.xml is incorrect, incomplete.

Context

Took me forever to figure this one out. It made no sense. The baseline was incorrect on my machine and correct on any other machine I tried (CIs, etc.) until I realized that it was correct if I used another account on the same machine. After a thorough process of elimination (Gradle, Java, and Kotlin caches/configurations, etc.), the project's directory name turned out to be the culprit. Note that when the project is in a test directory, the detekt task will not fail even though the baseline is incomplete.

Your Environment

  • Version of detekt used: 1.14.0, 1.15.0, 1.16.0, 1.7.0-RC1, main-SNAPSHOT
  • Version of Gradle used (if applicable): 7.0
  • Operating System and version: Ubuntu 20.04.2
  • Link to your project (if it's a public repository): https://github.com/ethauvin/mobibot
@cortinico
Copy link
Member

Version of detekt used: 1.17.0-RC1 / main-SNAPSHOT

Version 1.17.0-RC1 is sadly broken (see #3729). We're working on getting RC2 out soon.
Please try with 1.16.0 and update the issue if it's still happening or not.

@ethauvin
Copy link
Author

ethauvin commented May 2, 2021

Version 1.17.0-RC1 is sadly broken (see #3729). We're working on getting RC2 out soon.
Please try with 1.16.0 and update the issue if it's still happening or not.

It happens with 1.16.0 thru the current snapshot.

@ethauvin
Copy link
Author

ethauvin commented May 2, 2021

@cortinico Happens with 1.14.0 and 1.15.0 too. I've updated the issue accordingly.

@BraisGabin
Copy link
Member

I see what's going on here. The exclude works on the absolute path. Instead of the relative path. So it exludes all the files from a lot of rules. We should fix our exclusion code to use relative paths if they are available. And we should probably show a warning if they are not.

@cortinico
Copy link
Member

The exclude works on the absolute path. Instead of the relative path. So it exludes all the files from a lot of rules. We should fix our exclusion code to use relative paths if they are available. And we should probably show a warning if they are not.

Can you elaborate? Are you talking about the exclude inside the config or the one from the Gradle Plugin

@BraisGabin
Copy link
Member

The problem is the base path. For example, if you store your project in /home/test/myproject (because your user is called test) all the rules with exclude **/test/** will exclude ALL the files. If we have the information about the relative path we should use it instead of the absolute path to avoid this problem.

We will have the same problem if your package is something similar as com.test.myproject. But that's a different issue.

@github-actions
Copy link

github-actions bot commented Nov 4, 2021

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

@github-actions github-actions bot added the stale label Nov 4, 2021
@BraisGabin BraisGabin removed the stale label Nov 5, 2021
@github-actions
Copy link

github-actions bot commented Feb 4, 2022

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

@github-actions github-actions bot added the stale label Feb 4, 2022
3flex added a commit to 3flex/detekt that referenced this issue Jul 29, 2023
3flex added a commit to 3flex/detekt that referenced this issue Jul 29, 2023
@3flex 3flex self-assigned this Jul 30, 2023
@3flex 3flex removed the help wanted label Jul 30, 2023
3flex added a commit that referenced this issue Aug 3, 2023
* Require basePath when setting up environment

This is a prerequisite for fixing #3728

* Apply path filters based on relative paths when possible
@3flex 3flex removed their assignment Aug 3, 2023
mgroth0 pushed a commit to mgroth0/detekt that referenced this issue Feb 11, 2024
* Require basePath when setting up environment

This is a prerequisite for fixing detekt#3728

* Apply path filters based on relative paths when possible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants