suoto/hdl_checker

View on GitHub

Showing 152 of 152 total issues

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

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

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

Function __init__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(  # pylint: disable=too-many-arguments
Severity: Major
Found in hdl_checker/diagnostics.py - About 1 hr to fix

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

        if "-" in git_describe:
            # TAG-NUM-gHEX
            mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe)
            if not mo:
                # unparseable. Maybe git-describe is misbehaving?
    Severity: Major
    Found in versioneer.py and 1 other location - About 1 hr to fix
    hdl_checker/_version.py on lines 239..270

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

    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 scan_setup_py has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def scan_setup_py():
        """Validate the contents of setup.py against Versioneer's expectations."""
        found = set()
        setters = False
        errors = 0
    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

    Function do_vcs_install has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def do_vcs_install(manifest_in, versionfile_source, ipy):
        """Git-specific installation logic for Versioneer.
    
        For Git, this means creating/changing .gitattributes to mark _version.py
        for export-time keyword substitution.
    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

    Function getVunitSources has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def getVunitSources(builder):
        # type: (AnyValidBuilder) -> Iterable[Tuple[Path, Optional[str], BuildFlags]]
        "Gets VUnit sources according to the file types supported by builder"
        if not foundVunit():
            return
    Severity: Minor
    Found in hdl_checker/builder_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 _makeRecords has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _makeRecords(self, line):
            # type: (str) -> Iterable[BuilderDiag]
            for match in self._stdout_message_scanner(line):  # type: ignore
                info = match.groupdict()
    
    
    Severity: Minor
    Found in hdl_checker/builders/msim.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

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

        if "-" in git_describe:
            # TAG-NUM-gHEX
            mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe)
            if not mo:
                # unparseable. Maybe git-describe is misbehaving?
    Severity: Major
    Found in hdl_checker/_version.py and 1 other location - About 1 hr to fix
    versioneer.py on lines 1091..1122

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

    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 findRtlSourcesByPath has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def findRtlSourcesByPath(path):
        # type: (Path) -> Iterable[Path]
        """
        Finds RTL sources (files with extensions within FileType enum) inside
        <path>
    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_get_keywords has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def git_get_keywords(versionfile_abs):
        """Extract version information from the given file."""
        # the code embedded in _version.py can just fetch the value of these
        # keywords. When used from setup.py, we don't want to import _version.py,
        # so we do it with a regexp instead. This function is not used from
    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

    Function _handleRebuilds has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _handleRebuilds(self, rebuilds):
            # type: (Iterable[RebuildInfo]) -> None
            """
            Resolves hints found in the rebuild list into path objects
            and rebuild them
    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

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

                obj._flags_map[path][BuildFlagScope.single] = tuple(
                    info.get("flags", {}).pop(BuildFlagScope.single.value, ())
    Severity: Major
    Found in hdl_checker/database.py and 2 other locations - About 1 hr to fix
    hdl_checker/database.py on lines 308..309
    hdl_checker/database.py on lines 314..315

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

    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 git_get_keywords has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def git_get_keywords(versionfile_abs):
        """Extract version information from the given file."""
        # the code embedded in _version.py can just fetch the value of these
        # keywords. When used from setup.py, we don't want to import _version.py,
        # so we do it with a regexp instead. This function is not used from
    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

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

                obj._flags_map[path][BuildFlagScope.source_specific] = tuple(
                    info.get("flags", {}).pop(BuildFlagScope.source_specific.value, ())
    Severity: Major
    Found in hdl_checker/database.py and 2 other locations - About 1 hr to fix
    hdl_checker/database.py on lines 311..312
    hdl_checker/database.py on lines 314..315

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

    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

                obj._flags_map[path][BuildFlagScope.dependencies] = tuple(
                    info.pop("flags", {}).pop(BuildFlagScope.dependencies.value, ())
    Severity: Major
    Found in hdl_checker/database.py and 2 other locations - About 1 hr to fix
    hdl_checker/database.py on lines 308..309
    hdl_checker/database.py on lines 311..312

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

    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

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

        def __ne__(self, other):  # pragma: no cover
            """Overrides the default implementation (unnecessary in Python 3)"""
            result = self.__eq__(other)
    
            if result is not NotImplemented:
    Severity: Major
    Found in hdl_checker/parsers/elements/identifier.py and 1 other location - About 1 hr to fix
    hdl_checker/utils.py on lines 339..346

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

    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

            if len(paths) > 1:
                for location in included_path.locations:
                    self._addDiagnostic(
                        DependencyNotUnique(
                            filename=included_path.owner,
    Severity: Major
    Found in hdl_checker/database.py and 1 other location - About 1 hr to fix
    hdl_checker/database.py on lines 634..646

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

    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 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 addSource has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def addSource(
    Severity: Major
    Found in hdl_checker/database.py - About 1 hr to fix

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

          def __ne__(self, other):  # pragma: no cover
              """Overrides the default implementation (unnecessary in Python 3)"""
              result = self.__eq__(other)
      
              if result is not NotImplemented:
      Severity: Major
      Found in hdl_checker/utils.py and 1 other location - About 1 hr to fix
      hdl_checker/parsers/elements/identifier.py on lines 79..86

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

      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