在 sublime text 3 中配置 cppcheck linter

configuration of cppcheck linter in sublime text 3

我在我的机器上安装了 cppcheck 并在我的 SublimeText3 中安装了 Sublimelintercppcheck 插件,正如文档所述,但我仍然无法获得 cppcheck 工作。我想我在路径变量中犯了一些错误。我阅读了 this 个答案,但无法理解。请帮我配置它。谢谢。

这里是我的机器(Ubuntu 16.04)输出到相关命令的地方:

which cppcheck
/usr/bin/cppcheck

我的~/.profile文件:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin directories
PATH="$HOME/bin:$HOME/.local/bin:$PATH:/usr/bin"

这是我的 Sublimelinter.sublime-设置文件:

{
    "user": {
        "debug": false,
        "delay": 0.25,
        "error_color": "D02000",
        "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
        "gutter_theme_excludes": [],
        "lint_mode": "manual",
        "linters": {
            "cppcheck": {
                "@disable": false,
                "args": [],
                "enable": "style",
                "excludes": [],
                "std": ["c++11"]
            }
        },
        "mark_style": "outline",
        "no_column_highlights_line": false,
        "passive_warnings": false,
        "paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "python_paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "rc_search_limit": 3,
        "shell_timeout": 10,
        "show_errors_on_save": false,
        "show_marks_in_minimap": true,
        "syntax_map": {
            "html (django)": "html",
            "html (rails)": "html",
            "html 5": "html",
            "javascript (babel)": "javascript",
            "magicpython": "python",
            "php": "html",
            "python django": "python",
            "pythonimproved": "python"
        },
        "warning_color": "DDB700",
        "wrap_find": true
    }
}

Also note that whenever I try to add /usr/bin/ above i.e. "paths" : {"linux" : [/usr/bin/]} Sublime shows me error. Please help me here.

这可能只是您的问题,但您添加到 Sublimelinter.sublime-settings 文件的路径应该用引号引起来。

不正确:

"paths" : {"linux" : [/usr/bin/]}

更正:

"paths" : {"linux" : ["/usr/bin/"]}

注意:SublimeLinter Troubleshooting Guide 中的添加路径部分指出,如果您的 PATH 在正确的 space 中初始化(Ubuntu 的 ~/.profile),则您不需要在设置文件中重新添加目录。如果您打开 SublimeLinter 的调试并重新启动 SublimeText

,您应该会在控制台中看到 PATH 输出