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

Quiet mode or ability to disable all output in Gradle #1797

Closed
TWiStErRob opened this issue Aug 1, 2019 · 6 comments
Closed

Quiet mode or ability to disable all output in Gradle #1797

TWiStErRob opened this issue Aug 1, 2019 · 6 comments
Assignees
Milestone

Comments

@TWiStErRob
Copy link
Member

Expected Behavior

No output, unless there are problems, even then potentially just a build failure!
Ideal output when no issues detekted: nothing
Ideal output when there are issues:

> Task :module:detekt
Ruleset: exceptions - 40min debt
        TooGenericExceptionCaught - [ex] at C:\dev\project\module\src\main\kotlin\net\twisterrob\project\Pipeline.kt:154:13
        TooGenericExceptionCaught - [ex] at C:\dev\project\module\src\main\kotlin\net\twisterrob\project\Listings.kt:41:12

Ruleset: style - 1h 10min debt
        MagicNumber - [provideCache] at C:\dev\project\module\src\main\kotlin\net\twisterrob\project\network\OkHttpModule.kt:31:18
        MagicNumber - [provideCacheInterceptor] at C:\dev\project\module\src\main\kotlin\net\twisterrob\project\network\OkHttpModule.kt:78:31
        MagicNumber - [provideCacheInterceptor] at C:\dev\project\module\src\main\kotlin\net\twisterrob\project\network\OkHttpModule.kt:78:61
        MagicNumber - [callFirst] at C:\dev\project\module\src\main\kotlin\net\twisterrob\project\Listing.kt:20:38
        MagicNumber - [callFirst] at C:\dev\project\module\src\main\kotlin\net\twisterrob\project\Listing.kt:20:49
        MagicNumber - [callSecond] at C:\dev\project\module\src\main\kotlin\net\twisterrob\project\Listing.kt:21:39
        MagicNumber - [callSecond] at C:\dev\project\module\src\main\kotlin\net\twisterrob\project\Listing.kt:21:50

Overall debt: 1h 50min

Successfully generated HTML report at C:\dev\project\module\build\reports\detekt\detekt.html
Successfully generated Checkstyle XML report at C:\dev\project\module\build\reports\detekt\detekt.xml
Build succeeded with 9 weighted issues (threshold defined was 10).

Note:

  • no runtime of detekt (build scan is for that)
  • no number of files (it's nice to see, but not on all executions)
  • no progress output with .......... (use Gradle worker API to report progress)
  • no ruleset header when the ruleset had no violations
  • report location shown only when there are things in it
  • tech debt should be configurable
  • weighted threshold report maybe

Current Behavior

Spamming logs even with all the config I could think of to reduce noise (and no violations):

console-reports:
  exclude:
    - 'ComplexityReport'
    - 'ProjectStatisticsReport'
    - 'NotificationReport'
    - 'FindingsReport'
    - 'BuildFailureReport'
> Task :cli:detekt
...

3 kotlin files were analyzed.
Successfully generated HTML report at C:\dev\project\cli\build\reports\detekt\detekt.html
Successfully generated Checkstyle XML report at C:\dev\project\cli\build\reports\detekt\detekt.xml

detekt finished in 1253 ms.

> Task :images:detekt
....

4 kotlin files were analyzed.
Successfully generated HTML report at C:\dev\project\images\build\reports\detekt\detekt.html
Successfully generated Checkstyle XML report at C:\dev\project\images\build\reports\detekt\detekt.xml

detekt finished in 1302 ms.

> Task :web:detekt
....

4 kotlin files were analyzed.
Successfully generated HTML report at C:\dev\project\web\build\reports\detekt\detekt.html
Successfully generated Checkstyle XML report at C:\dev\project\web\build\reports\detekt\detekt.xml

detekt finished in 1363 ms.

> Task :model:detekt
............

12 kotlin files were analyzed.
Successfully generated HTML report at C:\dev\project\model\build\reports\detekt\detekt.html
Successfully generated Checkstyle XML report at C:\dev\project\model\build\reports\detekt\detekt.xml

detekt finished in 1489 ms.

> Task :graphdb:detekt
.............

13 kotlin files were analyzed.
Successfully generated HTML report at C:\dev\project\graphdb\build\reports\detekt\detekt.html
Successfully generated Checkstyle XML report at C:\dev\project\graphdb\build\reports\detekt\detekt.xml

detekt finished in 1539 ms.

> Task :app:detekt
........................................

40 kotlin files were analyzed.
Successfully generated HTML report at C:\dev\project\app\build\reports\detekt\detekt.html
Successfully generated Checkstyle XML report at C:\dev\project\app\build\reports\detekt\detekt.xml

detekt finished in 1806 ms.

> Task :helpers:detekt
..................

18 kotlin files were analyzed.
Successfully generated HTML report at C:\dev\project\helpers\build\reports\detekt\detekt.html
Successfully generated Checkstyle XML report at C:\dev\project\helpers\build\reports\detekt\detekt.xml

detekt finished in 1058 ms.

This is even a small project, I just started writing it, imagine the same with 50+ modules.

Context

I want to reduce noise in my builds (successful build should output nothing, unless configured otherwise). If the build outputs something that must be important, otherwise I stop paying attention to any output and miss important problems/warnings. I noticed this phenomenon and call it "warning blindness". The more warnings there are the easier it is to introduce new ones.

@schalkms
Copy link
Member

schalkms commented Aug 2, 2019

True. I think the configuration should be more modular, which means putting code in newly created console-reports.
Thanks for the detailed feedback btw!

@schalkms schalkms added the core label Aug 2, 2019
@arturbosch
Copy link
Member

arturbosch commented Aug 3, 2019

One more to exclude 4 files were analyzed.

processors:
  active: true
  exclude:
    - DetektProgressListener

Missing log points for exclusion:

  • Runner L23 - println("\ndetekt finished in $time ms.")
  • OutputFacade L50 - settings.info("Successfully generated ${report.name} at $filePath")

@lwasyl
Copy link

lwasyl commented Aug 15, 2019

I see #1818 that's supposed to close this issue, but I have a question: right now when I exclude BuildFailureReport, the detekt task will finish successfully even if some violations are found. Is this the inteded behavior?

Similarly, I'm not sure the original issue is fully addressed in the PR: for example having one violation in one file right now yields:

> Task :presentation:ui:detekt
Ruleset: empty-blocks
Ruleset: exceptions
Ruleset: naming
Ruleset: performance
Ruleset: potential-bugs
Ruleset: style - 5min debt
   ExpressionBodySyntax - [something] at path

while OP (and I join) requests output similar to

Ruleset: style - 5min debt
   ExpressionBodySyntax - [something] at path

where the minimal amount of information relevant to the fail is presented. Will this change with #1818?

@arturbosch
Copy link
Member

arturbosch commented Aug 15, 2019

I see #1818 that's supposed to close this issue, but I have a question: right now when I exclude BuildFailureReport, the detekt task will finish successfully even if some violations are found. Is this the inteded behavior?

Thanks for mentioning this. I also came across this yesterday and in my opinion:
No the ConsoleReport should not decide if we should break the build.
This report should just print the yellor or red message @schalkms @3flex :)

Similarly, I'm not sure the original issue is fully addressed in the PR: for example having one violation in one file right now yields:

> Task :presentation:ui:detekt
Ruleset: empty-blocks
Ruleset: exceptions
Ruleset: naming
Ruleset: performance
Ruleset: potential-bugs
Ruleset: style - 5min debt
   ExpressionBodySyntax - [something] at path

while OP (and I join) requests output similar to

Ruleset: style - 5min debt
   ExpressionBodySyntax - [something] at path

where the minimal amount of information relevant to the fail is presented. Will this change with #1818?

I just pushed a commit to change this behavior.

@TWiStErRob
Copy link
Member Author

@lwasyl build passes with up to 10 issues (weighted) by default, you need to change that if you want zero tolerance:
https://github.com/arturbosch/detekt/blob/3c22b1b85b61cb0337248ce9d1150e6935892ee6/detekt-cli/src/main/resources/default-detekt-config.yml#L2

@TWiStErRob
Copy link
Member Author

TWiStErRob commented Aug 18, 2019

Thank you!
(#1818 and #1819 merged, https://arturbosch.github.io/detekt/howto-silent-reports.html added.)
I'll check it out along with 1.0 when I have a chance.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants