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

clang-tidy config file support #9981

Closed
danielbisar opened this issue Oct 11, 2022 · 10 comments
Closed

clang-tidy config file support #9981

danielbisar opened this issue Oct 11, 2022 · 10 comments
Assignees
Labels
Feature: Code Analysis Related to integration with clang-tidy, cppcheck, cl.exe /analyze, etc. Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix
Milestone

Comments

@danielbisar
Copy link

Feature Request

clang-tidy has the option to specify a config file. This comes in very handy when working with multiple repositories.

The option is command line option --config-file=<string>.

This option currently cannot be used via the vscode extension.

@michelleangela
Copy link
Contributor

michelleangela commented Oct 11, 2022

@danielbisar
The extension has the setting C_Cpp.codeAnalysis.clangTidy.args for passing command ling arguments to the clang-tidy executable. Could you try adding the option --config-file=<string> to this setting and see if that works?

There is also the setting C_Cpp.codeAnalysis.clangTidy.config.

image

@michelleangela michelleangela added Language Service Feature: Code Analysis Related to integration with clang-tidy, cppcheck, cl.exe /analyze, etc. Feature: Configuration An issue related to configuring the extension or IntelliSense labels Oct 11, 2022
@danielbisar
Copy link
Author

@michelleangela clang-tidy config will not work.

--config=<string>              - 
                                   Specifies a configuration in YAML/JSON format:
                                     -config="{Checks: '*',
                                               CheckOptions: {x: y}}"
                                   When the value is empty, clang-tidy will
                                   attempt to find a file named .clang-tidy for
                                   each source file in its parent directories.

So in contrast to clang-format you cannot specify a filename to config file with this. (clang-format would allow file:PATH/TO/CONFIG).

Adding --config-file= to C_Cpp.codeAnalysis.clangTidy.args kind of works, but it doesn't allow environment variables to be replaced. Neither the vscode syntax ${env:VARIABLE} nor bash syntax $VARIABLE works.

@michelleangela
Copy link
Contributor

I don't think the extension has logic to parse or resolve environment variables passed to clang-tidy args. @sean-mcmanus could you confirm this? Is there a current workaround in case this is not supported in the near future?

@sean-mcmanus
Copy link
Contributor

I've added code to resolve the clangTidy.args variables: #10000 -- is that sufficient or do you want to keep this issue open to track adding a new setting?

@michelleangela michelleangela added this to the 1.13 milestone Oct 13, 2022
@danielbisar
Copy link
Author

If that allows me to use variables like in other places in vscode (https://code.visualstudio.com/docs/editor/variables-reference) this is sufficient for me.

@sean-mcmanus
Copy link
Contributor

@danielbisar It'll work for all the variable expansion mechanisms we currently support, i.e. anything that currently works with C_Cpp.codeAnalysis.clangTidy.path or "defines" or "includePath" in c_cpp_properties.json, etc. We have some open issues tracking some VS Code variables that aren't supported yet.

@sean-mcmanus sean-mcmanus modified the milestones: 1.13, 1.13.3 Oct 14, 2022
@sean-mcmanus sean-mcmanus added fixed Check the Milestone for the release in which the fix is or will be available. quick fix labels Oct 14, 2022
@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Oct 14, 2022

@danielbisar We support ${env:} and ${config:} variables and ${workspaceFolder} and ${workspaceFolderBasename}, but others in https://code.visualstudio.com/docs/editor/variables-reference may need to explicitly added. Let us know if there are any variable expansions you'd want added -- we might need to add a separate issue to track those though.

@Zingam
Copy link

Zingam commented Oct 14, 2022

I've added code to resolve the clangTidy.args variables: #10000 -- is that sufficient or do you want to keep this issue open to track adding a new setting?

I'd prefer to have a new setting. You are talking about a setting to pass a .clang-tidy configuration, right?

@sean-mcmanus
Copy link
Contributor

@Zingam Yeah, equivalent to --config-file=. I've created a new issue to track that at #10006 .

@sean-mcmanus
Copy link
Contributor

The fix is available with 1.13.3 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.3 , i.e. the ${workspaceFolder} variable is resolved. #10006 is tracking adding a new setting.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature: Code Analysis Related to integration with clang-tidy, cppcheck, cl.exe /analyze, etc. Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix
Projects
None yet
Development

No branches or pull requests

4 participants