suoto/hdl_checker

View on GitHub
hdl_checker/lsp.py

Summary

Maintainability
C
1 day
Test Coverage

File lsp.py has 455 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# This file is part of HDL Checker.
#
# Copyright (c) 2015 - 2019 suoto (Andre Souto)
#
# HDL Checker is free software: you can redistribute it and/or modify
Severity: Minor
Found in hdl_checker/lsp.py - About 6 hrs to fix

    Function definitions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def definitions(
            self, params: TextDocumentPositionParams
        ) -> Optional[List[Location]]:
            """
            Returns known definitions found in the given location
    Severity: Minor
    Found in hdl_checker/lsp.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 references has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def references(self, params: ReferenceParams) -> Optional[List[Location]]:
            "Tries to find references for the selected element"
    
            element = self.getElementAtPosition(
                Path(to_fs_path(params.textDocument.uri)), params.position
    Severity: Minor
    Found in hdl_checker/lsp.py - About 35 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 too many return statements within this function.
    Open

            return locations
    Severity: Major
    Found in hdl_checker/lsp.py - About 30 mins to fix

      Function getDependencyInfoForHover has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def getDependencyInfoForHover(self, dependency):
              # type: (BaseDependencySpec) -> str
              """
              Report which source defines a given dependency when the user hovers
              over its name
      Severity: Minor
      Found in hdl_checker/lsp.py - About 25 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 getElementAtPosition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def getElementAtPosition(
              self, path: Path, position: Position
          ) -> Union[BaseDependencySpec, tAnyDesignUnit, None]:
              """
              Gets design units and dependencies (in this order) of path and checks
      Severity: Minor
      Found in hdl_checker/lsp.py - About 25 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

      There are no issues that match your filters.

      Category
      Status