Conversation
Codecov Report
@@ Coverage Diff @@
## master #3319 +/- ##
============================================
- Coverage 80.28% 80.24% -0.05%
- Complexity 2714 2721 +7
============================================
Files 445 445
Lines 8196 8240 +44
Branches 1558 1564 +6
============================================
+ Hits 6580 6612 +32
- Misses 778 785 +7
- Partials 838 843 +5
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
I quickly skimmed through the code. The PR looks good to me.
Thanks for picking this up. Relative paths are a highly requested detekt feature.
I'm contemplating about adding more end-to-end tests in this area of detekt, since you also mentioned that you've done manual tests (thanks btw). For regression purposes it definitely makes sense. Could some of those manual tests be automated?
detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/internal/PathFilters.kt
Show resolved
Hide resolved
detekt-report-txt/src/test/kotlin/io/github/detekt/report/txt/TxtOutputReportSpec.kt
Outdated
Show resolved
Hide resolved
detekt-report-xml/src/test/kotlin/io/github/detekt/report/xml/XmlOutputFormatSpec.kt
Outdated
Show resolved
Hide resolved
detekt-report-xml/src/test/kotlin/io/github/detekt/report/xml/XmlOutputFormatSpec.kt
Outdated
Show resolved
Hide resolved
detekt-report-xml/src/test/kotlin/io/github/detekt/report/xml/XmlOutputFormatSpec.kt
Outdated
Show resolved
Hide resolved
detekt-report-xml/src/test/kotlin/io/github/detekt/report/xml/XmlOutputFormatSpec.kt
Outdated
Show resolved
Hide resolved
detekt-report-xml/src/test/kotlin/io/github/detekt/report/xml/XmlOutputFormatSpec.kt
Outdated
Show resolved
Hide resolved
detekt-report-xml/src/test/kotlin/io/github/detekt/report/xml/XmlOutputFormatSpec.kt
Outdated
Show resolved
Hide resolved
detekt-cli/src/main/kotlin/io/gitlab/arturbosch/detekt/cli/CliArgs.kt
Outdated
Show resolved
Hide resolved
This PR definitely added some integration tests in However, if you indicate end-to-end tests, I only see In my mind, such end-to-end tests should be a separate module or repo that applies detekt gradle plugin, runs against some kotlin code with violations, and validates the error can be reported. This does not exist today but I definitely can help sparkle the discussion |
Yes, I definitely meant end-to-end tests. Thanks for the hint. End-to-end tests are a separate topic and as you mentioned outside of the scope for this PR. |
BraisGabin
left a comment
There was a problem hiding this comment.
🤔 I didn't have time to tests it but if you add the workingDir the console report keeps reporting the absolute path. Right?
And, should we wait to merge #3320 before merging this? To ensure that we don't break compatibity.
| } | ||
|
|
||
| val ktFile = KtCompiler().compile(input, input) | ||
| val ktFile = KtCompiler().compile(null, input) |
There was a problem hiding this comment.
🤔 couldn't we get the base path from the CliArgs?
There was a problem hiding this comment.
Is AstPrinter considered as output? It sounds like yes, please confirm :)
There was a problem hiding this comment.
Yes, this command prints a file's psi tree.
There was a problem hiding this comment.
On second thought, this seems to conflict with #3319 (comment). AstPrinter also outputs to console.
detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/DetektPlugin.kt
Outdated
Show resolved
Hide resolved
detekt-report-xml/src/test/kotlin/io/github/detekt/report/xml/XmlOutputFormatSpec.kt
Show resolved
Hide resolved
detekt-psi-utils/src/main/kotlin/io/github/detekt/psi/KtFiles.kt
Outdated
Show resolved
Hide resolved
0dad660 to
986ea57
Compare
|
Apologize for the numerous force-push. I was debugging a CI failure that is not reproducible on local. |
|
There is a new problem that I encountered in this PR. A) In #3319 (comment), we are suggested to set the default relative path base to the project source dir So to unblock this PR, we can fix any one of the steps listed here: Among all the options, Apologize for the long response. I am seeking thoughts from all the maintainers, especially @BraisGabin since A) is per his request. |
It sounds like we are on the same page. What I probably need to do next is to prototype #3324. Since that would be impacting future changes and testing for detekt-gradle-plugin. |
4d656c7 to
5e55162
Compare
BraisGabin
left a comment
There was a problem hiding this comment.
This is good to go for me. My last concern (sorry the PR is big and each time I review it I realiced different things) is the cli flag name: --report-base-path. Right now we use the relative paths just for reporting but this feature is not just about that so, maybe, we could rename it to something more generic as --base-path. What do you think? Any way, this is not a blocking topic.
detekt-cli/src/main/kotlin/io/gitlab/arturbosch/detekt/cli/CliArgs.kt
Outdated
Show resolved
Hide resolved
detekt-gradle-plugin/src/test/kotlin/io/gitlab/arturbosch/detekt/DetektTaskDslTest.kt
Outdated
Show resolved
Hide resolved
I don't know other use cases of base path. The input paths can be both absolute and relative based on |
Posted in our slack channel: https://kotlinlang.slack.com/archives/C88E12QH4/p1609854726084000?thread_ts=1609854726.084000&cid=C88E12QH4 A user asking exactly for this feature and it's not related with the reports. So, probably, we should rename the flag. |
That user was me 😀 To clarify, I need to write a custom rule that checks for a project's naming conventions based on the relative path of source files, where the base is the Gradle root project directory. So my assumption would be that after this PR is merged, a call to the Is my assumption / expectation about the goal of this PR correct? |
|
Yes, your expectations are correct. You will need one extra line of configuration in your gradle because of this #3319 (comment) (it will be implemented in later PR). But you would be able to get the relative path using a extension function over the KtFile. |
* Support relative output paths * Enrich test spec description and add KDoc * Update documentation * Refactor FilePath * Fix CI failures * Fix detekt failures and restore defaults as absolute * Renamed report base path back to base path
This addresses #2492 and a part of #3045.
Out of scope items
Implementation
The implementation was done by putting the relative path and base path as user data of
KtFile.OutputReports read them through the paths stored inLocation.Test
In addition to adding tests in Spek, I also perform manual tests with a local repository.