Code quality tests
Project description
It is sometimes possible to tell that code stinks even without looking at it. This Django app tries to accomplish that.
Installation
pip install django-smelly-tokens
Usage
In your settings.py define SMELLY_TOKENS_APPLICATIONS list with packages you want to inspect.
In a package with code quality tests (e.g. test_tokens.py) import tests you want to check your apps against:
from smelly_tokens.test_smelly_tokens import (
EvalTokenTestCase,
PdbTokenTestCase,
)
Run django-admin.py test or ./manage.py test or py.test or nose or whatever runner you’re using.
Exceptions
To silence known errors PEP8-style noqa comment can be used in the beginning of a file:
# smelly_tokens: noqa
Or in-line:
eval('print 123') # noqa
To exclude an entire directory add it’s path to SMELLY_TOKENS_EXCLUDE_DIRS list in settings.
Adding your own tokens
To create a new type of smelly token test case, inherit SmellyTokensTestCase and override _tokens list:
from django.test import TestCase
from smelly_tokens.test_smelly_tokens import SmellyTokensTestCase
class OOPTokensTestCase(SmellyTokensTestCase, TestCase):
""" OOP hater. """
_tokens = ['class', 'object', 'Object']
References
Changelog
0.5.0 (2022-06-06)
Use pathlib for path manipulation.
0.4.6 (2020-09-21)
Better directory exclusion.
0.4.5 (2020-09-21)
New pkgutil.get_loader fix.
0.4.4 (2018-06-06)
#movingtogitlab
0.4 (2017-05-06)
Introduced zest.releaser.
Released to PyPI.
Documentation.
0.3 (2017-05-02)
Python 2 / 3 compatibility.
Multiple tokens per class.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-smelly-tokens-0.5.0.tar.gz
.
File metadata
- Download URL: django-smelly-tokens-0.5.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b092cc5176fcbdb97d6d6b2573b6fc6e72c1f09f11f8f70dd3c23c9ebc3aec6 |
|
MD5 | abecb71c5c7f7337d1f03535e27212c0 |
|
BLAKE2b-256 | ca2208d4a6270c0449e40ee4518c77a84d421e69441fb715229a596b8dfc598e |
File details
Details for the file django_smelly_tokens-0.5.0-py2.py3-none-any.whl
.
File metadata
- Download URL: django_smelly_tokens-0.5.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6ba75d411de9de057466e5f62c7b30265f41e0b3ace4c54ace4367a2bb825d6 |
|
MD5 | f6b64d288ecd9554c37281b4367ae969 |
|
BLAKE2b-256 | b20c2203789acc9893612eadc265fc5e1de89e71954cb05b13ab130431b53a81 |