user4640261
user4640261

Reputation:

How to add -fix option to .clang-tidy file?

Checks: 'modernize-use-auto, modernize-use-nullptr, modernize-loop-convert'

CheckOptions:
  - key:             modernize-loop-convert.MinConfidence
    value:           safe

I have a configration file like this and want to add -fix flag to apply possible fixes but I couldn't figure out where exactly place it. Is it possible to add -fix or -fix-errors flags to .clang-tidy file?

Upvotes: 5

Views: 3948

Answers (1)

pablo285
pablo285

Reputation: 2663

-fix and -fix-errors are not check options but rather command-line options and can not be configured separately for checks. The available configuration options for .clang-tidy files are stated in the Clang-tidy documentation and the -fix option is not there:

$ clang-tidy -dump-config
---
Checks:          '-*,some-check'
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle:     none
User:            user
CheckOptions:
  - key:             some-check.SomeOption
    value:           'some value'
...

If you want to run your configuration with the -fix option enabled just add it to the command you're running clang-tidy from.

Upvotes: 6

Related Questions