Skip to content
adamnsm1 edited this page Oct 27, 2017 · 8 revisions

Overview

The linter ensures that code conforms to proper style standards. RDFS conforms to the Google C++ Style Guide. RDFS uses cpplint to automate code style checks.

Installation

Globally

$ sudo pip install cpplint==1.3.0

Locally

$ virtualenv env
$ source env/bin/activate
$ pip install cpplint==1.3.0
For Windows
$ pip install cpplint==1.3.0

Running

On the entire codebase

$ ./.ci/test/lint.sh
# lint.sh will exit nonzero if there are any lint errors

On a single file or directory

# Note that invoking cpplint directly will not respect any ignored rules in lint.sh
$ cpplint <file>
$ cpplint --recursive <directory>

Ignored lint rules

There is a small number of ignored lint rules, which are incompatible with the legacy code structure of RDFS 1.0.

In general, you should make a best-effort attempt to fix all reported lint errors. Do not simply add it to the list of ignored rules, as this entirely defeats the purpose of a linter. If absolutely necessary, you may add a rule to the list of ignored rules. Please tag a reviewer that appears in the blame here before merging such a change.

Adding new source directories

If you add a new source directory to RDFS, you will need to tell the linter about its existence. Namely, you will need to add it to SOURCE_DIRECTORIES in lint.sh. Please tag a reviewer that appears in the blame here before merging such a change.

Enable the CLion CppLint plugin

  • Preferences > Plugins > search repositories for "CLion-cpplint"
  • Preferences > other settings > cpplint option
    • On terminal in virtualenv:
      • copy which python output to "python path" in CLion
      • copy which cpplint output to cpplint.py path in CLion

Clone this wiki locally