agronholm/typeguard

View on GitHub

Showing 66 of 66 total issues

Function check_send_type has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def check_send_type(
    func_name: str,
    sendval: T,
    annotation: Any,
    memo: TypeCheckMemo,
Severity: Minor
Found in src/typeguard/_functions.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function visit_BinOp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def visit_BinOp(self, node: BinOp) -> Any:
        self.generic_visit(node)

        if isinstance(node.op, BitOr):
            # If either branch of the BinOp has been transformed to `None`, it means
Severity: Minor
Found in src/typeguard/_transformer.py - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function check_yield_type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def check_yield_type(
    func_name: str,
    yieldval: T,
    annotation: Any,
    memo: TypeCheckMemo,
Severity: Minor
Found in src/typeguard/_functions.py - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid deeply nested control flow statements.
Open

                        if sys.version_info < (3, 9):
                            subscript_slice = Index(subscript_slice, ctx=Load())

Severity: Major
Found in src/typeguard/_transformer.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if is_method_of(property_func, target):
                            retval = instrument(property_func)
                            if isfunction(retval):
                                kwargs[name] = retval
    
    
    Severity: Major
    Found in src/typeguard/_decorators.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if sys.version_info < (3, 9):
                                  subscript_slice = Index(subscript_slice, ctx=Load())
      
      
      Severity: Major
      Found in src/typeguard/_transformer.py - About 45 mins to fix

        Function typechecked has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def typechecked(
        Severity: Minor
        Found in src/typeguard/_decorators.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if len(items) > 1:
                                      new_memo.send_annotation = self._convert_annotation(
                                          items[1]
                                      )
          
          
          Severity: Major
          Found in src/typeguard/_transformer.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if len(items) > 2:
                                        new_memo.return_annotation = self._convert_annotation(
                                            items[2]
                                        )
                            else:
            Severity: Major
            Found in src/typeguard/_transformer.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if node.args.args:
                                          if node.name == "__new__":
                                              memo_kwargs["self_type"] = Name(
                                                  id=node.args.args[0].arg, ctx=Load()
                                              )
              Severity: Major
              Found in src/typeguard/_transformer.py - About 45 mins to fix

                Function check_type has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def check_type(
                Severity: Minor
                Found in src/typeguard/_functions.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if isinstance(decorator, Call) and decorator.keywords:
                                              self._memo.configuration_overrides = {
                                                  kw.arg: kw.value for kw in decorator.keywords if kw.arg
                                              }
                  
                  
                  Severity: Major
                  Found in src/typeguard/_transformer.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (
                                                isinstance(decorator, Name)
                                                and decorator.id == "staticmethod"
                                            ):
                                                break
                    Severity: Major
                    Found in src/typeguard/_transformer.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if expression is None:
                                                  item[key] = self._get_import("typing", "Any")
                      
                      
                      Severity: Major
                      Found in src/typeguard/_transformer.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if isfunction(retval):
                                                wrapper = attr.__class__(retval)
                                                setattr(target, key, wrapper)
                                    elif isinstance(attr, property):
                        Severity: Major
                        Found in src/typeguard/_decorators.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if isinstance(annotation_slice, Index):
                                                      annotation_slice = (
                                                          annotation_slice.value  # type: ignore[attr-defined]
                                                      )
                          
                          
                          Severity: Major
                          Found in src/typeguard/_transformer.py - About 45 mins to fix

                            Function is_ignored_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def is_ignored_name(self, expression: expr | Expr | None) -> bool:
                                    top_expression = (
                                        expression.value if isinstance(expression, Expr) else expression
                                    )
                            
                            
                            Severity: Minor
                            Found in src/typeguard/_transformer.py - About 45 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Avoid deeply nested control flow statements.
                            Open

                                                    if len(items) > 0:
                                                        new_memo.yield_annotation = self._convert_annotation(
                                                            items[0]
                                                        )
                            
                            
                            Severity: Major
                            Found in src/typeguard/_transformer.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if sys.version_info >= (3, 9):
                                                          container = Name("tuple", ctx=Load())
                                                      else:
                                                          container = self._get_import("typing", "Tuple")
                              
                              
                              Severity: Major
                              Found in src/typeguard/_transformer.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if annotation:
                                                            annotations_[Constant(name)] = annotation
                                                            check_required = True
                                                        else:
                                                            annotations_[Constant(name)] = None
                                Severity: Major
                                Found in src/typeguard/_transformer.py - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language