How to create & use pylint in python???
Disable the message, report, category or checker with the given id(s). If you or your team ends up choosing not to enforce certain errors or warnings that pylint produces, just add the error number (or in later versions, the human readable string) to disable the messages from showing up.
output-format=colorize
Set the output format. Available formats are text, parseable, colorized, msvs (visual studio) and html. You can also give a reporter class, mypackage.mymodule.MyReporterClass. Going to default to colorize.
reports=no
Tells whether to display a full report or only the messages. No reports by default for me.
max-line-length=120
Maximum number of characters on a single line. I'm going to set this from 80 to 120. Purists out there, all I have to say is, "Haters gonna hate." :)
generated-members=objects
List of members which are set dynamically and missed by pylint inference system. Django ORM's 'objects' is only value I have presently. Feel free to suggest other common generated members.
Similarities Section
Similar lines in %s files Indicates that a set of similar lines has been detected among multiple file. This usually means that the code should be refactored to avoid this duplication. I love the idea that pylint does this and I'd like to get some feedback for folks who encountered this error and how accurate it was.
Design Section
This sections is my favorite. It points out possible design flaws in your code based on a set of rules you can tweak. I consider my OO design to be pretty darn good, but as I was quickly porting a simple all in one command line program into classes, I got flagged with 'max-attributes' error. The error states if that you have more than 7 attributes you're most likely doing something wrong. (I had 8) It pointed out 5 of those attributes belonged in a separate class of their own and made my design cleaner (which never really hurts)
Introduction:
- Pylint is a source code bug and quality checker for the Python programming language. It follows the style recommended by PEP 8, the Python style guide. It is similar to Pychecker but includes the following features: Checking the length of each line.
- Pylint is a Python tool that checks a module for coding standards. According to the TurboGears project coding guidelines, PEP8 is the standard and pylint is a good mechanical test to help us in attaining that goal.
- The range of checks run from Python errors, missing docstrings, unused imports, unintended redefinition of built-ins, to bad naming and more.
Installation:
- You can simply install pylint: easy_install pylint or pip install pylint
- if you want to use django-python plugin , then use "pip install pylint-django".
- & you can create custom config file of pylint: pylint --generate-rcfile > ~/.pylintrc
Explore and Tweak To Your Liking
The resulting file is pretty lengthy, but I'd like to highlight some of the various options and sections that I took interest in. I took some of the descriptions directly from the documentation. disable=Disable the message, report, category or checker with the given id(s). If you or your team ends up choosing not to enforce certain errors or warnings that pylint produces, just add the error number (or in later versions, the human readable string) to disable the messages from showing up.
output-format=colorize
Set the output format. Available formats are text, parseable, colorized, msvs (visual studio) and html. You can also give a reporter class, mypackage.mymodule.MyReporterClass. Going to default to colorize.
reports=no
Tells whether to display a full report or only the messages. No reports by default for me.
max-line-length=120
Maximum number of characters on a single line. I'm going to set this from 80 to 120. Purists out there, all I have to say is, "Haters gonna hate." :)
generated-members=objects
List of members which are set dynamically and missed by pylint inference system. Django ORM's 'objects' is only value I have presently. Feel free to suggest other common generated members.
Similarities Section
Similar lines in %s files Indicates that a set of similar lines has been detected among multiple file. This usually means that the code should be refactored to avoid this duplication. I love the idea that pylint does this and I'd like to get some feedback for folks who encountered this error and how accurate it was.
Design Section
This sections is my favorite. It points out possible design flaws in your code based on a set of rules you can tweak. I consider my OO design to be pretty darn good, but as I was quickly porting a simple all in one command line program into classes, I got flagged with 'max-attributes' error. The error states if that you have more than 7 attributes you're most likely doing something wrong. (I had 8) It pointed out 5 of those attributes belonged in a separate class of their own and made my design cleaner (which never really hurts)