suoto/hdl_checker

View on GitHub

Showing 152 of 152 total issues

Function run_command has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
    """Call the given command(s)."""
    assert isinstance(commands, list)
    p = None
    for c in commands:
Severity: Minor
Found in versioneer.py - About 2 hrs 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 _getBuildSequence has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def _getBuildSequence(self, path, builtin_libraries):
        # type: (Path, FrozenSet[Identifier]) -> Iterable[Tuple[Identifier, Path]]
        """
        Gets the build sequence that satisfies the preconditions to compile the
        given path
Severity: Minor
Found in hdl_checker/database.py - About 2 hrs 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 run_command has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
    """Call the given command(s)."""
    assert isinstance(commands, list)
    p = None
    for c in commands:
Severity: Minor
Found in hdl_checker/_version.py - About 2 hrs 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 _getRebuilds has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def _getRebuilds(self, path, line, library):
        # type: (Path, str, Identifier) -> Set[RebuildInfo]
        """
        Gets info on what should be rebuilt to satisfy the builder
        """
Severity: Minor
Found in hdl_checker/builders/base_builder.py - About 2 hrs 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

File msim.py has 259 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/builders/msim.py - About 2 hrs to fix

    Function git_pieces_from_vcs has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
        """Get version from 'git describe' in the root of the source tree.
    
        This only gets called if the git-archive 'subst' keywords were *not*
        expanded, and _version.py hasn't already been rewritten with a short
    Severity: Minor
    Found in versioneer.py - About 2 hrs 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 git_pieces_from_vcs has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
        """Get version from 'git describe' in the root of the source tree.
    
        This only gets called if the git-archive 'subst' keywords were *not*
        expanded, and _version.py hasn't already been rewritten with a short
    Severity: Minor
    Found in hdl_checker/_version.py - About 2 hrs 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

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

    def removeIfExists(filename):
        # type: (str) -> bool
        "Removes filename using os.remove and catches the exception if that fails"
        try:
            os.remove(filename)
    Severity: Major
    Found in hdl_checker/utils.py and 1 other location - About 2 hrs to fix
    hdl_checker/utils.py on lines 297..309

    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 51.

    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

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

    def removeDirIfExists(dirname):
        # type: (str) -> bool
        """
        Removes the directory dirname using shutil.rmtree and catches the exception
        if that fails
    Severity: Major
    Found in hdl_checker/utils.py and 1 other location - About 2 hrs to fix
    hdl_checker/utils.py on lines 285..294

    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 51.

    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

    Function _buildAndGetDiagnostics has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _buildAndGetDiagnostics(
            self, path, library, flags
        ):  # type: (Path, Identifier, BuildFlags) -> Tuple[Set[CheckerDiagnostic],Set[RebuildInfo]]
            """
            Runs _buildSource method and parses the output to find message
    Severity: Minor
    Found in hdl_checker/builders/base_builder.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 git_versions_from_keywords has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def git_versions_from_keywords(keywords, tag_prefix, verbose):
        """Get version information from git keywords."""
        if not keywords:
            raise NotThisMethod("no keywords at all, weird")
        refnames = keywords["refnames"].strip()
    Severity: Minor
    Found in hdl_checker/_version.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 _expand has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def _expand(config, ref_path):
        # type: (Dict[str, Any], str) -> Iterable[SourceEntry]
        """
        Expands the sources defined in the config dict into a list of tuples
        """
    Severity: Minor
    Found in hdl_checker/parser_utils.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 git_versions_from_keywords has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def git_versions_from_keywords(keywords, tag_prefix, verbose):
        """Get version information from git keywords."""
        if not keywords:
            raise NotThisMethod("no keywords at all, weird")
        refnames = keywords["refnames"].strip()
    Severity: Minor
    Found in versioneer.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

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

    class VhdlDesignUnit(_DesignUnit):
        """
        Specifies a design unit whose name is case insensitive
        """
    
    
    Severity: Major
    Found in hdl_checker/parsers/elements/design_unit.py and 1 other location - About 1 hr to fix
    hdl_checker/parsers/elements/design_unit.py on lines 124..132

    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 48.

    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

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

    class VerilogDesignUnit(_DesignUnit):
        """
        Specifies a design unit whose name is case sensitive
        """
    
    
    Severity: Major
    Found in hdl_checker/parsers/elements/design_unit.py and 1 other location - About 1 hr to fix
    hdl_checker/parsers/elements/design_unit.py on lines 112..120

    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 48.

    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

    Function getIncludedConfigs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def getIncludedConfigs(search_paths, root_dir="."):
        # type: (Iterable[str], str) -> Iterable[Tuple[str, Dict[str, Any]]]
        "Returns configuration contents of included files"
        # Copy the dict to avoid messing up with the caller's env
    
    
    Severity: Minor
    Found in hdl_checker/parser_utils.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 getMessagesByPath has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def getMessagesByPath(self, path):
            # type: (Path) -> Iterable[CheckerDiagnostic]
            """
            Returns the messages for the given path, including messages
            from the configured builder (if available) and static checks
    Severity: Minor
    Found in hdl_checker/core.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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def run(args):
        """
        Import modules and tries to start a hdl_checker server
        """
        # LSP will use stdio to communicate
    Severity: Minor
    Found in hdl_checker/server.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

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

                if match["package_name"] is not None:
                    yield VerilogDesignUnit(
                        owner=self.filename,
                        name=match["package_name"],
                        type_=DesignUnitType.package,
    Severity: Major
    Found in hdl_checker/parsers/verilog_parser.py and 2 other locations - About 1 hr to fix
    hdl_checker/parsers/verilog_parser.py on lines 142..146
    hdl_checker/parsers/vhdl_parser.py on lines 206..217

    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 46.

    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

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

                if match["module_name"] is not None:
                    yield VerilogDesignUnit(
                        owner=self.filename,
                        name=match["module_name"],
                        type_=DesignUnitType.entity,
    Severity: Major
    Found in hdl_checker/parsers/verilog_parser.py and 2 other locations - About 1 hr to fix
    hdl_checker/parsers/verilog_parser.py on lines 149..153
    hdl_checker/parsers/vhdl_parser.py on lines 206..217

    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 46.

    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

    Severity
    Category
    Status
    Source
    Language