Bases: ast.NodeVisitor
Provides a simple framework for writing AST-based checks.
Subclasses should implement visit_* methods like any other AST visitor implementation. When they detect an error for a particular node the method should call self.add_error(offending_node). Details about where in the code the error occurred will be pulled from the node object.
Subclasses should also provide a class variable named CHECK_DESC to be used for the human readable error message.
Add an error caused by a node to the list of errors for pep8.
Called automatically by pep8.
Bases: cinder.hacking.checks.BaseASTChecker
Checks for the use of str() or unicode() on an exception.
This currently only handles the case where str() or unicode() is used in the scope of an exception handler. If the exception is passed into a function, returned from an assertRaises, or used on an exception created in the same scope, this does not catch it.
Bases: cinder.hacking.checks.BaseASTChecker
Check for improper use of logging format arguments.
The format arguments should not be a tuple as it is easy to miss.
Look for the ‘LOG.*’ calls.
Bases: cinder.hacking.checks.BaseASTChecker
Verifying the registration of options are well formed
This class creates a check for single opt or list/tuple of opts when register_opt() or register_opts() are being called.
Look for the register_opt/register_opts calls.
Check for explicit import of the _ function
We need to ensure that any files that are using the _() function to translate logs are explicitly importing the _ function. We can’t trust unit test to catch whether the import has been added so we need to check for it here.
Ensure that we are not using LOG.audit messages
Plans are in place going forward as discussed in the following spec (https://review.openstack.org/#/c/91446/) to take out LOG.audit messages. Given that audit was a concept invented for OpenStack we can enforce not using it.
Check for ‘LOG.debug(_(‘
As per our translation policy, https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation we shouldn’t translate debug level logs.
N319
Check for vi editor configuration in source files.
By default vi modelines can only appear in the first or last 5 lines of a source file.
N314