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 ConsoleReport format #4027

Merged
merged 5 commits into from
Sep 28, 2021
Merged

Conversation

chao2zhang
Copy link
Member

@chao2zhang chao2zhang commented Aug 9, 2021

This addresses #3423.

This new consoleReport will be turned off by default. For comparison, I will list the console report from other tools below:

Existing FindingsReport

> Task :detekt-generator:detekt FAILED
style - 50min debt
        MagicNumber - [getArgument] at /Users/cazhang/detekt/detekt-generator/src/main/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleVisitor.kt:158:57
        MaxLineLength - [<anonymous>] at /Users/cazhang/detekt/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt:427:21
        MaxLineLength - [<anonymous>] at /Users/cazhang/detekt/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt:440:21
        MaxLineLength - [<anonymous>] at /Users/cazhang/detekt/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt:453:21
        MaxLineLength - [<anonymous>] at /Users/cazhang/detekt/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt:465:21
        MaxLineLength - [code] at /Users/cazhang/detekt/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt:527:1
        MaxLineLength - [code] at /Users/cazhang/detekt/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt:529:1
        MaxLineLength - [code] at /Users/cazhang/detekt/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt:606:1
        MaxLineLength - [code] at /Users/cazhang/detekt/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt:608:1

New LiteFindingsReport

/Users/cazhang/detekt/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/reporting/console/ReadableFindingsReport.kt:29:46: Missing spacing after "{" [SpacingAroundCurly]
/Users/cazhang/detekt/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/reporting/console/ReadableFindingsReport.kt:20:24: Missing newline after "(" [Indentation]
/Users/cazhang/detekt/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/reporting/console/ReadableFindingsReport.kt:25:17: Missing newline before ")" [Indentation]
/Users/cazhang/detekt/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/reporting/console/ReadableFindingsReport.kt:22:35: Missing newline after "(" [Indentation]
/Users/cazhang/detekt/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/reporting/console/ReadableFindingsReport.kt:26:28: Missing newline after "(" [Indentation]
/Users/cazhang/detekt/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/reporting/console/ReadableFindingsReport.kt:27:1: Unexpected indentation (12) (should be 16) [Indentation]

Checkstyle

[ant:checkstyle] [ERROR] /Users/cazhang/myrepo/messaging/MessagingRoutes.java:29: 'import' has more than 1 empty lines before. [EmptyLineSeparator]
[ant:checkstyle] [ERROR] /Users/cazhang/myrepo/messaging/MessagingRoutes.java:38:52: Use a single space to separate non-whitespace characters. [SingleSpaceSeparator]

Ktlint

/Users/cazhang/ktlint/ktlint-reporter-json/src/main/kotlin/com/pinterest/ktlint/reporter/json/JsonReporter.kt:13:30: Unexpected spacing after "("
/Users/cazhang/ktlint/ktlint-reporter-json/src/main/kotlin/com/pinterest/ktlint/reporter/json/JsonReporter.kt:13:31: Unnecessary space(s)

Kotlinc

w: /Users/cazhang/ktlint/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/NoWildcardImportsRule.kt: (8, 1): Visibility must be specified in explicit API mode
w: /Users/cazhang/ktlint/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/ParameterListWrappingRule.kt: (30, 1): Visibility must be specified in explicit API mode
w: /Users/cazhang/ktlint/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/ParameterListWrappingRule.kt: (125, 41): Name shadowed: adjustedIndent

@codecov
Copy link

codecov bot commented Aug 9, 2021

Codecov Report

Merging #4027 (cc13bf6) into main (cbdb460) will not change coverage.
The diff coverage is 100.00%.

❗ Current head cc13bf6 differs from pull request most recent head c565616. Consider uploading reports for the commit c565616 to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##               main    #4027   +/-   ##
=========================================
  Coverage     83.51%   83.51%           
+ Complexity     3186     3185    -1     
=========================================
  Files           461      463    +2     
  Lines          9095     9095           
  Branches       1768     1767    -1     
=========================================
  Hits           7596     7596           
  Misses          570      570           
  Partials        929      929           
Impacted Files Coverage Δ
...t/generator/printer/defaultconfig/ConfigPrinter.kt 92.10% <ø> (ø)
...tlab/arturbosch/detekt/core/reporting/Reporting.kt 94.11% <100.00%> (ø)
...t/core/reporting/console/AbstractFindingsReport.kt 100.00% <100.00%> (ø)
.../core/reporting/console/FileBasedFindingsReport.kt 100.00% <100.00%> (ø)
...ch/detekt/core/reporting/console/FindingsReport.kt 100.00% <100.00%> (ø)
...etekt/core/reporting/console/LiteFindingsReport.kt 100.00% <100.00%> (ø)

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 cbdb460...c565616. Read the comment docs.

Copy link
Member

@BraisGabin BraisGabin left a comment

Choose a reason for hiding this comment

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

I think that this should be the one turned on by default.

@chao2zhang chao2zhang marked this pull request as ready for review August 9, 2021 18:17
@chao2zhang chao2zhang changed the title [RFC] Add a new ConsoleReport format Add a new ConsoleReport format Aug 9, 2021
Copy link
Contributor

@marschwar marschwar left a comment

Choose a reason for hiding this comment

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

Other than the name I really like this. The name seems to imply that all others are unreadable. Maybe something like LinePerFindingReport ?

@cortinico
Copy link
Member

The name seems to imply that all others are unreadable

Agree. How about somethine like LiteFindingsReport or CompactFindingsReport?

Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Great work 👍

* Contains a clear read of the console report, where each line contains location, messages and issue id.
* See: https://detekt.github.io/detekt/configurations.html#console-reports
*/
class ReadableFindingsReport : ConsoleReport() {
Copy link
Member

Choose a reason for hiding this comment

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

Could we refactor FindingsReport and this class to a single hierarchy? Apparently the difference is just the (Map<String, List<Finding>>) -> String function that they're invoking.

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't call this ReadableFindingsReport. Is the other FindingsReport not readable? I would prefer to call it ConciseFindingsReport.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the name to LiteFindingsReport as suggested above.

@chao2zhang chao2zhang added this to the 1.19.0 milestone Aug 15, 2021
@chao2zhang chao2zhang merged commit 72d7e4f into detekt:main Sep 28, 2021
@cortinico cortinico added the notable changes Marker for notable changes in the changelog label Sep 30, 2021
@chao2zhang chao2zhang deleted the consolereport branch November 1, 2022 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notable changes Marker for notable changes in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants