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

Running formatting checks without formatting the code on CI #159

Closed
PavelSynek opened this issue Jul 5, 2017 · 6 comments
Closed

Running formatting checks without formatting the code on CI #159

PavelSynek opened this issue Jul 5, 2017 · 6 comments

Comments

@PavelSynek
Copy link

We would like to run detekt on our CI with all checks, including formatting. The problem is that we don't want to actually reformat code on CI, just fail the build if there are any errors. But if we run detektFormat with autoCorrect: false, it prints format errors, but doesn't fail the build.

Is it possible to either add formatting checks to detektCheck or make detektFormat fail the build (possibly enabled by some flag) if there are any formatting errors?

@arturbosch
Copy link
Member

arturbosch commented Jul 6, 2017

So you already running detektFormat on CI and it does not format code (like you want it?), but formatting should also fail the build?

How do your build settings look like ? I turned off formatting weights in the build failure check, try turning it on

build:
  warningThreshold: 5
  failThreshold: 10
  weights:
    complexity: 2
    formatting: 0
    LongParameterList: 1
    comments: 0.5

@PavelSynek
Copy link
Author

This is our current detekt.yml

autoCorrect: false

build:
  warningThreshold: 1
  failThreshold: 1

potential-bugs:
  active: true
  LateinitUsage:
    active: false

exceptions:
  active: true

empty-blocks:
  active: true

complexity:
  active: true

code-smell:
  active: true

formatting:
  active: true
  useTabs: true

style:
  active: true

comments:
  active: true
  UndocumentedPublicClass:
    active: false
  UndocumentedPublicFunction:
    active: false

We simply want a way to fail the build if the code isn't formatted properly. We've tried increasing weight for formatting, but weights apply only for detektCheck task which doesn't run formatting.

@arturbosch
Copy link
Member

Ah I see, shouldn't be so hard to add. Will try to add this to next release.

@arturbosch
Copy link
Member

Ok fixed. After the last two PR are merged, I will release a new version.

@arturbosch arturbosch modified the milestone: M13 Jul 9, 2017
@PavelSynek
Copy link
Author

Great, thanks!

@lock
Copy link

lock bot commented Jun 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 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

2 participants