https://github.com/cmsirbu/codelint
Code Linting & Formatting Showcase
https://github.com/cmsirbu/codelint
Last synced: about 1 year ago
JSON representation
Code Linting & Formatting Showcase
- Host: GitHub
- URL: https://github.com/cmsirbu/codelint
- Owner: cmsirbu
- Created: 2020-07-24T08:17:18.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-27T13:27:09.000Z (about 5 years ago)
- Last Synced: 2025-01-27T23:47:09.416Z (over 1 year ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Code Linting & Formatting Showcase
The [](https://travis-ci.org/cmsirbu/codelint) is intentional, see if you can find out why!
Try linting `example.py` with `pylint`, `pylama` and reformat it with `black`.
```
pip install -r requirements.txt
pylint example.py
pylama example.py
black --check --diff example.py
```
For YAML, first lint `playbook.yml` with `yamllint`.
```
yamllint playbook.yml
playbook.yml
1:1 error too many blank lines (1 > 0) (empty-lines)
2:3 warning comment not indented like content (comments-indentation)
3:1 warning missing document start "---" (document-start)
3:81 error line too long (101 > 80 characters) (line-length)
8:20 error too many spaces before colon (colons)
13:7 error duplication of key "ios" in mapping (key-duplicates)
```
Now, fix the duplicate key error on line 13 in `playbook.yml` and run `ansible-lint`. Note the custom rule (in the `custom_rules` folder) that checks whether task names are written in all uppercase.
```
ansible-lint -Rr custom_rules playbook.yml
[289] All task names should be capitalized
playbook.yml:19
Task/Handler: Task 1 - ensure snmp commands exist on ios and vmx devices
[502] All tasks should be named
playbook.yml:23
Task/Handler: cli_config msg=A task without a name, so lazy! __line__=23 __file__=playbook.yml
```