# eric6.Plugins.CheckerPlugins.CodeStyleChecker.NamingStyleChecker

Module implementing a checker for naming conventions.

### Global Attributes

None

### Classes

NamingStyleChecker | Class implementing a checker for naming conventions.

### Functions

None

## NamingStyleChecker

Class implementing a checker for naming conventions.

### Derived from

object

### Class Attributes

CamelcaseRegexp
Codes
LowercaseRegex
MixedcaseRegexp
UppercaseRegexp

### Class Methods

None

### Methods

NamingStyleChecker | Constructor (according to 'extended' pycodestyle.py API)
__checkClassName | Private class to check the given node for class name conventions (N801).
__checkFunctionArgumentNames | Private class to check the argument names of functions (N803, N804, N805, N806).
__checkFunctionName | Private class to check the given node for function name conventions (N802).
__checkImportAs | Private method to check that imports don't change the naming convention (N811, N812, N813, N814).
__checkModule | Private method to check module naming conventions (N807, N808).
__checkNameToBeAvoided | Private class to check the given node for a name to be avoided (N831).
__checkVariablesInFunction | Private method to check local variables in functions (N821).
__error | Private method to build the error information.
__findGlobalDefs | Private method amend a node with global definitions information.
__getArgNames | Private method to get the argument names of a function node.
__isNameToBeAvoided | Private method to check, if the given name should be avoided.
__tagClassFunctions | Private method to tag functions if they are methods, class methods or static methods.
__visitNode | Private method to inspect the given AST node.
__visitTree | Private method to scan the given AST tree.
run | Public method run by the pycodestyle.py checker.
unpackArgs | Local helper function to unpack function argument names.

### Static Methods

None

#### NamingStyleChecker (Constructor)

NamingStyleChecker(tree, filename, options)

Constructor (according to 'extended' pycodestyle.py API)

tree
  AST tree of the source file
filename
  name of the source file (string)
options
  options as parsed by pycodestyle.StyleGuide

#### NamingStyleChecker.__checkClassName

__checkClassName(node, parents)

Private class to check the given node for class name conventions (N801).

Almost without exception, class names use the CapWords convention. Classes for internal use have a leading underscore in addition.

node
  AST note to check
parents
  list of parent nodes

Returns:
  tuple giving line number, offset within line and error code (integer, integer, string)

#### NamingStyleChecker.__checkFunctionArgumentNames

__checkFunctionArgumentNames(node, parents)

Private class to check the argument names of functions (N803, N804, N805, N806).

The argument names of a function should be lowercase, with words separated by underscores. A class method should have 'cls' as the first argument. A method should have 'self' as the first argument.

node
  AST note to check
parents
  list of parent nodes

Returns:
  tuple giving line number, offset within line and error code (integer, integer, string)

#### NamingStyleChecker.__checkFunctionName

__checkFunctionName(node, parents)

Private class to check the given node for function name conventions (N802).

Function names should be lowercase, with words separated by underscores as necessary to improve readability. Functions not being methods '__' in front and back are not allowed. Mixed case is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards compatibility.

node
  AST note to check
parents
  list of parent nodes

Returns:
  tuple giving line number, offset within line and error code (integer, integer, string)

#### NamingStyleChecker.__checkImportAs

__checkImportAs(node, parents)

Private method to check that imports don't change the naming convention (N811, N812, N813, N814).

node
  AST note to check
parents
  list of parent nodes

Returns:
  tuple giving line number, offset within line and error code (integer, integer, string)

#### NamingStyleChecker.__checkModule

__checkModule(node, parents)

Private method to check module naming conventions (N807, N808).

Module and package names should be lowercase.

node
  AST note to check
parents
  list of parent nodes

Returns:
  tuple giving line number, offset within line and error code (integer, integer, string)

#### NamingStyleChecker.__checkNameToBeAvoided

__checkNameToBeAvoided(node, parents)

Private class to check the given node for a name to be avoided (N831).

node
  AST note to check
parents
  list of parent nodes

Returns:
  tuple giving line number, offset within line and error code (integer, integer, string)

#### NamingStyleChecker.__checkVariablesInFunction

__checkVariablesInFunction(node, parents)

Private method to check local variables in functions (N821).

Local variables in functions should be lowercase.

node
  AST note to check
parents
  list of parent nodes

Returns:
  tuple giving line number, offset within line and error code (integer, integer, string)

#### NamingStyleChecker.__error

__error(node, code)

Private method to build the error information.

node
  AST node to report an error for
code
  error code to report (string)

Returns:
  tuple giving line number, offset within line and error code (integer, integer, string)

#### NamingStyleChecker.__findGlobalDefs

__findGlobalDefs(functionNode)

Private method amend a node with global definitions information.

functionNode
  AST tree node to amend

#### NamingStyleChecker.__getArgNames

__getArgNames(node)

Private method to get the argument names of a function node.

node
  AST node to extract arguments names from

Returns:
  list of argument names (list of string)

#### NamingStyleChecker.__isNameToBeAvoided

__isNameToBeAvoided(name)

Private method to check, if the given name should be avoided.

name
  name to be checked (string)

Returns:
  flag indicating to avoid it (boolen)

#### NamingStyleChecker.__tagClassFunctions

__tagClassFunctions(classNode)

Private method to tag functions if they are methods, class methods or static methods.

classNode
  AST tree node to tag

#### NamingStyleChecker.__visitNode

__visitNode(node)

Private method to inspect the given AST node.

node
  AST tree node to inspect

Returns:
  tuple giving line number, offset within line, code and checker function

#### NamingStyleChecker.__visitTree

__visitTree(node)

Private method to scan the given AST tree.

node
  AST tree node to scan

Returns:
  tuple giving line number, offset within line, code and checker function

#### NamingStyleChecker.run

run()

Public method run by the pycodestyle.py checker.

Returns:
  tuple giving line number, offset within line, code and checker function

#### NamingStyleChecker.unpackArgs

unpackArgs()

Local helper function to unpack function argument names.

args
  list of AST node arguments

Returns:
  list of argument names (list of string)

Up