├── .python-version ├── .gitignore ├── messages.json ├── .travis.yml ├── messages └── install.txt ├── LICENSE ├── linter.py └── README.md /.python-version: -------------------------------------------------------------------------------- 1 | 3.8 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "install": "messages/install.txt" 3 | } 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.6" 4 | install: 5 | - pip install flake8 6 | script: 7 | - flake8 . --max-line-length=120 8 | -------------------------------------------------------------------------------- /messages/install.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-cpplint 2 | ------------------------------- 3 | This linter plugin for SublimeLinter provides an interface to cpplint. 4 | 5 | Please read the installation instructions at: 6 | 7 | https://github.com/SublimeLinter/SublimeLinter-cpplint 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 2 | of this software and associated documentation files (the "Software"), to deal 3 | in the Software without restriction, including without limitation the rights 4 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5 | copies of the Software, and to permit persons to whom the Software is 6 | furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | -------------------------------------------------------------------------------- /linter.py: -------------------------------------------------------------------------------- 1 | from SublimeLinter.lint import Linter, util 2 | 3 | 4 | class Cpplint(Linter): 5 | cmd = ('cpplint', '${args}', '${file}') 6 | regex = r'^.+:(?P\d+):\s+(?P.+)' 7 | tempfile_suffix = '-' 8 | error_stream = util.STREAM_BOTH # errors are on stderr 9 | on_stderr = None # handle stderr via split_match 10 | defaults = { 11 | 'selector': 'source.c, source.c++', 12 | '--filter=,': '', 13 | '--linelength=,': '', 14 | } 15 | 16 | def split_match(self, match): 17 | """ 18 | Extract and return values from match. 19 | 20 | We override this method so that the error: 21 | No copyright message found. 22 | You should have a line: "Copyright [year] " [legal/copyright] [5] 23 | that appears on line 0 (converted to -1 because of line_col_base), can be displayed. 24 | 25 | """ 26 | 27 | match, line, col, error, warning, message, near = super().split_match(match) 28 | 29 | if line is not None and line == -1 and message: 30 | line = 0 31 | 32 | return match, line, col, error, warning, message, near 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SublimeLinter-cpplint 2 | ========================= 3 | 4 | [![Build Status](https://travis-ci.org/SublimeLinter/SublimeLinter-cpplint.svg?branch=master)](https://travis-ci.org/SublimeLinter/SublimeLinter-cpplint) 5 | 6 | This linter plugin for SublimeLinter provides an interface to [cpplint](https://pypi.python.org/pypi/cpplint). 7 | It will be used with files that have the "C" or "C++" syntax. 8 | 9 | ## Installation 10 | 11 | SublimeLinter must be installed in order to use this plugin. 12 | 13 | Please use [Package Control](https://packagecontrol.io) to install the linter plugin. 14 | 15 | Before using this plugin, ensure that `cpplint` is installed on your system. 16 | To install `cpplint`, do the following: 17 | 18 | 1. Install [Python](http://python.org/download/) and [pip](http://www.pip-installer.org/en/latest/installing.html). 19 | 20 | 1. Install `cpplint` by typing the following in a terminal: 21 | ``` 22 | [sudo] pip install cpplint 23 | ``` 24 | 25 | Please make sure that the path to `cpplint` is available to SublimeLinter. 26 | The docs cover [troubleshooting PATH configuration](http://sublimelinter.com/en/latest/troubleshooting.html#finding-a-linter-executable). 27 | 28 | 29 | ## Settings 30 | 31 | - SublimeLinter settings: http://sublimelinter.com/en/latest/settings.html 32 | - Linter settings: http://sublimelinter.com/en/latest/linter_settings.html 33 | 34 | Additional settings for SublimeLinter-cpplint 35 | 36 | |Setting|Description| 37 | |:------|:----------| 38 | |filter|A comma-separated list of category-filters to apply| 39 | |linelength|The allowed line length (with cpplint >= 0.0.6)| 40 | 41 | ``filter`` can be a single string (anywhere) or array of strings (anywhere but inline). 42 | --------------------------------------------------------------------------------