versioneer.py

Summary

Maintainability
F
1 wk
Test Coverage

File versioneer.py has 479 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""versioneer.py

(like a rocketeer, but for versions)

* https://github.com/warner/python-versioneer
Severity: Minor
Found in versioneer.py - About 7 hrs to fix

    Function versions_from_expanded_variables has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def versions_from_expanded_variables(variables, tag_prefix, verbose=False):
        refnames = variables["refnames"].strip()
        if refnames.startswith("$Format"):
            if verbose:
                print("variables are unexpanded, not using")
    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 get_best_versions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_best_versions(versionfile, tag_prefix, parentdir_prefix,
                          default=DEFAULT, verbose=False):
        # returns dict with two keys: 'version' and 'full'
        #
        # extract version from first of _version.py, 'git describe', parentdir.
    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 versions_from_vcs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def versions_from_vcs(tag_prefix, versionfile_source, verbose=False):
        # this runs 'git' from the root of the source tree. That either means
        # someone ran a setup.py command (and this code is in versioneer.py, so
        # IN_LONG_VERSION_PY=False, thus the containing directory is the root of
        # the source tree), or someone ran a project-specific entry point (and
    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 get_expanded_variables has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_expanded_variables(versionfile_source):
        # the code embedded in _version.py can just fetch the value of these
        # variables. 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 _version.py.
    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 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def do_vcs_install(versionfile_source, ipy):
        GIT = "git"
        if sys.platform == "win32":
            GIT = "git.cmd"
        run_command([GIT, "add", "versioneer.py"])
    Severity: Minor
    Found in versioneer.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 versions_from_parentdir has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def versions_from_parentdir(parentdir_prefix, versionfile_source, verbose=False):
        if IN_LONG_VERSION_PY:
            # We're running from _version.py. If it's from a source tree
            # (execute-in-place), we can work upwards to find the root of the
            # tree, and then check the parent directory for a version string. If
    Severity: Minor
    Found in versioneer.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 get_best_versions has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def get_best_versions(versionfile, tag_prefix, parentdir_prefix,
    Severity: Minor
    Found in versioneer.py - About 35 mins to fix

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

      def run_command(args, cwd=None, verbose=False):
          try:
              # remember shell=False, so use git.cmd on windows, not just git
              p = subprocess.Popen(args, stdout=subprocess.PIPE, cwd=cwd)
          except EnvironmentError:
      Severity: Minor
      Found in versioneer.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 default
      Severity: Major
      Found in versioneer.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return {}
        Severity: Major
        Found in versioneer.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return {"version": tag, "full": full}
          Severity: Major
          Found in versioneer.py - About 30 mins to fix

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

            def versions_from_file(filename):
                versions = {}
                try:
                    f = open(filename)
                except EnvironmentError:
            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

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

            def versions_from_vcs(tag_prefix, versionfile_source, verbose=False):
                # this runs 'git' from the root of the source tree. That either means
                # someone ran a setup.py command (and this code is in versioneer.py, so
                # IN_LONG_VERSION_PY=False, thus the containing directory is the root of
                # the source tree), or someone ran a project-specific entry point (and
            Severity: Major
            Found in versioneer.py and 1 other location - About 2 days to fix
            attic/_version.py on lines 98..147

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

            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 versions_from_expanded_variables(variables, tag_prefix, verbose=False):
                refnames = variables["refnames"].strip()
                if refnames.startswith("$Format"):
                    if verbose:
                        print("variables are unexpanded, not using")
            Severity: Major
            Found in versioneer.py and 1 other location - About 2 days to fix
            attic/_version.py on lines 64..96

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

            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 versions_from_parentdir(parentdir_prefix, versionfile_source, verbose=False):
                if IN_LONG_VERSION_PY:
                    # We're running from _version.py. If it's from a source tree
                    # (execute-in-place), we can work upwards to find the root of the
                    # tree, and then check the parent directory for a version string. If
            Severity: Major
            Found in versioneer.py and 1 other location - About 1 day to fix
            attic/_version.py on lines 150..180

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

            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 run_command(args, cwd=None, verbose=False):
                try:
                    # remember shell=False, so use git.cmd on windows, not just git
                    p = subprocess.Popen(args, stdout=subprocess.PIPE, cwd=cwd)
                except EnvironmentError:
            Severity: Major
            Found in versioneer.py and 1 other location - About 1 day to fix
            attic/_version.py on lines 20..37

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

            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 get_expanded_variables(versionfile_source):
                # the code embedded in _version.py can just fetch the value of these
                # variables. 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 _version.py.
            Severity: Major
            Found in versioneer.py and 1 other location - About 1 day to fix
            attic/_version.py on lines 44..62

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

            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