-
Notifications
You must be signed in to change notification settings - Fork 62
Pylint Reporters
Reporters display messages when they are available. Each of the messages can focus on a particular aspect of the project, such as number of messages by categories. Right after, a global evaluation of the code is evaluated.
Taken from pylint.readthedocs.io
For instance, the metrics report displays summaries gathered from the current run.
- the number of processed modules
- for each module, the percentage of errors and warnings
- the total number of errors and warnings
- percentage of classes, functions and modules with docstrings, and a comparison from the previous run
- percentage of classes, functions and modules with correct name (according to the coding standard), and a comparison from the previous run
- a list of external dependencies found in the code, and where they appear
More information about Pylint and reporters in Pylint:
- Pylint doc
https://pylint.readthedocs.io/en/latest/ - Pylint reporters files
https://github.com/PyCQA/pylint/tree/master/pylint/reporters
When a user calls python_ta.check_all() to check a piece of code, ColorReporter and PlainReporter are also called and they:
-
- Piggyback on methods in Pylinter class https://github.com/PyCQA/pylint/blob/master/pylint/lint.py
-
- Overwrite the way PyLint reports errors to messages that are easier to read (Print statement)
More information about python_ta.check_all() and PyTA's custom reporters:
- python_ta
https://github.com/pyta-uoft/pyta/blob/master/python_ta/__init__.py - PyTA's custom reporters https://github.com/pyta-uoft/pyta/tree/master/python_ta/reporters
If your reporters are subclasses of BaseReporter, there are two main methods you should consider in addition to the instance method.
-
instance(self) You should initialize an empty list here to store the messages for later use.
-
handle_message(self, msg) This method lets you handle the given msg obg. handle_message should be implemented if msg has many properties and you need some way to sort them.
-
display_messages(self, layout) Essentially, what do you want to do with all the data? This is the most important method in reporters because this is a way for you to report what you have collected from Pylint's checkers. How do you want to display what you have collected?
As previously mentioned, when a user calls python_ta.check_all() to check a piece of code, ColorReporter and PlainReporter are also called, which means BaseReporter is called eventually.