[cfe-dev] Correct .clang-tidy syntax

Alexander Kornienko alexfh at google.com
Wed Dec 3 06:09:07 PST 2014


Hi,

Thanks for reporting the problem. The example of configuration contained an
error: the braces are not needed in the indented YAML format, they only
make sense in the inline format. I've fixed the documentation page and help
message in r223235.

Also, you can always get an example of a valid configuration file
using clang-tidy
-dump-config:

$ clang-tidy -dump-config - --
---
Checks:          '-*,clang-diagnostic-*,llvm-*,misc-*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: true
User:            alexfh
CheckOptions:
  - key:
google-readability-braces-around-statements.ShortStatementLines
    value:           '1'
  - key:             google-readability-function-size.StatementThreshold
    value:           '800'
  - key:
google-readability-namespace-comments.ShortNamespaceLines
    value:           '10'
  - key:
google-readability-namespace-comments.SpacesBeforeComments
    value:           '2'
  - key:             llvm-namespace-comment.ShortNamespaceLines
    value:           '1'
  - key:             llvm-namespace-comment.SpacesBeforeComments
    value:           '1'
...

Also, if you implement the storeOptions method in your check, you can see
how your check options are represented in configuration using:

$ clang-tidy -checks=-*,your-check-name -dump-config - --



-- 
Regards,
Alex

On Wed, Dec 3, 2014 at 12:44 AM, Szabolcs Sipos <labuwx at balfug.com> wrote:

> Hi!
>
> I've been trying to use a .clang-tidy config file to pass parameters to
> my checker, but have had no success
>
> When I use the following syntax: (-> I found it here:
> http://clang.llvm.org/extra/clang-tidy.html#configuring-checks)
> CheckOptions: {
>   - key: my-check.SomeOption1
>     value: 123
>   - key: my-check.SomeOption2
>     value: 'some other value'
> }
>
> I get this error message:
> YAML:2:4: error: Unexpected token. Expected Key, Flow Entry, or Flow
> Mapping End.
>   - key: my-check.SomeOption1
>    ^
>
> I tried removing the whitespace the arrow points to -> same error,
> different location (before 123) -> whitespace removed -> a different error:
> YAML:3:10: error: Found unexpected ':' while scanning a plain scalar
>     value:123
>          ^
>
> At this point I have no idea what to do. Can you spot the error?
>
> Thanks
> --
> Szabolcs Sipos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141203/216a3777/attachment.html>


More information about the cfe-dev mailing list