Skip to content

Enable "--config-file" flag for clang-tidy #4186

@stevenengland

Description

@stevenengland

What kind of issue is this?

  • [ x] Feature Request.
    Start by telling us what problem you’re trying to solve. Often a solution
    already exists! Don’t send pull requests to implement new features without first getting our
    support. Sometimes we leave features out on purpose to keep the project small.

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system: Win10

PlatformIO Version (platformio --version): latest

Description of problem

As a developer I would like to tell clang-tidy to use an external config file to keep my configs clean. Especially when handling multiple clang-tidy checks the code looks messy if I am forced to use the clangtidy extra flag --checks= for that purpose.
Instead it would be great to use a config file that is made of yaml like this:

---
Checks:              '-*,some-check'
WarningsAsErrors:    ''
HeaderFilterRegex:   ''
FormatStyle:         none
InheritParentConfig: true
User:                user
CheckOptions:
  - key:             some-check.SomeOption
    value:           'some value'
...

CLang Tidy comes with a flag --config-file for that scenario (see clang-tidy --help, it is not documented on the websites). Its help text is: "Specify the path of .clang-tidy or custom config file: e.g. --config-file=/some/path/myTidyConfigFile This option internally works exactly the same way as --config option after reading specified config file. Use either --config-file or --config, not both."

Actually it is not possible to use this flag because at least the Checks part is overriden due to the logic in https://github.com/platformio/platformio-core/blob/4839fe37a3d1433737c80147ce9a205100dc4925/platformio/commands/check/tools/clangtidy.py:

if not self.is_flag_set("--checks", flags):
            cmd.append("--checks=*")

Additional info

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions