A wrapper around pylint that analyzes a Django project file by file and calculates a weighted average based on lines of code for the whole project. It tweaks the pylint runs on the fly to accommodate for expected Django usage that doesn't necessarily follow pylint's guidelines.
In early usage, we find that an average rating of 7/10 or higher can be considered "good."
- More tweaking of pylint flags
- set MINIMUM_SCORE & EXCLUDE_DIRS via flags at runtime
An additional option (--local) has been added to allow you to limit the tests and coverage reports. We frequently want to know what the coverage is on code we wrote and not include Django itself or 3rd-party applications. --local expects a setting EXCLUDE_FROM_LOCAL_TESTS that is a list of application labels to skip when running the test suite. If you store your local applications within your project module, a line like this will suffice:
KWALITEE_LOCAL_EXCLUDES = [app.split('.')[-1] for app in INSTALLED_APPS \ if not app.startswith('[my_project]')]
Replace [my_project] with the name of your project.
Some common modules really shouldn't be reported via coverage as they skew the results. These can be excluded via regular expressions on the module name. We typically use the following:
KWALITEE_COVERAGE_EXCLUDES = (r'\.tests(\.|$)', r'\.migrations\.', r'\.evolutions\.')
- Add django_kwalitee to your INSTALLED_APPS.
- ./manage.py test --help
- Pass minimum coverage requirement in via the options and exit with a failure if they are not met.
This project was inspired by the following projects. There is overlap, but for one reason or another, they didn't quite fit our needs.