Python "Elegant Object" Naive linter.
"Python Elegant Objects Naive" linter allows you to check your code for conditions of "Elegant objects" OOP architecture, proposed by yegor256
This repo works only for python code.
Priciple | Yes/No |
---|---|
No null | :heavy_check_mark: |
No code in constructors | :heavy_check_mark: |
No getters and setters | :heavy_check_mark: |
No mutable objects | :heavy_check_mark: |
No readers, parsers, controllers, sorters, and so on | :heavy_check_mark: |
No static methods, not even private ones | :heavy_check_mark: |
No instanceof, type casting, or reflection | :heavy_check_mark: |
No public methods without a contract | :x: |
No statements in test methods except assertThat | :heavy_check_mark: |
No ORM or ActiveRecord | :x: |
No implementation inheritance | :heavy_check_mark: |
:heavy_check_mark: - realized
:interrobang: - so-so (not sure)
:heavy_minus_sign: - not done yet
:x: - will never be done, i think
Version | Yes/No | Why |
---|---|---|
3.6 | :heavy_check_mark: | |
3.7 | :heavy_check_mark: | |
3.8 | :heavy_check_mark: | |
3.9 | :heavy_check_mark: |
Simply you should run something like this (dont forget to python3 setup.py install
)
peon ./path/to/code
or not recommended way
python3 ./peon/__main__.py
You can use this linter by adding it to pre-commit configuration file.
For example (for check all project):
- repo: https://github.com/roch1990/peon
rev: '0.13'
hooks:
- id: peon
stages:
- commit
args:
- ./peon
or (for check only changed files):
- repo: https://github.com/roch1990/peon
rev: '0.13'
hooks:
- id: peon
stages:
- commit
Because it checks only "plain definitions".
For example:
def some_function(some_arg):
some_var = some_arg
def some_function(some_arg):
def some_another_function(some_arg):
return some_arg
some_var = some_another_function(some_arg)
class SomeClass:
pass
class SomeClass:
class SomeAnotherClass:
pass
pass
After you clone repo:
python3 -m venv /path/to/new/virtual/environment
pip3 install - r ./peon/requirements.txt
pre-commit install
export PYTHONPATH=$PWD/peon
And then feel free to make a changes.
You can start local test:
make tests
this instruction starts - unit, mutual and security tests.
You can test pre-commit integration:
make local-run
Show results of mutual tests:
mutmut results
Show result of concrete mutual test:
mutmut show <test_id:int>
Easiest way is:
If all check would be passed - I check your changes so fast, as i can.
P.S.: falling of mutual tests - is normal now (in development, as you remember)
Every commit should start with keyword with colon:
feature:
(if you add new functionality)fix:
(if you fix bug or invalid behaviour)chore:
(if you fix something, that you were not going to fix)Then, after keyword you should shortly describe your changes:
feature: add sec test step to travis
Every pull request to dev should start with keyword pr-dev
and issue number:
pr-dev: 123
Every pull request to master should start with keyword pr
and issue number:
pr: 123