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

Add a new line at the end of the txt report #2255

Merged
merged 1 commit into from
Jan 14, 2020
Merged

Add a new line at the end of the txt report #2255

merged 1 commit into from
Jan 14, 2020

Conversation

BraisGabin
Copy link
Member

This PR adds a \n at the end of the txt report. This way you can concat all the reports easily. Or you can do something like wc -l report.txt to count the number of errors that you and not be off by one

Context

This is a real minor thing but I lose 10 minutes today because of this. I was counting the errors of different branches using wc -l report.txt. And I was getting always one error less than expected. This PR will avoid that problem.

@codecov-io
Copy link

codecov-io commented Jan 13, 2020

Codecov Report

Merging #2255 into master will increase coverage by 0.18%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2255      +/-   ##
============================================
+ Coverage     81.26%   81.45%   +0.18%     
- Complexity     2101     2114      +13     
============================================
  Files           348      349       +1     
  Lines          6020     6054      +34     
  Branches       1102     1106       +4     
============================================
+ Hits           4892     4931      +39     
+ Misses          534      532       -2     
+ Partials        594      591       -3
Impacted Files Coverage Δ Complexity Δ
...itlab/arturbosch/detekt/cli/out/TxtOutputReport.kt 100% <100%> (ø) 4 <1> (ø) ⬇️
...rbosch/detekt/api/internal/CyclomaticComplexity.kt 94.33% <0%> (-0.21%) 23% <0%> (ø)
...bosch/detekt/rules/providers/StyleGuideProvider.kt 100% <0%> (ø) 3% <0%> (ø) ⬇️
...les/style/ExplicitCollectionElementAccessMethod.kt 78.12% <0%> (ø) 10% <0%> (?)
...ain/kotlin/io/gitlab/arturbosch/detekt/api/Debt.kt 100% <0%> (+6.66%) 6% <0%> (ø) ⬇️
...in/io/gitlab/arturbosch/detekt/api/SplitPattern.kt 96.29% <0%> (+11.11%) 20% <0%> (+3%) ⬆️
...ch/detekt/api/internal/ValidatableConfiguration.kt 100% <0%> (+13.63%) 0% <0%> (ø) ⬇️
...io/gitlab/arturbosch/detekt/api/RuleSetProvider.kt 100% <0%> (+28.57%) 0% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebff6aa...67ec36f. Read the comment docs.

@@ -11,6 +11,8 @@ class TxtOutputReport : OutputReport() {

override fun render(detektion: Detektion): String {
val smells = detektion.findings.flatMap { it.value }
return smells.joinToString("\n") { it.compactWithSignature() }
return smells.joinToString("\n") { it.compactWithSignature() }.let {
Copy link
Member

@schalkms schalkms Jan 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for messing around with your branch, but isn't it enough to add just one new line at the line of the file to be compliant with git?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and this is what this code does... If you mean this: smells.joinToString { it.compactWithSignature() + "\n" } it would work too(out was my first impregnation). But we are losing the performance of string builder. That would create 2k useless strings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh sorry. By looking at the test code once more, it becomes clear what this code is intended to do.
But something like this should work without introducing a new branch.

Suggested change
return smells.joinToString("\n") { it.compactWithSignature() }.let {
val builder = StringBuilder();
smells.forEach { builder.append(it.compactWithSignature()).append('\n') }
return builder.toString()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! This is easier.

Comment on lines 36 to 38
TestSmellC - [TestEntity] at TestFile.kt:1:1 - Signature=S1

""".trimIndent()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have two new lines at the end of the file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trimIndent removed the second end of line. I can use trimMargin to make it easier to understand.

@arturbosch arturbosch added this to the 1.5.0 milestone Jan 14, 2020
@BraisGabin BraisGabin requested a review from schalkms January 14, 2020 20:41
@schalkms schalkms merged commit a517db9 into detekt:master Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants