Home

Awesome

linter

This repo contains a (C++, python) linter and auto formatter package that can be conveniently installed into your repositories using git hooks. It provides the following git hooks:

Dependencies

Installation

git clone git@github.com:ethz-asl/linter.git
cd linter
echo ". $(realpath setup_linter.sh)" >> ~/.bashrc  # Or the matching file for
                                                   # your shell.
bash

Then you can install the linter in your repository:

cd $YOUR_REPO
init_linter_git_hooks

Uninstallation

To remove the linter from your git repository again, run the following:

cd $YOUR_REPO
init_linter_git_hooks --remove

Linter configuration

General

To configure the linter, add a file named .linterconfig.yaml in your repository root. An example file is given under linterconfig.yaml_example.

C++

clang-format can be configured by defining a project-specific C++ format by adding a file .clang-format to your projects root folder. Example file:

---
Language: Cpp
BasedOnStyle: Google
DerivePointerAlignment: false
PointerAlignment: Left
ColumnLimit: 80
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlignAfterOpenBracket: AlwaysBreak
IncludeCategories:
  - Regex:           '^<.*'
    Priority:        1
  - Regex:           '.*'
    Priority:        2
...

Python

Currently there it is not possible to configure the python formatter on a per-repository basis. The linter can be configured on a per-repository bais by adding a .pylintrc file to your repositorie's root folder.

Disable Linter Functionalities for a Specific Line

Tools

ASCII-Art Sources