class documentation

class MisdesignChecker(BaseChecker): (source)

View In Hierarchy

Checker of potential misdesigns. Checks for sign of poor/misdesign: * number of methods, attributes, local variables... * size, complexity of functions, methods

Method __init__ Checker instances should have the linter as argument.
Method leave_classdef Check number of public methods.
Method leave_functiondef Most of the work is done here on close: checks for max returns, branch, return in __init__.
Method open Initialize visit variables.
Method visit_classdef Check size of inheritance hierarchy and number of instance attributes.
Method visit_default Default visit method -> increments the statements counter if necessary.
Method visit_functiondef Check function name, docstring, arguments, redefinition, variable names, max locals.
Method visit_if Increments the branches counter and checks boolean expressions.
Method visit_return Count number of returns.
Method visit_tryexcept Increments the branches counter.
Method visit_tryfinally Increments the branches counter.
Method visit_while Increments the branches counter.
Class Variable name Name of the provider.
Class Variable options Options provided by this provider.
Method _check_boolean_expressions Go through "if" node `node` and count its boolean expressions if the 'if' node test is a BoolOp node.
Method _inc_all_stmts Undocumented
Method _inc_branch Increments the branches counter.
Instance Variable _branches Undocumented
Instance Variable _exclude_too_few_public_methods Undocumented
Instance Variable _returns Undocumented
Instance Variable _stmts Undocumented

Inherited from BaseChecker:

Method __eq__ Permit to assert Checkers are equal.
Method __gt__ Sorting of checkers.
Method __hash__ Make Checker hashable.
Method __repr__ Undocumented
Method __str__ This might be incomplete because multiple classes inheriting BaseChecker can have the same name.
Method add_message Undocumented
Method check_consistency Check the consistency of msgid.
Method close Called after visiting project (i.e set of modules).
Method create_message_definition_from_tuple Undocumented
Method get_full_documentation Undocumented
Method get_map_data Undocumented
Method get_message_definition Undocumented
Method reduce_map_data Undocumented
Class Variable enabled Undocumented
Class Variable msgs Undocumented
Class Variable reports Undocumented
Instance Variable linter Undocumented
Property messages Undocumented

Inherited from _ArgumentsProvider (via BaseChecker):

Method get_option_def DEPRECATED: Return the dictionary defining an option given its name.
Method level.setter Undocumented
Method load_defaults DEPRECATED: Initialize the provider using default values.
Method option_attrname DEPRECATED: Get the config attribute corresponding to opt.
Method option_value DEPRECATED: Get the current value for the given option.
Method options_and_values DEPRECATED.
Method options_by_section DEPRECATED: Return an iterator on options grouped by section.
Method set_option DEPRECATED: Method called to set an option (registered in the options list).
Class Variable option_groups_descs Option groups of this provider and their descriptions.
Property config Undocumented
Property level Undocumented
Instance Variable _arguments_manager The manager that will parse and register any options provided.
Instance Variable _level Undocumented
def __init__(self, linter: PyLinter): (source)

Checker instances should have the linter as argument.

@only_required_for_messages('too-few-public-methods', 'too-many-public-methods')
def leave_classdef(self, node: nodes.ClassDef): (source)

Check number of public methods.

@only_required_for_messages('too-many-return-statements', 'too-many-branches', 'too-many-arguments', 'too-many-locals', 'too-many-statements')
def leave_functiondef(self, node: nodes.FunctionDef): (source)

Most of the work is done here on close: checks for max returns, branch, return in __init__.

def open(self): (source)

Initialize visit variables.

@only_required_for_messages('too-many-ancestors', 'too-many-instance-attributes', 'too-few-public-methods', 'too-many-public-methods')
def visit_classdef(self, node: nodes.ClassDef): (source)

Check size of inheritance hierarchy and number of instance attributes.

def visit_default(self, node: nodes.NodeNG): (source)

Default visit method -> increments the statements counter if necessary.

@only_required_for_messages('too-many-return-statements', 'too-many-branches', 'too-many-arguments', 'too-many-locals', 'too-many-statements', 'keyword-arg-before-vararg')
def visit_functiondef(self, node: nodes.FunctionDef): (source)

Check function name, docstring, arguments, redefinition, variable names, max locals.

@only_required_for_messages('too-many-boolean-expressions', 'too-many-branches')
def visit_if(self, node: nodes.If): (source)

Increments the branches counter and checks boolean expressions.

def visit_return(self, _: nodes.Return): (source)

Count number of returns.

def visit_tryexcept(self, node: nodes.TryExcept): (source)

Increments the branches counter.

def visit_tryfinally(self, node: nodes.TryFinally): (source)

Increments the branches counter.

def visit_while(self, node: nodes.While): (source)

Increments the branches counter.

Name of the provider.

options: tuple[tuple, ...] = (source)

Options provided by this provider.

def _check_boolean_expressions(self, node: nodes.If): (source)

Go through "if" node `node` and count its boolean expressions if the 'if' node test is a BoolOp node.

def _inc_all_stmts(self, amount: int): (source)

Undocumented

def _inc_branch(self, node: nodes.NodeNG, branchesnum: int = 1): (source)

Increments the branches counter.

_branches = (source)

Undocumented

_exclude_too_few_public_methods = (source)

Undocumented

_returns: list = (source)

Undocumented

Undocumented