Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync linter with ethz fork #1

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
80731d1
Changed python formatter to yapf and added working default pylint.rc
eggerk May 25, 2018
3a22b26
Adapted init script
eggerk May 25, 2018
e73a0cc
Updated readme
eggerk May 25, 2018
81bd7fa
Enabled python by default
eggerk May 25, 2018
2a0551f
Set yapf style to google
eggerk May 25, 2018
a7bf3ce
Fixed style argument
eggerk May 25, 2018
f0fc44d
Fixed style in the right place
eggerk May 25, 2018
6945964
Changed default python style to pep8 and no longer enforce docstrings…
eggerk May 25, 2018
03b9686
Merge pull request #23 from ethz-asl/fix/python-linter
eggerk May 29, 2018
d0e74db
Added possibility to install the linter
eggerk May 29, 2018
fdd5b86
Enable usage of linter from within submodules
eggerk May 29, 2018
6e511cd
Cleanup
eggerk May 29, 2018
956fdc3
Removed a debug print
eggerk May 29, 2018
1c04254
Added option to remove linter
eggerk May 29, 2018
6d416a5
Removed dead code
eggerk May 29, 2018
cd91c54
Fix linter path for bash
eggerk May 30, 2018
a81569c
Completely removed possiblility to use linter as submodule
eggerk May 31, 2018
6d61256
Expanded documentation
eggerk Jun 11, 2018
6cf67b5
Fixed grammar
eggerk Jun 11, 2018
de9bf9b
Renamed to .linterconfig.yaml
eggerk Jun 11, 2018
db10109
Merge pull request #24 from ethz-asl/feature/easy_linter_installation_2
eggerk Jun 11, 2018
ac5b666
Disabled two more pylint warnings
eggerk Jun 13, 2018
b185a75
Disabled another pylint check
eggerk Jun 14, 2018
64a518c
Merge pull request #25 from ethz-asl/fix/pylint_again
eggerk Jun 14, 2018
add18a7
use newest clang-format
mfehr Jun 22, 2018
1ed08cf
automatically search for clang format version, apply linter formattin…
mfehr Jun 25, 2018
6711217
add generic clang format executable
mfehr Jun 25, 2018
7b5d274
rm unused line
mfehr Jun 25, 2018
242ca01
Adapt README
mfehr Jun 25, 2018
c7bc193
Fix README for OSX, add section about disabling linter functions
mfehr Jun 25, 2018
206b47f
Merge pull request #28 from ethz-asl/feature/use_new_clang
mfehr Jun 25, 2018
6bd2994
Update README.md
mfehr Jul 31, 2018
27a9e41
Removed exit(1) on failure of linter check
hhansen-bdai May 30, 2019
f3f6f04
Added docstrings required, check formatting
hhansen-bdai May 30, 2019
612ec9c
tripping linter
hhansen-bdai May 31, 2019
6b16c92
trip linter
hhansen-bdai May 31, 2019
a27fb4b
trip linter
hhansen-bdai May 31, 2019
a4a36ad
trip linter
hhansen-bdai May 31, 2019
2ccae37
Merge branch 'feature/non-blocking-linter' of github.com:mit-drl/lint…
hhansen-bdai May 31, 2019
be45d4e
trip linter
hhansen-bdai May 31, 2019
317b9c6
Real commit, added option to choose to commit at the end
hhansen-bdai May 31, 2019
bf00832
Removed .linterconfig.yaml
hhansen-bdai May 31, 2019
a64865d
Added ascii art credit.
igilitschenski May 31, 2019
ade3956
Merge pull request #1 from mit-drl/feature/non-blocking-linter
igilitschenski Jun 1, 2019
a2230c7
Reverse docstring related changes for PR to upstream
igilitschenski Jun 1, 2019
85e281a
Merge pull request #32 from mit-drl/feature/non-blocking-linter
igilitschenski Jun 1, 2019
5c16bde
Added option for local pylint config.
igilitschenski Jun 3, 2019
77959ea
Merge branch 'feature/non-blocking-linter' into feature/pylint_config
igilitschenski Jun 3, 2019
dab9bd6
Addressed comments by @mfehr
igilitschenski Jun 5, 2019
d76091b
Merge pull request #33 from mit-drl/feature/pylint_config
igilitschenski Jun 5, 2019
c2b19b3
Update ascii_art.py
mfehr Dec 19, 2019
47de734
add run on whole repo function
Jul 23, 2020
1ae28c4
clearer printing summary
Jul 23, 2020
a33f2c4
fix pylint error count
Jul 23, 2020
c425a88
pretty printing for commit numbers
Jul 23, 2020
684e464
fix linter_check_all, prettier printing for pylint
Jul 25, 2020
3fe27b4
update readme
Jul 25, 2020
04bf888
minor fix to readme and default config
Jul 27, 2020
72d054d
add pylint warning filtering so other warnings pass
Aug 10, 2020
4ca8884
lucky commit on 42nd and not 41st commit :)
Aug 10, 2020
2007a9d
fix typo
Aug 17, 2020
4d3087d
Merge pull request #36 from ethz-asl/feature/run_on_repo
Schmluk Aug 17, 2020
a6561ad
remove printing
Aug 19, 2020
bbd2cc3
Merge pull request #37 from ethz-asl/fix/printing
Schmluk Aug 19, 2020
e944d49
fix for repo root
LBern Jul 5, 2022
09f2264
more ports to py3
LBern Jul 5, 2022
e871a31
Merge pull request #39 from ethz-asl/hotfix/py3
LBern Jul 6, 2022
9e3a9b0
added requests install to readme
LBern Jul 6, 2022
cb070ec
Merge pull request #40 from ethz-asl/hotfix/readme
LBern Jul 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 93 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,74 @@
# linter

This repo contains a (C++, python (experimental)) linter and auto formatter package that can be included into your repository as a submodule. It provides the following git hooks:
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:
* **General**
* Prevent commits to master.
* **C++** files:
* **clang-format** Formats your code based on your .clang-format preferences.
*
* **clang-format** Formats your code based on your `.clang-format` preferences.
* **cpplint** Checks your C++ code for style errors and warnings.

* **EXPERIMENTAL - Python** files:

**WARNING:** The default linter settings are very strict and might not actually conform with the formatting produced by autopep8. If you want to use this linter for python you will need to do some tweaking.
* **autopep8** Formats your python code.
* **Python** files:

* **yapf** Formats your python code.
* **pylint** Checks your Python code for style errors and warnings.


## Dependencies

* **autopep8** ([Introduction to autopep8](http://avilpage.com/2015/05/automatically-pep8-your-python-code.html))
* Ubuntu 14.04 / macOS: `pip install autopep8`
* **pylint**
* macOS:
```
pip install pylint
```
* **yapf**
* Ubuntu / macOS: `pip install yapf`
* **clang-format**
* Ubuntu 14.04: `sudo apt-get install clang-format-3.X`
* macOS:
* Compatible with `clang-format-3.8 - 6.0`
* Ubuntu: `sudo apt install clang-format-${VERSION}`
* macOS:
```
brew install clang-format
ln -s /usr/local/share/clang/clang-format-diff.py /usr/local/bin/clang-format-diff-3.8
ln -s /usr/local/share/clang/clang-format-diff.py /usr/local/bin/clang-format-diff
```

* **requests**
* Ubuntu:
```
pip install requests
```

## Installation

```bash
git clone [email protected]: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:
```bash
cd $YOUR_REPO
git submodule add [email protected]:ethz-asl/linter.git
./linter/init-git-hooks.py
init_linter_git_hooks
```

You can also add the linter submodule in a subfolder of your repo, e.g.:
## Uninstallation
To remove the linter from your git repository again, run the following:
```bash
mkdir $YOUR_REPO/dev_tools
git submodule add [email protected]:ethz-asl/linter.git dev_tools/linter
./dev_tools/linter/init-git-hooks.py
cd $YOUR_REPO
init_linter_git_hooks --remove
```

Define the project-specific C++ format by adding a file `.clang-format` to your projects root folder. Example:
## 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`](https://github.com/ethz-asl/linter/blob/master/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:

```
---
Expand All @@ -63,6 +89,52 @@ IncludeCategories:
...
```

#### ASCII-Art Sources
**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

* **C++ Linter (`cpplint`):**
```cpp
void your_awful_function(int & result) // NOLINT
```
* **C++ Formatting (`clang-format`):**
```cpp
// clang-format off
...
// clang-format on
```
* **Python Linter (`pylint`)**

For whole file:
```python
#!/usr/bin/env python
# pylint: disable=C0103,E1101
...
```
For a line:
```Python
your_awful_function('-legal/copyright,-build/c++11') # pylint: disable=W0212
```
The full list of pylint warnings and errors can be found [here](http://pylint-messages.wikidot.com/all-messages)

* **Python Formatting (`yapf`)**
```python
# yapf: disable
...
# yapf: enable
```

## Tools
* **Checking an entire repository**

Type `linter_check_all` to run the linters and formatters on all files within the current repository.


## ASCII-Art Sources

* [www.asciiart.eu](https://www.asciiart.eu)
* [www.retrojunkie.com (accessed through web.archive.org)](https://web.archive.org/web/20150831003349/http://www.retrojunkie.com:80/asciiart/)
49 changes: 42 additions & 7 deletions ascii_art.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class AsciiArt(object):

tiger = r"""
tiger = r"""
_
,',\
( / \\
Expand Down Expand Up @@ -37,7 +37,7 @@ class AsciiArt(object):

"""

cthulhu = r"""
cthulhu = r"""


_.---._
Expand Down Expand Up @@ -75,7 +75,7 @@ class AsciiArt(object):

"""

story = r"""
story = r"""
______ _ ______ _
\___ \____ | | \__ \____ | |
| | _/\__ \ | |__ | | _/\__ \ | |__
Expand Down Expand Up @@ -134,7 +134,7 @@ class AsciiArt(object):

"""

commit_success = r"""
commit_success = r"""

d888888b d888888b
d888 8888b d888888 888b
Expand All @@ -150,12 +150,12 @@ class AsciiArt(object):
88 _(<_ / )_ 88
d88b (__\_\_|_/__) d88b

Your happiness shall not depend on what you have or what your are,
Your happiness shall not depend on what you have or what you are,
it shall solely depend on the beauty of your code.

"""

grumpy_cat = r"""
grumpy_cat = r"""

: sdMMm+
/mMMMMMMM+
Expand Down Expand Up @@ -203,7 +203,7 @@ class AsciiArt(object):

"""

homer_woohoo = r"""
homer_woohoo = r"""

,#M]RRD`"RW
,R,qB*""``"*Rw,
Expand Down Expand Up @@ -239,3 +239,38 @@ class AsciiArt(object):
Woohoo, no formatter or linter for merge commits!

"""

yoda = r"""
____
_.' : `._
.-.'`. ; .'`.-.
__ / : ___\ ; /___ ; \ __
,'_ ""--.:__;".-.";: :".-.":__;.--"" _`,
:' `.t""--.. '<@.`;_ ',@>` ..--""j.' `;
`:-.._J '-.-'L__ `-- ' L_..-;'
"-.__ ; .-" "-. : __.-"
L ' /.------.\ ' J
"-. "--" .-"
__.l"-:_JL_;-";.__
.-j/'.; ; / .'\-.
.' /:`. "-.: .-" .'; `.
.-" / ; "-. "-..-" .-" : "-.
.+"-. : : "-.__.-" ;-._ \
; \ `.; ; : : "+. ;
: ; ; ; : ; : \:
: `."-; ; ; : ; ,/;
; -: ; : ; : .-"' :
:\ \ : ; : \.-" :
;`. \ ; : ;.'_..-- / ;
: "-. "-: ; :/." .' :
\ .-`.\ /t-"" ":-+. :
`. .-" `l __/ /`. : ; ; \ ;
\ .-" .-"-.-" .' .'j \ / ;/
\ / .-" /. .'.' ;_:' ;
:-""-.`./-.' / `.___.'
\ `t ._ / bug :F_P:
"-.t-._:'
Careful be, you must. Unformatted code
to the dark side leads

"""
Loading