Git Product home page Git Product logo

cpp-check-lint's Introduction

cpp-check-lint

GitHub release GitHub license GitHub stars GitHub fork GitHub issues

[toc]

Features

  • cppcheck/cpplint:
  • editor/context
  • check current file
  • check the directory of the current file
    • cmd :
      • clear all
      • clear current file
      • stop check
  • explorer/context
    • check directory || check current file
    • cmd
  • OnSave/QuickFix

Requirements

cppcheck

  • Install from source
# http://cppcheck.net/
yum install -y gcc gcc-c++ cmake
sudo tar -zxvf cppcheck-x.y.tar.gz
cd cppcheck-x.y/
mkdir build && cd build
cmake ..
make -j$(nproc)
  • Install for yum/apt_get/brew :
sudo apt-get install cppcheck
sudo yum install cppcheck
brew install cppcheck
  • help

http://cppcheck.sourceforge.net/manual.html

cpplint

  • Install from source
https://github.com/cpplint/cpplint
  • Install from pip
pip install cpplint

builtin binaries

  • cppcheck 2.15 Windows 64-bit (No XP support) Linux x86 GLIBC 2.5

  • cpplint 1.6.1 (linux cpplint need python)

from to
http://cppcheck.net/ cpp-check-lint\bin\linux64 cppcheck
addons
cfg
platforms
http://cppcheck.net/ cpp-check-lint\bin\win64 cppcheck.exe
cppcheck-core.dll
addons
cfg
platforms
https://github.com/cpplint/cpplint/tree/1.6.1 cpp-check-lint\bin\win64 cpplint.py -> cpplint.exe
https://github.com/cpplint/cpplint/tree/1.6.1 cpp-check-lint\bin\linux64 cpplint.py

Extension Settings

  • If ${workspaceFolder} is included, it will be replaced.

Cppcheck

  • Cppcheck:--executable
if (cppcheck configure is null) {
    use builtin binaries
} else {
    if( ("path to executable" --version).trim().toLowerCase().startsWith("cppcheck") ){
        use "path to executable"
    } else {
        use builtin binaries 
    }
}
  • Cppcheck:--addon=
[
    "cert", 
    {
        "script": "misra.py", 
        "args": [
            "--rule-texts=/home/user/misra.txt"
        ]
    }, 
    "y2038.py", 
    "C:\\UsersAdministrator\\hreadsafety.json"
]

"addon" and "addon.py" will use addons folder under the same level folder as cppcheck .

[rorot@cpppcheck]$ tree | grep -E " cppcheck.exe| addons| misra.py| y2038.py| cert.py| threadsafety.py"
├── addons
│   ├── cert.py
│   ├── misra.py
│   ├── threadsafety.py
│   └── y2038.py
├── cppcheck.exe

Some addons need extra arguments. You can configure json or json file.

{
    "script": "misra.py",
    "args": [
        "--rule-texts=/home/user/misra.txt"
    ]
}
"--rule-texts=/home/user/misra.txt" (need absolute path, and use "/" or "\\" to split paths)
"args": ["--rule-texts=${workspaceFolder}/rule/misra.txt"] -> "args":["--rule-texts=D:/code/demo/rule/misra.txt"]}

Cpplint

  • Cpplint:--executable
if (cpplint configure is null) {
    use builtin binaries
} else {
    if("path to executable"){
        use "path to executable"
    } else {
        use builtin binaries 
    }
} 
  • Cpplint:--recursive

  • Cpplint:--lintdir

if ( cpplint version support "--recursive") {
        set --recursive true
    } else {
        set "--recursive" false
        set "--lintdir"
}
  • customargs

    If the configuration parameters cannot be satisfied, use custom configuration "--customargs="

  • OnSave

    cpplint suggest use with clang-format

  • QuickFix

    It's just suppresses alarms

  • Configure skip unsupported flag

    type value
    bool false
    string ""
    number null
    object null

Known Issues

Source code


cpp-check-lint's People

Contributors

qiuminge avatar cvaliere avatar jqknono avatar lubomilko avatar

Stargazers

Bao Liqi avatar  avatar JedA_I avatar Shan Pen avatar Ricardo Carvalheira avatar  avatar  avatar Aleksandr Anenkov avatar HNguyen avatar Charles.Lee avatar listenwind avatar  avatar

Watchers

 avatar

cpp-check-lint's Issues

Bump bundled Cppcheck to 2.15

Hi!
It would be nice to include the latest version of Cppcheck (version 2.15), as the bundled 2.12 version is now one year old. This would be great to include lots of fixes for the addons as well, such as the many changes received by the misra.py addon.
Not to talk about the other commits to the main Cppcheck program, as they are in the hundreds. This would greatly improve the experience when using the extension, with minimal effort.
The upgrade should be pretty straightforward if you have already the environment set up. Thanks for the consideration!

Unable to use multiple "--enable"

We use "--enable=style --enable=performance" but I can't seem to get this to work with this extension. I've tried the following in the settings:
style performance
"style performance"
style --enable=performance

I've also tried to add "--enable=performance" to customargs but that didn't show up in the command line.

cppcheck filter argument needs a single quote

While using cppcheck on a file, I noticed that the command was failing because the executing command was this:

executing: cppcheck --template={file}:{line}:{column}: {severity}: CWE-{cwe} {message}:[{id}] --enable=warning -j4 ....

Since there is a space in the given template, according to cppcheck documentation, it looks like the argument to the template needs to be wrapped with a single quote(').

--template='<text>'  Format the error messages. E.g.
                         '{file}:{line},{severity},{id},{message}' or
                         '{file}({line}):({severity}) {message}' or
                         '{callstack} {message}'
                         Pre-defined templates: gcc, vs, edit.

I tried that out locally by copying the full command and using single quotes, and the command ran without issues:

cppcheck --template='{file}:{line}:{column}: {severity}: CWE-{cwe} {message}:[{id}]' --enable=warning -j4 ...

C99 standard not allowed, two C89 standards offered

It is not possible to specify C99 standard and the C89 is duplicated, so the valid choices are: "C89, C89, C11".
std_c

Also, setting the "c99" option in JSON settings is producing an error:
c99_json

Would it be possible to fix it? The plugin is otherwise very helpful! Thank you.

variable substitution

Is it possible to use variable substitution for configurations?

For example to have a workspace based suppression it would be nice to be able to use a setting like this:

"cpp-check-lint.cppcheck.--suppressions-list=": "${worspaceFolder}\\cppcheck-suppression.txt"

Thanks!

‘python\r’: No such file or directory

executing: /home/xxx/.vscode-server/extensions/qiumingge.cpp-check-lint-1.4.7/bin/linux64/cpplint.py  ....
/usr/bin/env: ‘python\r’: No such file or directory

exit code is : 127
close code is : 127

How to enable cppcheck addons?

I'm trying to use the MISRA addon in cppcheck. The corresponding cppcheck command is:
cppcheck --addon=misra .\test.c
How can I enable it in cpp-check-lint?

cpplint settings are ignored

Hey! When I add configuration for the lint, like --root=src or --filter=-legal/copyright it just ignores these settings and shows errors anyway.
Is it possible to fix this bug?

How to disable cppcheck on save?

Hi i've tried the setting: "cpp-check-lint.cppcheck.--onsave": false, but it seems that cppcheck is always enabled on save
Thanks!

misra.py addon not working correctly

Hi! I'm having trouble making the extension work with the "misra.py" addon. Before the latest updates (before 1.5.2) I had the settings (in settings.json) like this:
image
But that doesn't work anymore:
image
So (temporarily) I hardcoded the full path of the plugin (C:\\Users\\riccardo.b\\.vscode\\extensions\\qiumingge.cpp-check-lint-1.5.4\\bin\\win64\\addons\\misra.py), and I tried running it again but it still fails to catch very simple misra errors. I then wondered if the python file actually got executed, so I went and modified it like so:
image
I just added a small print (there are many throughout the code) and like this I get this error message when trying to analyze a single file (with right click -> cpp-check-lint -> cppcheck-file).

CWE-0 Bailing out from analysis: Whole program analysis failed: Failed to execute 'python3.exe  C:\Users\riccardo.b\.vscode\extensions\qiumingge.cpp-check-lint-1.5.4\bin\win64\addons\misra.py --cli --rule-texts=c:/DATI/REPO/PROJECT_NAME/misra-rules-2012.txt --file-list c:\DATI\REPO\PROJECT_NAME\src\cppcheck-addon-ctu-file-list13840'. TEST

So the "TEST" gets printed but the whole program then gets aborted? Also It seems that there is some sort of problem when selecting a single file, as I don't think that the --file-list argument is correct.
It would also be nice to go back to selecting the addon with just the relative path (misra.py instead of C:\\Users\\riccardo.b\\.vscode\\...), I don't know what happened there honestly.

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.