odin-detector/odin-data

View on GitHub
python/src/odin_data/_version.py

Summary

Maintainability
D
3 days
Test Coverage

File _version.py has 377 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# feature). Distribution tarballs (built by setup.py sdist) and build
# directories (produced by setup.py build) will contain a much shorter file
# that just contains the computed version number.
Severity: Minor
Found in python/src/odin_data/_version.py - About 5 hrs to fix

    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,
                    env=None):
        """Call the given command(s)."""
        assert isinstance(commands, list)
        p = None
    Severity: Minor
    Found in python/src/odin_data/_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 git_get_keywords has a Cognitive Complexity of 17 (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 python/src/odin_data/_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 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 python/src/odin_data/_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 git_versions_from_keywords has a Cognitive Complexity of 16 (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")
        date = keywords.get("date")
    Severity: Minor
    Found in python/src/odin_data/_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 render_pep440 has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def render_pep440(pieces):
        """Build up version string, with post-release "local version identifier".
    
        Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
        get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
    Severity: Minor
    Found in python/src/odin_data/_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 render_pep440_post has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def render_pep440_post(pieces):
        """TAG[.postDISTANCE[.dev0]+gHEX] .
    
        The ".dev0" means dirty. Note that .dev0 sorts backwards
        (a dirty tree will appear "older" than the corresponding clean one),
    Severity: Minor
    Found in python/src/odin_data/_version.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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def render(pieces, style):
        """Render the given version pieces into the requested style."""
        if pieces["error"]:
            return {"version": "unknown",
                    "full-revisionid": pieces.get("long"),
    Severity: Minor
    Found in python/src/odin_data/_version.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 render_pep440_old has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def render_pep440_old(pieces):
        """TAG[.postDISTANCE[.dev0]] .
    
        The ".dev0" means dirty.
    
    
    Severity: Minor
    Found in python/src/odin_data/_version.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 run_command has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
    Severity: Minor
    Found in python/src/odin_data/_version.py - About 45 mins to fix

      Avoid too many return statements within this function.
      Open

          return {"version": "0+unknown", "full-revisionid": None,
      Severity: Major
      Found in python/src/odin_data/_version.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 python/src/odin_data/_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

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

                    if line.strip().startswith("git_date ="):
                        mo = re.search(r'=\s*"(.*)"', line)
                        if mo:
                            keywords["date"] = mo.group(1)
        Severity: Major
        Found in python/src/odin_data/_version.py and 2 other locations - About 1 hr to fix
        python/src/odin_data/_version.py on lines 143..146
        python/src/odin_data/_version.py on lines 147..150

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

        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 line.strip().startswith("git_full ="):
                        mo = re.search(r'=\s*"(.*)"', line)
                        if mo:
                            keywords["full"] = mo.group(1)
        Severity: Major
        Found in python/src/odin_data/_version.py and 2 other locations - About 1 hr to fix
        python/src/odin_data/_version.py on lines 143..146
        python/src/odin_data/_version.py on lines 151..154

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

        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 line.strip().startswith("git_refnames ="):
                        mo = re.search(r'=\s*"(.*)"', line)
                        if mo:
                            keywords["refnames"] = mo.group(1)
        Severity: Major
        Found in python/src/odin_data/_version.py and 2 other locations - About 1 hr to fix
        python/src/odin_data/_version.py on lines 147..150
        python/src/odin_data/_version.py on lines 151..154

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

        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

        There are no issues that match your filters.

        Category
        Status