cloudmatrix/esky

View on GitHub
esky/finder.py

Summary

Maintainability
F
5 days
Test Coverage

Function _prepare_version has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    def _prepare_version(self,app,version,path):
        """Prepare the requested version from downloaded data.

        This method is responsible for unzipping downloaded versions, applying
        patches and so-forth, and making the result available as a local
Severity: Minor
Found in esky/finder.py - About 1 day 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 finder.py has 528 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#  Copyright (c) 2009-2010, Cloud Matrix Pty. Ltd.
#  All rights reserved; available under the terms of the BSD License.
"""

  esky.finder:  VersionFinder implementations for esky
Severity: Major
Found in esky/finder.py - About 1 day to fix

    Function _fetch_file_iter has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def _fetch_file_iter(self,app,url):
            nm = os.path.basename(urlparse(url).path)
            outfilenm = os.path.join(self._workdir(app,"downloads"),nm)
            if not os.path.exists(outfilenm):
                try:
    Severity: Minor
    Found in esky/finder.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 fetch_version_iter has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def fetch_version_iter(self,app,version):
            #  There's always the possibility that a file fails to download or 
            #  that a patch fails to apply.  _fetch_file_iter and _prepare_version
            #  will remove such files from the version graph; we loop until we find
            #  a patch path that works, or we run out of options.
    Severity: Minor
    Found in esky/finder.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 _workdir has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def _workdir(self,app,nm,create=True):
            """Get full path of named working directory, inside the given app."""
            updir = app._get_update_dir()
            workdir = os.path.join(updir,nm)
            if create:
    Severity: Minor
    Found in esky/finder.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 _copy_best_version has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _copy_best_version(self,app,uppath,force_appdata_dir=True):
            """Copy the best version directory from the given app.
    
            This copies the best version directory from the given app into the
            unpacking path.  It's useful for applying patches against an existing
    Severity: Minor
    Found in esky/finder.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 needs_cleanup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def needs_cleanup(self,app):
            """Check whether the cleanup() method has any work to do."""
            dldir = self._workdir(app,"downloads",create=False)
            if os.path.isdir(dldir):
                for nm in os.listdir(dldir):
    Severity: Minor
    Found in esky/finder.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 find_versions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_versions(self, app):
            version_re = "[a-zA-Z0-9\\.\\-_]+"
            appname_re = "(?P<version>%s)" % (version_re,)
            name_re = "(%s|%s)" % (app.name, urllib.quote(app.name))
            appname_re = join_app_version(name_re, appname_re, app.platform)
    Severity: Minor
    Found in esky/finder.py - About 45 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_paths has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_best_paths(self,source):
            """Get the best path from source to every other version.
    
            This returns a dictionary mapping versions to lists of "via" links.
            Each entry gives the lowest-cost path from the given source version
    Severity: Minor
    Found in esky/finder.py - About 45 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 find_versions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_versions(self,app):
            version_re = "[a-zA-Z0-9\\.\\-_]+"
            appname_re = "(?P<version>%s)" % (version_re,)
            appname_re = join_app_version(app.name,appname_re,app.platform)
            filename_re = "%s\\.(zip|exe|from-(?P<from_version>%s)\\.patch)"
    Severity: Minor
    Found in esky/finder.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

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

        def find_versions(self,app):
            version_re = "[a-zA-Z0-9\\.\\-_]+"
            appname_re = "(?P<version>%s)" % (version_re,)
            name_re = "(%s|%s)" % (app.name, urllib.quote(app.name))
            appname_re = join_app_version(name_re,appname_re,app.platform)
    Severity: Minor
    Found in esky/finder.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

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

                    if os.path.isdir(bspath):
                        shutil.copytree(bspath,dstpath)
                    else:
                        if not os.path.isdir(os.path.dirname(dstpath)):
                            os.makedirs(os.path.dirname(dstpath))
    Severity: Major
    Found in esky/finder.py and 1 other location - About 4 hrs to fix
    esky/bdist_esky/__init__.py on lines 742..747

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

    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 not os.path.isdir(vdirpath):
                        self.version_graph.remove_all_links(path[0][1])
                        err = version + ": version directory does not exist"
                        raise EskyVersionError(err)
    Severity: Major
    Found in esky/finder.py and 1 other location - About 2 hrs to fix
    esky/finder.py on lines 377..380

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

    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 not os.path.exists(bsfile):
                    self.version_graph.remove_all_links(path[0][1])
                    err = version + ": version has no bootstrap-manifest.txt"
                    raise EskyVersionError(err)
    Severity: Major
    Found in esky/finder.py and 1 other location - About 2 hrs to fix
    esky/finder.py on lines 362..365

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

    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 os.path.exists(rdpath):
                        tmpnm = rdpath + ".old"
                        while os.path.exists(tmpnm):
                            tmpnm = tmpnm + ".old"
                        really_rename(rdpath,tmpnm)
    Severity: Major
    Found in esky/finder.py and 2 other locations - About 1 hr to fix
    esky/fstransact/fallback.py on lines 86..90
    esky/fstransact/fallback.py on lines 91..95

    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

    There are no issues that match your filters.

    Category
    Status