Code Monkey home page Code Monkey logo

vscode-clang-tidy's Introduction

Hi! I'm Jacob Stearns


LinkedIn Gmail

  • πŸŽ“ Current: B.S. CS degree at Colorado State University (2022-current)
  • πŸ“œ Finished: A.S. CS degree at Finger Lakes Community College (2020-2022)
  • πŸŽ‰ Graduating December 2024
  • 🌎 Upstate New York, EST timezone

πŸŽ“ Interesting Courses - Current


Colorado State University

  • CS 454 - Principles of Programming Languages
  • CS 310H - Design Thinking Toolbox: Mixed Reality Design

πŸŽ“ Interesting Courses - Finished


Colorado State University

  • CS 445 - Introduction to Compiler Construction
  • CS 455 - Introduction to Distributed Systems
  • CS 445 - Introduction to Machine Learning
  • CS 430 - Database Systems

Finger Lakes Community College

  • CSC 260 - Networking Technologies
  • CSC 273 - Ethical Hacking

βœ… Skills


πŸ“Š GitHub Stats


vscode-clang-tidy's People

Contributors

dependabot[bot] avatar dmeister avatar knehez avatar notskm avatar relder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vscode-clang-tidy's Issues

module 'std' not found clang-tidy(clang-diagnostic-error)

Hi Friends,
I am using clang-tidy in vscode in a c++20 project. but clang-tidy does not recognize modules.

import std;

Generates:

module 'std' not found clang-tidy(clang-diagnostic-error)

The build system is cmake 3.22

CMAKE_CXX_FLAGS:  -stdlib=libc++ -fuse-ld=lld -fno-builtin -fmodules -fbuiltin-module-map -Wno-unused-command-line-argument -Wall -Wextra -Wpedantic -Wmove -Wdangling

CMAKE_EXPORT_COMPILE_COMMANDS: ON
// settings.json
"clang-tidy.buildPath": "build",

My environment is Linux Mint 19.3
Compiler clang-13

Everything else works: clang, clangd, code completion, etc...

Is c++20 supported by current clang-tidy version?

➜  ~ clang-tidy --version
Ubuntu LLVM version 13.0.1
  
  Optimized build.
  Default target: x86_64-pc-linux-gnu
  Host CPU: skylake

clang-tidy.checks example

Could you give an example of how to add or suppress clang-tidy checks in settings.json? The specific check I would like to add is implicit-function-declaration and I would like to suppress errors with not finding headers. I am already using cpptools. Thanks.

Support for compile_commands.json

The clangd extension supports specifying a compile_commands.json file which specifies the compiler arguments that are used to build each source file. The system that vscode-clang-tidy uses of requiring the user to specify a single set of arguments for the whole project doesn't work for projects where the arguments vary from file to file, or directory to directory at least. Could compile_commands.json support be added at some point? :-)

Add excludeCompilerArgs setting

My project uses gcc-specific flags in compile_commands.json and I get following error:

unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'?clang-tidy(clang-diagnostic-unknown-warning-option

Maybe it would be nice to exclude any unknown for clang flag.

Errors from included file shown as part of parsed file

Description
When parsing clang-tidy output for .cpp files, the extension doesn't distinguish errors from included files and shows them as part of linted/opened file.

Consider two files main.hpp and main.cpp. The main.hpp includes non-existing included.hpp and clang-tidy shows the error properly:

image

But now if I'll open main.cpp I'll see the same error at an unexpected place:

image

Expected behavior
The extension needs to filter out errors not related to an opened file.

Support .clang-tidy configuration file

Add the ability for the extension to locate a .clang-tidy configuration file within the project parent folder and lint according to it, instead of inserting a list in the setting.json file for the "checks".

Only one file is linted when changing settings.json

When you change the extension's settings, all open files are re-linted. #16 ensures that only one instance of clang-tidy ever runs at a time. This breaks the re-linting process. If multiple files are open, it tries to spawn an instance of clang-tidy for each file. Only the last gets linted because each other instance of clang-tidy is killed.

Config option "Build Path" passes double quote as argument

I have a cmake project that has a build directory, and added build as the Build Path. Inside the output I see that the plugin runs clang-tidy with -p="build" with the quotation marks, and from the look of it, clang-tidy sees the quotation marks and is therefore unable to find a directory named "build".
If I run the same line in terminal, it would generate a set of fixes in standard out; however the plugin output produces errors.
Plugin output:

> clang-tidy /path/to/project/src/history.cpp --export-fixes=- -p="build"
Working Directory: /path/to/project
/path/to/project/src/history.cpp:1:10: error: 'history.hpp' file not found [clang-diagnostic-error]
#include "history.hpp"
         ^
---
MainSourceFile:  '/path/to/project/src/history.cpp'
Diagnostics:
  - DiagnosticName:  clang-diagnostic-error
    DiagnosticMessage:
      Message:         '''history.hpp'' file not found'
      FilePath:        '/path/to/project/src/history.cpp'
      FileOffset:      9
      Replacements:    []
...

Error while trying to load a compilation database:
Could not auto-detect compilation database from directory ""build""
No compilation database found in /path/to/project/"build" or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
1 error generated.
Error while processing /path/to/project/src/history.cpp.
Found compiler error(s).

Feature Request: New command - fix file

Currently clang-tidy only comes with one command: lint file - that lints currently opened file.

It would be great if a new command fix file is added to fix issues.

Currently, fixing clang-tidy warning is only available via FixOnSave option. But turning this option will result in unwanted fix & cause delay before saving. So i personally don't want it to be turned on.

Quick Fix Issues

  • Quick Fix suggestions should be removed after a fix is applied
  • Quick Fixes should be removed while linting

My experiences with vscode clang-tidy in Windows are:

1-firstly you need clang-tidy.exe(completely working is what come with clion.)
others are not work: msys2 , official, qt creator.
Actually it's work what come with qt creator but it gives less information than clion.

2-settings.json should be:
{
"cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json",

"clang-tidy.executable":
     "C:/Program Files/JetBrains/CLion 201.6073.20/bin/clang/win/clang-tidy.exe",
"clang-tidy.compilerArgsBefore":
      ["-Wall","-Wextra"],
"clang-tidy.checks": 
      [
    "google-*",
    "cppcoreguidelines-*",
    "modernize-*",
    "performance-*"
     ]

}

3-Bug Fix:
you must convert source path seperators from \ to / in command from compile_commands.json

from

"command": "C:\msys64\mingw64\bin\g++.exe -g -o CMakeFiles\demo.dir\main.cpp.obj -c C:\Users\x64\vscodeProjects\demo\main.cpp",

to

"command": "C:\msys64\mingw64\bin\g++.exe -g -o CMakeFiles\demo.dir\main.cpp.obj -c C:/Users/x64/vscodeProjects/demo/main.cpp",

Support Clang-Tidy command line arguments

There is not a way to pass command line arguments to Clang-Tidy.

For example:
When building using CMake, the compiler_commands.json file is not placed in the project root, but under the build/ folder, You direct Clang-Tidy to look in that location by passing the argument -p build/.

clang-tidy.buildPath not working

I am struggling getting the clang-tidy.buildPath to work. When used like this:

"clang-tidy.buildPath": "build/linux-release"

I get the error No compilation database found in [...absolute workspace path...]/"build/linux-release" or any parent directory. I think the issue is the superfluous " before "build. How can I get rid of this?

Thank you!

regular expression

In source code file tidy.ts,I can not understand line 175,What is this regular expression searching for?

const yamlIndex = clangTidyOutput.search(/^---$/m);

Does it search for three consecutive β€˜-’ ? why?

Feature Request: fix on save

I want to fix auto fixable clang-tidy's checks on save if "editor.formatOnSave" is true or "clang-tidy.autoFixOnSave" (setting name is tentative) is true.

LLVM 10.0.1-rc1 crash

 #0 0x00007ff766140256 C:\Program Files\LLVM\bin\clang-tidy.exe 0x3c0256 (C:\Program Files\LLVM\bin\clang-tidy.exe+0x3c0256)
 #1 0x00007ff766140256 
 #2 0x00007ff766140256 (C:\Program Files\LLVM\bin\clang-tidy.exe+0x3c0256)
 #3 0x00007ffb20aacb7d (C:\Windows\System32\ucrtbase.dll+0x6cb7d)
 #4 0x00007ffb20aadb81 (C:\Windows\System32\ucrtbase.dll+0x6db81)
 #5 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fca526 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fcb189
 #6 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fcb292 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a86681
 #7 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a80e5c C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a80e5c
 #8 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a81937 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a5c52b
 #9 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a2bf6c C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a90a76
#10 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a2c46f C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a81979
#11 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a5c52b C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a2bf6c
#12 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a90a76 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1a2c46f
#13 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x71ee94 C:\Program Files\LLVM\bin\clang-tidy.exe 0x71f97a
#14 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x72164b C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fa0f73
#15 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fc40ab C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fa044b
#16 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fa7643 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fa433f
#17 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fa764e C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fa1417
#18 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fa764e C:\Program Files\LLVM\bin\clang-tidy.exe 0x1fa3a91
#19 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x1f80cf8 C:\Program Files\LLVM\bin\clang-tidy.exe 0xccab7c
#20 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0xe56c83 C:\Program Files\LLVM\bin\clang-tidy.exe 0xccfe35
#21 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0xcb805c C:\Program Files\LLVM\bin\clang-tidy.exe 0x3e8230
#22 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x4071b4 C:\Program Files\LLVM\bin\clang-tidy.exe 0x3e80f0
#23 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x3e760e C:\Program Files\LLVM\bin\clang-tidy.exe 0x3e9905
#24 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x4028f0 C:\Program Files\LLVM\bin\clang-tidy.exe 0x3184
#25 0x00007ffb20aaf505 C:\Program Files\LLVM\bin\clang-tidy.exe 0x205ead4 (C:\Windows\System32\ucrtbase.dll+0x6f505)
#26 0x00007ffb20aaf505 
#27 0x00007ffb20aaf505 (C:\Windows\System32\ucrtbase.dll+0x6f505)
0x00007FF766140256 (0x0000610B32A3F2D3 0x0000000000000000 0x0000000000000016 0x0000000000000000)
0x00007FFB20AACB7D (0x0000000000000001 0x00007FF700000000 0x0000000000000000 0x000000D08838B2A0), raise() + 0x1DD bytes(s)
0x00007FFB20AADB81 (0x00007FFB00000003 0x00007FFB00000003 0x00007FF768CE9654 0x00007FF768CE9588), abort() + 0x31 bytes(s)
0x00007FFB20AAF505 (0x00000000000000B6 0x00007FF768CE9654 0x0000000000000079 0x0000000000000000), _get_wpgmptr() + 0x18B5 bytes(s)
0x00007FFB20AAF841 (0x00007FF767DE2184 0x000001FD57DEE598 0x000001FD582961F0 0x00007FFB20A52596), _wassert() + 0x71 bytes(s)
0x00007FF767D4A526 (0x000000D08838B448 0x00007FF767D47D7A 0x000001FD56DCF9BA 0x000001FD54D74F90)
0x00007FF767D4B189 (0x0000000000000002 0x0000000000000020 0x0000000000000016 0x0000000000000019)
0x00007FF767D4B292 (0x00000000000002D0 0x000001FD54E40CC0 0x000001FD54D40000 0x0000000000000000)
0x00007FF767806681 (0x000000D000000000 0x000001FD00000000 0x00000F7400011087 0x00007FF7677AC760)
0x00007FF767800E5C (0x000000D08838BA01 0x0000000000000000 0x000000D000000000 0x00000000804F44CD)
0x00007FF767800E5C (0x000000D0FFFFFFFF 0x0000005954504D45 0x000001FD54DC6260 0x0000000000000005)
0x00007FF767801937 (0x000001FD56DCF982 0x00007FF7677CCA39 0x000000D08838BE48 0x00007FF7677AC755)
0x00007FF7677DC52B (0x000001FD56DCF982 0x004F44A200000001 0x000001FD804F453D 0x00000004804F4538)
0x00007FF7677ABF6C (0x000000D000000000 0x000001FD00000000 0x00000F5B00011087 0x00007FF7677AC760)
0x00007FF767810A76 (0x000001FD00000002 0x0000DAD5129260E9 0x000000D08838C598 0x000001FD54DC6260)
0x00007FF7677AC46F (0x00000000FFFFFFFF 0x0000005954504D45 0x000000D08838C0E0 0x0000000000000005)
0x00007FF767801979 (0x0000000000000210 0x000000D08838C279 0x000000000002000C 0x00007FFB22AFC43F)
0x00007FF7677DC52B (0x0000000000000230 0x000000D08838C3B9 0x000001FD54D40000 0x00007FFB22AFB997)
0x00007FF7677ABF6C (0x0000000000000002 0x0000000000000048 0x000001FD54DC6260 0x000000D08838C598)
0x00007FF767810A76 (0x0000DAD512921B89 0x000001FD569FD460 0x000001FD569FD430 0x000000D08838C598)
0x00007FF7677AC46F (0x0000000000010585 0x000000D08838C5D0 0x000000D08838C888 0x00007FF766188E13)
0x00007FF76649EE94 (0x000000D08838CBD0 0x0000000000000000 0x000001FD5800BC60 0x000001FD54DCE770)
0x00007FF76649F97A (0x0000000000000070 0x000001FD54E40CC0 0x00000000039D00DF 0x0000000000000000)
0x00007FF7664A164B (0x000001FD599FD5A0 0x000001FD599EF290 0x000001FD599FD5A0 0x00007FF7661D99EC)
0x00007FF767D20F73 (0x000001FD599E9E20 0x00007FFB22AFFB91 0x000000D08838D0E0 0x0000010054D40000)
0x00007FF767D440AB (0x000001FD5800B834 0x00007FF700000000 0x000000D08838D160 0x000000D08838D5D0)
0x00007FF767D2044B (0x000000D08838D150 0x0000000100000001 0x000000D000000001 0x000001FD56E65D70)
0x00007FF767D27643 (0x0000000000000000 0x000001FD58AB4010 0x000001FD58ACE8E0 0x000000D08838D5D0)
0x00007FF767D2433F (0x000001FD58ACF830 0x00007FFB22AFFB91 0x000000D08838D3C0 0x0000010054D40000)
0x00007FF767D2764E (0x0000000000000000 0x000001FD57EF17B0 0x000001FD57EF5390 0x000000D08838D5D0)
0x00007FF767D21417 (0x000001FD57EF5470 0x00007FFB22AFFB91 0x000000D08838D530 0x000001FD54D40000)
0x00007FF767D2764E (0x000001FD54DC6260 0x000001FD578FC258 0x000001FD56879300 0x000000D08838D5D0)
0x00007FF767D23A91 (0x000000D000000003 0x0000000000000000 0x000001FD569F4B48 0x000001FD003AFBCB)
0x00007FF767D00CF8 (0x000000D08838D7B0 0x0000000000000000 0x0000000000000000 0x0000000000000000)
0x00007FF766A4AB7C (0x0000000000000000 0x00007FF766A34BDF 0x000000D08838DBA0 0x000000D08838DBB0)
0x00007FF766BD6C83 (0x000000D08838D8C8 0x0000DAD512920C79 0x0000000000000000 0x0000000000000000)
0x00007FF766A4FE35 (0x000000D08838E9C0 0x00007FF767D562C7 0x000001FD54D65510 0x00007FFB22AFFB91)
0x00007FF766A3805C (0x000001FD54D8F9C0 0x000001FD54D8F180 0x000001FD54D8F720 0x000001FD54D8F420)
0x00007FF766168230 (0x0000000000000016 0x00007FF768A28AA4 0x0000000000000012 0x00007FF768A28AB7)
0x00007FF7661871B4 (0x000000D08838E830 0x000001FD54DC27A0 0x000000D08838E4E8 0x00007FFB20A52596)
0x00007FF7661680F0 (0x000001FD54D83EB0 0x0000000000000000 0x0000000000000070 0x000000D08838DD49)
0x00007FF76616760E (0x000001FD54D85F00 0x0000000000000008 0x0000000000000000 0x00007FFB22AFC43F)
0x00007FF766169905 (0x0000000000000008 0x00007FFB22AFC43F 0x00000000003B0033 0x0000000000000020)
0x00007FF7661828F0 (0x0000000000000000 0x0000000300000000 0x0000000000000000 0x0000000300000002)
0x00007FF765D83184 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000)
0x00007FF767DDEAD4 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000)
0x00007FFB21D37BD4 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), BaseThreadInitThunk() + 0x14 bytes(s)
0x00007FFB22B2CE51 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), RtlUserThreadStart() + 0x21 bytes(s)

error: 'stddef.h' file not found [clang-diagnostic-error]

Hey there,
i just have a question:
after installing the clang tidy extension and setup the path to the bin, i receive errors while the checkts which says that system header files are not found. Do you know how to fix this issue?
Ive tried to setup the -p parameter but wasn succesfull.

Thanks in advance
Nick

'ioStream' file not found

As the screenshots show clang-tidy does not find the MinGW header file iostream.

VS Code version: 1.44.2
OS: Windows 10, version 1903, build 18362.720
clang-tidy extension version: 0.4.1

clang/LLVM:
version: 10.0
InstalledDir: C:\LLVM\bin

MinGW:
version: x86_64-8.1.0-posix-seh-rt_v6-rev0
InstalledDir: C:\MinGW\mingw64

settings.json:

   "clang-tidy.executable": "C:\\LLVM\\bin\\clang-tidy",
    "clang-tidy.lintOnSave": true,
    "clang-tidy.checks": [
        "cppcoreguidelines-*",
        "clang-analyzer-*"
    ],
    "clang-tidy.compilerArgs": [
        "--target=x86_64-pc-windows-gnu"
    ],

03

As the PATH variable shows, according to this everything is set:

04

If I execute the same command vscode-clang-tidy is executing (shown in the OUTPUT window) in the cmd of Windows, no iostream error is shown:

C:\LLVM\bin\clang-tidy c:\Users\xx\Desktop\test\main.cpp --export-fixes=- --checks=cppcoreguidelines-*,clang-analyzer-*,clang-diagnostic-* --extra-arg=--target=x86_64-pc-windows-gnu

'ros/ros.h' file not found clang-tidy(clang-diagnostic-error)

When working in a ROS Catkin workspace, intellisense is able to find all my header files, yet clang complains that it cannot find them. It does not complain about std headers such as vector or sstream but it cannot find ros specific header files.

My cpp properties are:

{
  "configurations": [
    {
      "browse": {
        "databaseFilename": "",
        "limitSymbolsToIncludedHeaders": true
      },
      "includePath": [
        "/home/ftb/catkin_ws/devel/include/**",
        "/opt/ros/melodic/include/**",
        "/usr/include/**"
      ],
      "name": "ROS"
    }
  ],
  "version": 4
}

My settings.json is:

{
    "python.autoComplete.extraPaths": [
        "/home/ftb/catkin_ws/devel/lib/python2.7/dist-packages",
        "/opt/ros/melodic/lib/python2.7/dist-packages"
    ],
    "python.pythonPath": "/usr/bin/python",
    "files.associations": {
        "vector": "cpp"
    }
}

My user settings are as follows:

{
    "python.showStartPage": false,
    "python.languageServer": "Microsoft",
    "workbench.editorAssociations": [
        {
            "viewType": "jupyter.notebook.ipynb",
            "filenamePattern": "*.ipynb"
        }
    ],
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "[cpp]": {
        "editor.defaultFormatter": "ms-vscode.cpptools"
    },
    "clang-tidy.fixOnSave": true,
    "[python]": {
        "editor.defaultFormatter": "ms-python.python"
    },
    "workbench.iconTheme": "vscode-icons",
    "clang-tidy.compilerArgs": [ "-p /home/ftb/catkin_ws/build"
    
    ],
    "clang-tidy.compilerArgsBefore": [
        "-p  /home/ftb/catkin_ws/build"
    ]
}

Extension not Working

So I installed the Extension under Ubuntu but nothing is happening.

I would appreciate instructions on how to set it up.

Add clang-tidy.headerFilter to specify --header-filter= parameter when invoking clang-tidy

I would like to be able to specify the header filter in my .vscode/settings.json file instead of having to hard-code it via HeaderFilterRegex: in the shared .clang-tidy file of our repo. (My local path is different from other peoples local path.)

Would it be possible to add a clang-tidy.headerFilter setting to pass this parameter through when invoking clang-tidy?

Thank you!

clang-tidy triggers the lint of the file whenever the file is saved despite "clang-tidy.lintOnSave": false

I don't want the file to be linted when I save it because all the cores skyrocket the load.
I prefer to have the control of the proper moment to lint my files, that's why I set this option
"clang-tidy.lintOnSave": false
But, this options is, at least, not working for me, because every time I hit Ctrl+S, the current file is linted.
Any suggestions?
Thanks in advanced.

Edit: I have this option set in the global settings.json. Is it necessary to have this option also set in the specific workspace I'm working on?

Fails when using old versions of clang-tidy

At some point, the output of clang-tidy --export-fixes=- changed. The extension breaks when it encounters the old output. I'm working on a fix for this.


Old output:

MainSourceFile:  /path/to/main.cpp
Diagnostics:
  - DiagnosticName:  clang-analyzer-deadcode.DeadStores
    Message: 'Value stored to ''num'' during its initialization is never read'
    FileOffset: 85
    FilePath: /path/to/main.cpp
    Replacements:

New output:

MainSourceFile:  '/path/to/main.cpp'
Diagnostics:
  - DiagnosticName:  clang-analyzer-deadcode.DeadStores
    DiagnosticMessage:
      Message:         'Value stored to ''num'' during its initialization is never read'
      FilePath:        '/path/to/main.cpp'
      FileOffset:      85
      Replacements:    []
    Notes:
      - Message:         'Value stored to ''num'' during its initialization is never read'
        FilePath:        '/path/to/main.cpp'
        FileOffset:      85
        Replacements:    []

Problems found in included headers show at the wrong position in .cpp compilation unit.

I think what's happening is that issues found in .h files included in the compilation unit are being shown in .cpp file at the .h FileOffset.
Would it be difficult to move the "problems" to the header files so that are shown in it when viewed?
By the way, thanks for the VSCode extension. I think what you are targeting with it is the main thing holding VScode to be the best free C++ IDE available.

 - DiagnosticName:  readability-inconsistent-declaration-parameter-name
    Message:         'function ''MyClass::myMethod()'' has a definition with different parameter names'
    FileOffset:      23691
    FilePath:        '/Code/MyClass.h'
    Notes:           
      - Message:         the definition seen here
        FilePath:        '/Code/MyClass.cpp'
        FileOffset:      93200
      - Message:         'differing parameters are named here: (''links''), in definition: (''groups'')'
        FilePath:        '/Code/MyClass.h'
        FileOffset:      23691
    Replacements:    
      - FilePath:        '/Code/MyClass.h'
        Offset:          23760
        Length:          5
        ReplacementText: groups

Feature request: clang-tidy.lintOnOpen

Currently, the extension will always trigger a clang-tidy execution when opening a file.

I would like to have the option, to never run clang-tidy unless I explicitly tell it to, thus the following setting would be nice to have:
"clang-tidy.lintOnOpen": false,

Note: I tried to use the following, but that resulted in an error when trying to manually run the lint via command:

"clang-tidy.blacklist": [
    "*"
],

image

Feature Request: Custom arguments

I'm using a custom script to always add some -I built flags when I run clang-tidy.

Unfortunately, I can't use "clang-tidy.executable" setting to use my binary (I'm using node to run a script) because it itself needs some arguments.

Looking into the source code here, I see that the executable setting ultimately gets consumed by child_process.execFile() as the first argument. So I can't use that setting to pass extra args.

Would you consider adding an extra optional setting that are arguments prepended to this list?

Problems are not marked in headerfiles when llvm-* checks are enabled

When I enable llvm-* checks, I get the following error in the vs code developer tools console:

mainThreadExtensionService.ts:60 TypeError: Cannot read property 'DiagnosticMessage' of undefined
	at tidyOutputAsObject (/home/max/.vscode/extensions/notskm.clang-tidy-0.5.1/out/tidy.js:141)
	at Object.collectDiagnostics (/home/max/.vscode/extensions/notskm.clang-tidy-0.5.1/out/tidy.js:147)
	at Object.<anonymous> (/home/max/.vscode/extensions/notskm.clang-tidy-0.5.1/out/lint.js:54)
	at Generator.next (<anonymous>)
	at fulfilled (/home/max/.vscode/extensions/notskm.clang-tidy-0.5.1/out/lint.js:5)
	at runMicrotasks (<anonymous>)
	at processTicksAndRejections (internal/process/task_queues.js:97)

Additionally, the clang-tidy results are not shown in the editor, even though they are found in the Clang-Tidy output on the console:

---
MainSourceFile:  /home/max/ma/workspaces/simws/src/solver_ipft/include/solver_ipft/problems/cont_lightdark.hpp
Diagnostics:     
  - DiagnosticName:  llvm-header-guard
    Message:         header is missing header guard
    FileOffset:      0
    FilePath:        /home/max/ma/workspaces/simws/src/solver_ipft/include/solver_ipft/problems/cont_lightdark.hpp
    Replacements:    
      - FilePath:        /home/max/ma/workspaces/simws/src/solver_ipft/include/solver_ipft/problems/cont_lightdark.hpp
        Offset:          0
        Length:          0
        ReplacementText: '#ifndef SOLVER_IPFT_PROBLEMS_CONT_LIGHTDARK_HPP
#define SOLVER_IPFT_PROBLEMS_CONT_LIGHTDARK_HPP

'
      - FilePath:        /home/max/ma/workspaces/simws/src/solver_ipft/include/solver_ipft/problems/cont_lightdark.hpp
        Offset:          5631
        Length:          0
        ReplacementText: '
#endif
'
  - DiagnosticName:  cppcoreguidelines-special-member-functions
    Message:         'class ''CLDState'' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator'
    FileOffset:      1542
    FilePath:        /home/max/ma/workspaces/simws/src/solver_ipft/include/solver_ipft/problems/cont_lightdark.hpp
    Replacements:    

Maybe the extension has a problem reading multi-line replacement suggestions?
My settings are:

{   
 "clang-tidy.checks":  [
        "-*",
        "google-*", 
        "cppcoreguidelines-*", 
        "clang-*", 
        "readability-*", 
        "misc-*",
        "modernize-*",
        "bugprone-*",
        "llvm-*", <== Error disappears, when I comment this line out
        "performance-*",
        "cert-*"
        ], 
 "clang-tidy.buildPath": "/home/max/ma/workspaces/simws/build/solver_ipft/clang-tidy",
}

Officially putting this project on hiatus

I don't have the time or work on this project at all at the moment. What free time I have, I would like to spend on other things. I'm also about to start college, which will further limit the amount of time I can spend on this.

As a result, this project is being put on hiatus.

Russian symbols break warning position.

The warning position is shifted on russian characters count come before. The same appears not only if russian symbols in comments, but if they in quotes too.

Expecting:
image
Actual:
image

Feature request: Don't lint open files when the compilation database is not found!

Reason for this request is simple, if I don't have a build, my whole files are full of wrong underlined clang-tidy issues! This is annoying and distract me.

Currently you get this output:

> clang-tidy-12 /file/being/lint.cpp --export-fixes=- --extra-arg=-style=file -p=build
Working Directory: /project/dir/

Error while trying to load a compilation database:
Could not auto-detect compilation database from directory "build"
No compilation database found in /project/dir/build_test or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.

error: unknown argument: '-style=file' [clang-diagnostic-error]
/file/being/lint.cpp:118:17: warning: variable 'usbFolderMatch' is not initialized [cppcoreguidelines-init-variables]
    std::smatch usbFolderMatch;
                ^
                               = 0
/file/being/lint.cpp:151:5: warning: switch has 3 consecutive identical branches [bugprone-branch-clone]
    case '3':
    ^
/file/being/lint.cpp:155:9: note: last of these clones ends here
    case '1':'

etc
etc

Please don't lint any file!

Please add some log in vscode output

First, thanks for your work on this extension.
Is it possible to add some log information in VS Code's output panel (View -> Output)?
I could only get the diagnostics from limited files. It would be great if there is some logging so it is easier to figure out what goes wrong.

Thanks again.

[feature_request] Add clang-tidy to C++ formatters list

It would be very nice if clang-tidy would be recognized as a C++ formater by vscode. The "clang-tidy.fixOnSave": true is already very helpful however I think it would make more sense to remove this option and add clang-tidy as a C++ formatter. By doing this people can register clang-tidy as their C++ formatter such that it can format the code when a document is saved (i.e. "editor.formatOnSave": true is enabled).

clang-tidy-problem

No quick fixes available in vscode

There is an option ti use fix on save, but VSCode hind show that "No quick fixes available".
Is there any way to use fixes without autosave but from vscode hint?

Using inclusive language

I would propose to use inclusive language throughout the code base and avoid the term blacklist.

I would propose to replace the option clang-tidy.blacklist with clang-tidy.excludelist.

Diagnostic messages are getting ignored due to relative filepath check

The if statement here:

Is causing diagnostic messages to be ignored due to the fact that the FilePath output is only a filename.

Command being run /usr/local/clang/bin/clang-tidy /code/srv/sd/sdbuf.c ...
The diagnostic messages being reported are:

- DiagnosticName:  clang-diagnostic-incompatible-pointer-types-discards-qualifiers
    DiagnosticMessage:
      Message:         'passing ''volatile uchar *'' (aka ''volatile unsigned char *'') to parameter of type ''void *'' discards qualifiers'
      FilePath:        sdbuf.c
      FileOffset:      62732
      Replacements:    []

This then fails that check, and causes all messages to be ignored.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.