Metadata-Version: 2.1
Name: django-smelly-tokens
Version: 0.4.6
Summary: Code quality tests
Home-page: https://gitlab.com/murchik/django-smelly-tokens
Author: murchik
Author-email: murchik@protonmail.com
License: GPLv3
Keywords: django-smelly-tokens
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Requires-Dist: Django (>=1.4)
Requires-Dist: pytest-django

####################
Django Smelly Tokens
####################

It is sometimes possible to tell that code stinks even without looking at it.
This Django app tries to accomplish that.

.. image:: https://gitlab.com/murchik/django-smelly-tokens/badges/master/build.svg
    :target: https://gitlab.com/murchik/django-smelly-tokens/commits/master
    :alt: Pipeline status

.. image:: https://readthedocs.org/projects/django-smelly-tokens/badge/?version=latest
    :target: https://django-smelly-tokens.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation status


Installation
============

.. code-block:: bash

    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:

.. code-block:: python

   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:


.. code-block:: python

   # smelly_tokens: noqa


Or in-line:


.. code-block:: python

   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:

.. code-block:: python

   from django.test import TestCase
   from smelly_tokens.test_smelly_tokens import SmellyTokensTestCase


   class OOPTokensTestCase(SmellyTokensTestCase, TestCase):
   """ OOP hater. """
   _tokens = ['class', 'object', 'Object']


References
==========

* `Full documentation <https://django-smelly-tokens.readthedocs.io/>`__;


Changelog
=========

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.


