253 @param name name to be checked (string) |
253 @param name name to be checked (string) |
254 @return flag indicating to avoid it (boolen) |
254 @return flag indicating to avoid it (boolen) |
255 """ |
255 """ |
256 return name in ("l", "O", "I") |
256 return name in ("l", "O", "I") |
257 |
257 |
258 def __checkNameToBeAvoided(self, node, parents): |
258 def __checkNameToBeAvoided(self, node, parents): # noqa: U100 |
259 """ |
259 """ |
260 Private class to check the given node for a name to be avoided (N831). |
260 Private class to check the given node for a name to be avoided (N831). |
261 |
261 |
262 @param node AST note to check |
262 @param node AST note to check |
263 @param parents list of parent nodes |
263 @param parents list of parent nodes |
358 |
358 |
359 superClasses = self.__superClassNames(name, parents) |
359 superClasses = self.__superClassNames(name, parents) |
360 if "Exception" in superClasses and not name.endswith("Error"): |
360 if "Exception" in superClasses and not name.endswith("Error"): |
361 yield self.__error(node, "N818") |
361 yield self.__error(node, "N818") |
362 |
362 |
363 def __checkFunctionName(self, node, parents): |
363 def __checkFunctionName(self, node, parents): # noqa: U100 |
364 """ |
364 """ |
365 Private class to check the given node for function name |
365 Private class to check the given node for function name |
366 conventions (N802, N809). |
366 conventions (N802, N809). |
367 |
367 |
368 Function names should be lowercase, with words separated by underscores |
368 Function names should be lowercase, with words separated by underscores |
385 if name.lower() != name: |
385 if name.lower() != name: |
386 yield self.__error(node, "N802") |
386 yield self.__error(node, "N802") |
387 if functionType == "function" and name[:2] == "__" and name[-2:] == "__": |
387 if functionType == "function" and name[:2] == "__" and name[-2:] == "__": |
388 yield self.__error(node, "N809") |
388 yield self.__error(node, "N809") |
389 |
389 |
390 def __checkFunctionArgumentNames(self, node, parents): |
390 def __checkFunctionArgumentNames(self, node, parents): # noqa: U100 |
391 """ |
391 """ |
392 Private class to check the argument names of functions |
392 Private class to check the argument names of functions |
393 (N803, N804, N805, N806). |
393 (N803, N804, N805, N806). |
394 |
394 |
395 The argument names of a function should be lowercase, with words |
395 The argument names of a function should be lowercase, with words |
593 isinstance(nodeValue.func, ast.Name) |
593 isinstance(nodeValue.func, ast.Name) |
594 and nodeValue.func.id == "namedtuple" |
594 and nodeValue.func.id == "namedtuple" |
595 ) |
595 ) |
596 ) |
596 ) |
597 |
597 |
598 def __checkModule(self, node, parents): |
598 def __checkModule(self, node, parents): # noqa: U100 |
599 """ |
599 """ |
600 Private method to check module naming conventions (N807, N808). |
600 Private method to check module naming conventions (N807, N808). |
601 |
601 |
602 Module and package names should be lowercase. |
602 Module and package names should be lowercase. |
603 |
603 |
615 # we got a package |
615 # we got a package |
616 packageName = os.path.split(os.path.dirname(self.__filename))[1] |
616 packageName = os.path.split(os.path.dirname(self.__filename))[1] |
617 if packageName.lower() != packageName: |
617 if packageName.lower() != packageName: |
618 yield self.__error(node, "N808") |
618 yield self.__error(node, "N808") |
619 |
619 |
620 def __checkImportAs(self, node, parents): |
620 def __checkImportAs(self, node, parents): # noqa: U100 |
621 """ |
621 """ |
622 Private method to check that imports don't change the |
622 Private method to check that imports don't change the |
623 naming convention (N811, N812, N813, N814, N815). |
623 naming convention (N811, N812, N813, N814, N815). |
624 |
624 |
625 @param node AST note to check |
625 @param node AST note to check |