Code Monkey home page Code Monkey logo

sublimelinter-cppcheck's Introduction

SublimeLinter-cppcheck

Build Status

This linter plugin for SublimeLinter provides an interface to cppcheck. It will be used with files that have the "C++" or "C" syntax.

Installation

SublimeLinter must be installed in order to use this plugin.

Please use Package Control to install the linter plugin.

Before using this plugin, ensure that cppcheck is installed on your system. To install cppcheck, do one of the following:

  • Install cppcheck from your favorite package manager:

    <package manager> install cppcheck
    
  • For Windows, you can download a copy from the official site of cppcheck.

Once cppcheck is installed, ensure it is in your system PATH so that SublimeLinter can find it. The docs cover troubleshooting PATH configuration.

Settings

We have two settings sections. 'cppcheck' for c files, and 'cppcheck++' to configure the linter for c++ files. E.g.

{
    "linters":
    {
        "cppcheck": {
            ...
        },
        "cppcheck++": {
            ...
        }
    }
},

--language= is set automatically to c or c++.

Additional SublimeLinter-cppcheck settings:

Setting Description
std Set the language standard used.
enable A comma-delimited list of checks to enable. Defaults to style.

Examples

For enable, you can use a single string (ex: "style,unusedFunction"), or an array of strings if not inline (ex: ["style", "unusedFunction"]).

For std, you can use a single string for a single value, but you have to use an array of strings for multiple values (ex. ["c89", "c99"]), which means you can't use multiple values in inline settings.

sublimelinter-cppcheck's People

Contributors

ajalt avatar aparajita avatar braver avatar cixtor avatar dollars avatar eamars avatar ftoulemon avatar groteworld avatar irvingzhang0512 avatar jawshooah avatar jfcherng avatar kaste avatar mokkabonna avatar notsqrt avatar unwiredben 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublimelinter-cppcheck's Issues

lint_mode background doesn't work

I'm using SublimeText on OS X El Capitan and installed cppcheck via homebrew.
When saving a file the linter works just fine but it seems he won't do anything on the fly when I'm typing.
I checked the settings for lint_mode and it is set to background, with php the background mode works just fine.

If you need any further information please let me know!

Thanks!

does cppcheck work for source files in ftp?

I use samba ftp service to mapping a remote linux directory to windows. Then I open the net-mapped directory in windows using sublime text 3. But it seems that sublimelinter & sublimelinter-cppcheck does not work.

If I open a cpp source stored in windows, sublimelinter & sublimelinter-cppcheck works well.

does cppcheck work for source files in ftp?

Crashes after SublimeLinter4 upgrade

After the recent upgrade to SublimeLinter 4, SublimeLinter-cppcheck crashes with following error:

SublimeLinter: ERROR: Linter crashed.

Traceback (most recent call last):
  File "lint.backend in /home/gizdov/.config/sublime-text-3/Installed Packages/SublimeLinter.sublime-package", line 97, in execute_lint_task
  File "lint.linter in /home/gizdov/.config/sublime-text-3/Installed Packages/SublimeLinter.sublime-package", line 813, in lint
  File "lint.linter in /home/gizdov/.config/sublime-text-3/Installed Packages/SublimeLinter.sublime-package", line 847, in find_errors
  File "linter in /home/gizdov/.config/sublime-text-3/Installed Packages/SublimeLinter-cppcheck.sublime-package", line 50, in split_match
  File "lint.linter in /home/gizdov/.config/sublime-text-3/Installed Packages/SublimeLinter.sublime-package", line 865, in split_match
AttributeError: 'NoneType' object has no attribute 'groupdict'
ERROR:SublimeLinter.lint.backend:Linter crashed.

Is this the correct settings format?

As someone that hasn't used SublimeLinter before I want to check that I'm adding the settings in the right palce.

The readme points to the standard SublimeLinter documentation which isn't very clear on where settings are put. It says in one part "Each linter plugin is responsible for providing its own settings" (which to me would imply that each plugin is in charge of maintaining its own settings file), but their default settings file shows a "linters" section (which isn't included in the default settings file that it installs with.

In any case, would this be the correct way to add cppcheck and have it work with a project being compiled with -std=c++14? https://gist.github.com/JohannesMP/95502c2f85d5ded0a8f3c42be8963b3b#file-sublimelinter-sublime-settings-L9-L13

CppCheck refuses to lint .h as C++ files

Issue :

  • CppCheck won't lint .h files as C++ files even though syntax is set to C++ in bottom right

Steps to reproduce :

  • Open a C++ header with .h file extension

Error Message :

  • Code 'namespaceNameSpace{' is invalid C code. Use --std or --language to configure the language.

System Information :

  • Sublime Text Build 3207
  • CppCheck Version 1.88 via MingW64
  • Windows 7 Ultimate

cppcheck is exectued but errors are not marked

Not sure what I'm doing wrong.
My config looks like this:

{
    // Set to true to print extra information in the console.
    "debug": true,
    "lint_mode": "save",
    "linters": {
        "cppcheck": {
            "@disable": false,
            "args": [],
            "enable": "style",
            "excludes": [],
            "std": "c++11",
            "syntax_map": {
                "c++11": "c++"
            }
        }
    }
}

The test-file (from the docs):

#include

using namespace std;

int main()
{
    cout << "it works" << endl;

    return 0;

After saving, the output is printed to the console:

  /home/zac  (working dir)
  $ /usr/bin/cppcheck --template={file}:{line}:{column}:{severity}:{id}:{message} --inline-suppr --quiet --std=c++11 --enable=style /home/zac/myerror.cpp

SublimeLinter: #3 linter.py:1202      cppcheck: output:
  /home/zac/myerror.cpp:6:{column}:error:syntaxError:Invalid number of character '{' when no macros are defined.
SublimeLinter: #3 linter.py:1254      cppcheck: No match for line: '/home/zac/myerror.cpp:6:{column}:error:syntaxError:Invalid number of character '{' when no macros are defined.'
SublimeLinter: sublime_linter.py:575  Linting 'myerror.cpp' took 0.02s

cppcheck seems to work.
However, there are no hints or marks inside the editor. What am I missing?

Can't install

For some reason I am unable to install via package control due to this error:

File "./plistlib.py", line 378, in parse
xml.parsers.expat.ExpatError: XML or text declaration not at start of entity: line 23, column 0

Any suggestions?

cppcheck seems to work but no lint results appear

I get the same question described here.
In short, in sublime console, cppcheck works just fine. However, when running SublimeLinter: Show all errors command in ctrl + shift + p, it shows No lint results.

I'm using win7 & sublime text 3 build 3143 & SublimeLinter v4.6.6 & SublimeLinter-cppcheck v1.1.1.

Is there any way to check for directory instead of file?

Cppcheck is performing check when file open and showing the results.
If the function is used in another file it is showing unused function which is not correct.
Is there any way to make cppcheck to run on entire directory instead of checking the current file?

Improve error handling on stdout

The comment in the code suggest that exceptions are on stdout. It would be nice for the user if these could be captured and presented to the user. (Like call notify_failure() on hard, configuration errors.)

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.