Adds issue details to findings on FindingsReport and FileBasedFindingsReporter#4464
Conversation
|
Thanks for the PR @gfreivasc 👍 Shouldn't we just extend |
Codecov Report
@@ Coverage Diff @@
## main #4464 +/- ##
=========================================
Coverage 84.12% 84.12%
Complexity 3310 3310
=========================================
Files 477 477
Lines 10916 10926 +10
Branches 2027 2029 +2
=========================================
+ Hits 9183 9192 +9
Misses 700 700
- Partials 1033 1034 +1
Continue to review full report at Codecov.
|
|
While I personally don't think that's too much trouble, I see that If you think we're good to make those changes to Edit: Just in case we would move forward changing |
|
I agree with @cortinico. I also vote to change
Yes, I think that it would be good to keep both aligned. |
1b5f523 to
954e741
Compare
|
Changed the PR so now it changes |
f9c737f to
21c1de3
Compare
BraisGabin
left a comment
There was a problem hiding this comment.
I never understand why compact is part of the Finding api... I think that we should deprecate it. But that's another topic.
|
@gfreivasc Can you update the PR title to reflect the current diff? |
|
@cortinico changed the message |
21c1de3 to
0a9dd93
Compare
|
@cortinico Had to fix tests from modules I had not run the tests for. They're all passing now. |
| NoUnusedImports - [] at /user/home/detekt/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/DetektPlugin.kt:10:1 - Signature=io.gitlab.arturbosch.detekt.DetektPlugin.kt:10 | ||
| NoConsecutiveBlankLines - [] at /user/home/detekt/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/DetektPlugin.kt:86:1 - Signature=io.gitlab.arturbosch.detekt.DetektPlugin.kt:86 | ||
| UnusedPrivateMember - [registerDetektJvmTasks] at /user/home/detekt/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/DetektPlugin.kt:17:5 - Signature=DetektPlugin.kt$DetektPlugin$private fun Project.registerDetektJvmTasks(extension: DetektExtension) | ||
| EmptyFunctionBlock - [This empty block of code can be removed.] at /user/home/detekt/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/DetektPlugin.kt:14:42 - Signature=DetektPlugin.kt$DetektPlugin${ } |
There was a problem hiding this comment.
One last question: are there scenario where this text can either:
- Be too long
- Contain
\n?
Askign as if so, we should escape it as it would screw up the final reporting.
There was a problem hiding this comment.
As far as I'm aware of, there's no checks or anything to prevent these to be the case. These scenarios could also affect LiteFindingsReport. We could run a replace .replace('\n', ' ') for the second case but I can't think of what could be done in the first one. Truncate and ellipsis? What could be a threshold?
There was a problem hiding this comment.
Truncate and ellipsis? What could be a threshold?\
I think it's something we can address should we face it. Ideally Truncate and ellipsis sounds like a decent way to clean this up, but it's something we can follow-up on.
EDIT: Just noticed you implemented it 👍 We can fine tune it if needed
BraisGabin
left a comment
There was a problem hiding this comment.
I approved this PR because I thought that the only report using compact() was FindingsReport but I just saw that it also affect the file reports so I don't think we should change the return of compact(). We should find another way to implement this.
| TestSmellC - [TestEntity] at TestFile.kt:1:1 - Signature=TestEntitySignature | ||
| TestSmellA - [TestMessage] at TestFile.kt:1:1 - Signature=TestEntitySignature | ||
| TestSmellB - [TestMessage] at TestFile.kt:1:1 - Signature=TestEntitySignature | ||
| TestSmellC - [TestMessage] at TestFile.kt:1:1 - Signature=TestEntitySignature |
There was a problem hiding this comment.
I'm not sure if we should change the txt output too... I'm fine adding behaviour changes in the console report. But I don't feel that confortable changing the file reports. People can be using those structures and have their own parsers so we should keep those.
I changed my mind for the previous reason
|
@BraisGabin your comment makes total sense and I should've found another approach rather than applying these changes elsewhere. Addressed them in the last commit. Will work on the other suggestions yet today. I also found that I'm changing code on the |
|
Could we don't change |
59c6151 to
fcdc20e
Compare
|
So in your opinion we should fallback to having a simple extension method similar to the one we had with the previous iteration of fun Findings.detailed() = when (this) {
is ThresholdedCodeSmell -> "$id - $metric - [${messageOrDescription()}] at ${location.compact()}"
else -> "$id - [${messageOrDescription()}] at ${location.compact()}"
}This would eliminate API impact. |
ede8fa2 to
df3244d
Compare
| private fun Finding.truncatedMessage(): String { | ||
| val message = messageOrDescription() | ||
| .replace(Regex("\\s+"), " ") | ||
| .trim() | ||
| return when { | ||
| message.length > REPORT_MESSAGE_SIZE_LIMIT -> "${message.take(REPORT_MESSAGE_SIZE_LIMIT)}($ellipsis)" | ||
| else -> message | ||
| } | ||
| } |
There was a problem hiding this comment.
@cortinico I applied this treatment to handle the scenarios you've raised. As seen above, I've loosely set REPORT_MESSAGE_SIZE_LIMIT to be 80. There is a test that validates both truncation and space characters (\n, \r, \t, ...).
df3244d to
1b14c2e
Compare
I was thinking about fun Findings.detailed() = "$id - [${messageOrDescription()}] at ${location.compact()}"
}But sure, the |
|
About |
Achieved different levels of detailing by changing the format in the implementation of compact() method for CodeSmell and ThresholdedCodeSmell.
Reverts changes to `CodeSmell::compact` method to keep other reports untouched.
1b14c2e to
1746b57
Compare
Prevents line breaks and long messages from breaking report structure
1746b57 to
b6bee2b
Compare
|
Fixed conflicts related to jUnit 5 migration |
cortinico
left a comment
There was a problem hiding this comment.
Change looks go to me 👍 Thanks for doing that. Are we good to merge?
Addresses #4463
Changes
FindingsReportto print with the current structure, but withmessageOrDescription() + location.compact()instead ofentity.compact()as the message gives more details and usually also mentions the entity. It tries to combine that layout with the degree of information found onLiteFindingsReport.Message changes also apply to
FileBasedFindingsReporter.Example
LiteFindingsReportCurrent
FindingsReportModified
FindingsReportObservations
These changes make it so that
Entity::compact()method is no longer called internally. I chose to keep it as it's published API.