How to configure clang-tidy checks using InspectCode Command-Line Tool
I am running inspectcode.exe against a solution file. I have put .editorconfig in the root and this seems to be picking up checks. I have set checks for function size warning from clang-tidy: https://clang.llvm.org/extra/clang-tidy/checks/readability/function-size.html
# Resharper inspectcode settings
[*]
resharper_cpp_clang_tidy_readability_function_size_highlighting=warning
resharper_cpp_clang_tidy_google_readability_function_size_highlighting=warning
I am not getting any warnings from my code. I am trying to set the threshold using a .clang-tidy file in the root:
---
Checks: '-*,readability-function-size'
CheckOptions:
- key: readability-function-size.LineThreshold
value: 100This config is not being picked up. How do I set the parameters for clang-tidy checks when running InspectCode Command-Line Tool?
Please sign in to leave a comment.
Turns out I was wrong and the settings in
.clang-tidyare respected by clang-tidy checks done in inspectcode.exe. You don't get the full details, e.g. forreadability-function-size.LineThresholdhow long the function actually was that exceeded the function length limit, but it raises a warning nevertheless. Clang-tidy checks done by Visual Studio do output this information.Hello David,
Could you please elaborate how Visual Studio outputs this additional information? In the VS editor I only see the main message, not the additional notes.
It's true that some clang-tidy checks output additional notes which R# does not show. I've filed a feature request - RSCPP-34840
Thanks!
Hi Igor,
I ran the checks in CI, using MSBuild:
EnableClangTidyCodeAnalysiselement into the projectvcxprojXML file before running analysis, using a customRunClangTidyconditionmsbuild /p:RunCodeAnalysis=true /p:PreferredToolArchitecture=x64 /p:RunClangTidy=true /p:Configuration=Release /p:Platform=x86 -m $projectto run analysis on the project\Release\<project>.ClangTidy.log.The
<project>.ClangTidy.logfile is not XML which is a pain, but it does contain entries with additional information like:This additional information like the actual size of the function is useful for targeting where to start.
Running InspectCode.exe I get an XML report, but only contains initial info, no indication of what threshold was breached and by how much, like this:
Just clarifying I meant clang-tidy checks done via Project Properties > Code Analysis > Clang-Tidy, not via Resharper.
Thanks! Yes, I see VS indeed does print the notes to the log. I don't think R#'s inspect code supports printing additional information apart from the message. But then these notes might also be beneficial when they're included into the message in the editor. We'll consider how this can be implemented.
I don't know if it's worth necro'ing this post but I have the same problem with Inspect Code 2025.3.1. This is for C++ projects.
If I run clang-tidy analysis on msbuild, it'll respect .clang-tidy in my repository root:
msbuild /p:RunCodeAnalysis=true /p:EnableClangTidyCodeAnalysis=true .\SubDir\MyProject.vcxprojIf I use
inspectcode.exeit's ignored:inspectcode.exe .\SubDir\MyProject.vcxprojInspect Code will run and output a report, but for a whole lot of checks I don't want and none of the ones I do want that I've specified in
.clang-tidy. I tried using a.DotSettingsfile but that's ignored as well..clang-tidy:Checks: '-*,readability-function-size,readability-function-cognitive-complexity'CheckOptions:- key: readability-function-cognitive-complexity.Thresholdvalue: 25- key: readability-function-size.LineThresholdvalue: 100- key: readability-function-size.NestingThresholdvalue: 5InspectCode.DotSettings, it'll read this file with--settings, because inspectcode will complain if it's missing when--settingsis used:ReSharper still does not support reading enabled checks from .clang-tidy if this file is present. The tracking issue is RSCPP-30593, we'll try to get to it in 2026.