0

I'm using Sublime Text 3(Version 3.1.1, build 3176) on macOS High Sierra(Version 10.13.3).

I want to make SublimeLinter-cppcheck plugin & cppcheck work in my Sublime Text 3, so I installed them according to this link and other web sites.

Now my SublimeLinter.sublime-settings is like this. (I also use the plugin for Python, so there are settings for flake8.)

{
  "debug": true,
  "linters": {
    "cppcheck": {
      "@disable": false,
      "source": "source.cpp",
      "lint_mode": "save",
      "args": [],
      "enable": "style",
      "excludes": [],
      "std": ["c++11"]
    },
    "flake8": {
      "@disable": false,
      "source": "source.py",
      "args": ["--ignore=E111"],
      "enable": "style",
      "excludes": [],
    }
  },
}

Then I check whether they were successfully installed or not with test.cpp which is shown below.

#include <iostream>

using namespace std;

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

    return 0;

This code has apparently an error, so if they were successfully installed, some lint results will appear in the code.

In the debug console, cppcheck seems to be working, so I think I succeeded to install it. Here is the output of debug console.

SublimeLinter: sublime_linter.py:249: Delay buffer 28 for 0.1s
SublimeLinter: sublime_linter.py:249: Delay buffer 28 for 0.0s
SublimeLinter: linter.py:798: Checking lint mode background vs lint reason on_save
SublimeLinter: #98 linter.py:818: 'cppcheck' is linting 'test.cpp'
SublimeLinter: #98 linter.py:1174: Running ...

  /Users/ASHIJANKEN/Desktop  (working dir)
  $ /usr/local/bin/cppcheck --template=gcc --inline-suppr --quiet --std=c++11 --enable=style /Users/ASHIJANKEN/Desktop/test.cpp

SublimeLinter: #98 linter.py:866: cppcheck output:
    /Users/ASHIJANKEN/Desktop/test.cpp:6:0: warning: Invalid number of character '{' when no macros are defined. [syntaxError]
    {
    ^
SublimeLinter: #98 linter.py:906: cppcheck: No match for line: '{'
SublimeLinter: #98 linter.py:906: cppcheck: No match for line: '^'
SublimeLinter: sublime_linter.py:432: Linting buffer 28 took 0.03s

However, no lint result is appear in editing window.

An image of actual window when I editing test.cpp

I don't know why lint results don't appear. Where did I made mistakes?

I know that cppcheck doesn't work when lint_mode is background(Related issue). is it related to this strange behavior?

ASHIJANKEN
  • 11
  • 8

1 Answers1

1

In my environment, finally I solved this problem with deleting the section below from SublimeLinter.sublime-settings.

"cppcheck": {
  "@disable": false,
  "source": "source.cpp",
  "lint_mode": "save",
  "args": [],
  "enable": "style",
  "excludes": [],
  "std": ["c++11"]
},

Now my SublimeLinter.sublime-settings is shown below.

{
  "debug": true,
  "linters": {
    "flake8": {
      "@disable": false,
      "source": "source.py",
      "args": ["--ignore=E111, E114"],
      "enable": "style",
      "excludes": [],
    }
  },
}
ASHIJANKEN
  • 11
  • 8
  • I've got the same problem. How did you solve this exactly? I don't get what you mean by "...with deleting the section below from SublimeLinter.sublime-settings". How does your user-settings-file look now? – OD IUM Dec 28 '19 at 17:21
  • I updated my answer, so please check it. I just deleted the `cppcheck` section. I think this affected the correct behavior. – ASHIJANKEN Dec 29 '19 at 07:59
  • 1
    Ok thx.my issue was different. I installed cppcheck via ubuntus package manager.this gave me cppcheck version 1.8x and apparently this version did not provide a "column"-output. After downloading and building cppcheck version 1.90 everything is fine – OD IUM Dec 29 '19 at 09:01