You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be possible to configure the detekt tasks in such a way as they can be cached in CI or one machine and then get a cache hit on another machine where the code lives under a different path while not breaking any functionality.
Observed Behavior
It is not possible to use the gradle remote cache without breaking the basePath functionality since the base path, at least from the documentation, takes an absolute path which will differ on different machines which will then result in different task cache keys and therefore cache misses.
Steps to Reproduce
Run detekt on two machines where the module has different paths on the file system. If you have the gradle remote cache enabled, you will notice that there is a cache miss and different cache keys for the two runs due ti the different basePath values.
The only way I've found to make it work is to pass "" as the basePath, but then we get non-relativized paths in the generated reports.
Context
It's nice to allow developers and CI builds to leverage a shared cache.
Your Environment
Version of detekt used: 1.23.6
Version of Gradle used: 8.7
Gradle scan link (add --scan option when running the gradle task):
Operating System and version:
Link to your project (if it's a public repository):
The text was updated successfully, but these errors were encountered:
I think that to be able to implement this we will need #6879.
With that we could split the task in two. One with the analysis (that is the heavy part) and it should be cacheable and another(s) task(s) with the report creation. That last one would not be cacheable because it would depend on the absolute path but it should be a really fast.
What are your thoughts of accepting a relative path (relative to the module path)?
Then the implementation would do something like:
fileWithIssues.absolutePath.stripPrefix(File(projectDir.absolutePath, baseDir).absolutePath)
I imagine that's the usual use-case and would allow everything to be cacheable.
Alternatively, I think this could be solved by accepting a File instead of a string and marking it with @PathSensitive(PathSensitivity.NAME_ONLY). I would hope gradle would then relativize the input and make the outputs relocatable.
Here's my concrete proposal that should be mostly backwards compatible:
accept the directory of the project projectRootPath as an input with @PathSensitive(PathSensitivity.NAME_ONLY) defaulting to the current dir by convention
if basePath does not start with a "/", assume it is relative and then get the base path using File(projectRootPath, basePath)
You might need to use some level of canonicalPath or absolutePath on the base path and detected file locations
if basePath starts with a '/', assume it is the absolute path and just use that as you do today
Expected Behavior
It should be possible to configure the detekt tasks in such a way as they can be cached in CI or one machine and then get a cache hit on another machine where the code lives under a different path while not breaking any functionality.
Observed Behavior
It is not possible to use the gradle remote cache without breaking the basePath functionality since the base path, at least from the documentation, takes an absolute path which will differ on different machines which will then result in different task cache keys and therefore cache misses.
Steps to Reproduce
Run detekt on two machines where the module has different paths on the file system. If you have the gradle remote cache enabled, you will notice that there is a cache miss and different cache keys for the two runs due ti the different basePath values.
The only way I've found to make it work is to pass "" as the basePath, but then we get non-relativized paths in the generated reports.
Context
It's nice to allow developers and CI builds to leverage a shared cache.
Your Environment
--scan
option when running the gradle task):The text was updated successfully, but these errors were encountered: