suoto/hdl_checker

View on GitHub

Showing 152 of 152 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if diagnostics:
            self._logger.debug("Diagnostic messages found")
            for record in diagnostics:
                self._logger.debug(record)
Severity: Minor
Found in hdl_checker/builders/base_builder.py and 1 other location - About 30 mins to fix
hdl_checker/builders/base_builder.py on lines 369..372

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 32.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid too many return statements within this function.
Open

    return {"version": "0+unknown", "full-revisionid": None,
Severity: Major
Found in versioneer.py - About 30 mins to fix

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

    def get_versions():
        """Get version information or return default if unable to do so."""
        # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
        # __file__, we can work backwards from there to the root. Some
        # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
    Severity: Minor
    Found in hdl_checker/_version.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 default has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def default(self, o):  # pylint: disable=method-hidden
            if hasattr(o, "__jsonEncode__"):
                dct = o.__jsonEncode__()
                # Set a __class__ entry into the dict so we can use it to get from
                # CLASS_MAP when recreating the object
    Severity: Minor
    Found in hdl_checker/serialization.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 get_root has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_root():
        """Get the project root directory.
    
        We require that all commands are run from the project root, i.e. the
        directory that contains setup.py, setup.cfg, and versioneer.py .
    Severity: Minor
    Found in versioneer.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 _updatePathLibrary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _updatePathLibrary(self, path, library):
            # type: (Path, Identifier) -> None
            """
            Updates dependencies of the given path so they reflect the change in
            their owner's path
    Severity: Minor
    Found in hdl_checker/database.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 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 _getMiscChecks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def _getMiscChecks(objects):
        """
        Get generic code hints (or it should do that sometime in the future...)
        """
        if "library" not in [x["type"] for x in objects.values()]:
    Severity: Minor
    Found in hdl_checker/static_check.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 getLibrary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def getLibrary(self, path):
            # type: (Path) -> UnresolvedLibrary
            """
            Gets the library the path is in, inferring and updating it if needed.
            Any unit that can be used from VHDL code can be bound to a library,
    Severity: Minor
    Found in hdl_checker/database.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 _parseArguments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parseArguments():
        parser = argparse.ArgumentParser()
    
        # Options
        parser.add_argument(
    Severity: Minor
    Found in .ci/scripts/run_tests.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, locations=None):
            # type: (Optional[LocationList]) -> None
            set_of_locations = set()  # type: Set[Location]
            for line_number, column_number in locations or []:
                set_of_locations.add(
    Severity: Minor
    Found in hdl_checker/parsers/elements/parsed_element.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

    Severity
    Category
    Status
    Source
    Language