cloudmatrix/esky

View on GitHub
esky/util.py

Summary

Maintainability
F
3 days
Test Coverage

File util.py has 490 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.util:  misc utility functions for esky
Severity: Minor
Found in esky/util.py - About 7 hrs to fix

    Function create_zipfile has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_zipfile(source,target,get_zipinfo=None,members=None,compress=None):
        """Bundle the contents of a given directory into a zipfile.
    
        The argument 'source' names the directory to read, while 'target' names
        the zipfile to be written.
    Severity: Minor
    Found in esky/util.py - About 4 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 really_rmtree has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def really_rmtree(path):
        """Like shutil.rmtree, but try to work around some win32 wierdness.
    
        Every so often windows likes to throw a spurious error about not being
        able to remove a directory - like claiming it still contains files after
    Severity: Minor
    Found in esky/util.py - About 3 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 extract_zipfile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def extract_zipfile(source,target,name_filter=None):
        """Extract the contents of a zipfile into a target directory.
    
        The argument 'source' names the zipfile to read, while 'target' names
        the directory into which to extract.  If given, the optional argument
    Severity: Minor
    Found in esky/util.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 really_rename has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def really_rename(source,target):
        """Like os.rename, but try to work around some win32 wierdness.
    
        Every so often windows likes to throw a spurious error about not being
        able to rename something; if we sleep for a brief period and try
    Severity: Minor
    Found in esky/util.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 files_differ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def files_differ(file1,file2,start=0,stop=None):
        """Check whether two files are actually different."""
        try:
            stat1 = os.stat(file1)
            stat2 = os.stat(file2)
    Severity: Minor
    Found in esky/util.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 copy_ownership_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def copy_ownership_info(src,dst,cur="",default=None):
        """Copy file ownership from src onto dst, as much as possible."""
        # TODO: how on win32?
        source = os.path.join(src,cur)
        target = os.path.join(dst,cur)
    Severity: Minor
    Found in esky/util.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 is_locked_version_dir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def is_locked_version_dir(vdir):
        """Check whether the given version dir is locked."""
        if sys.platform == "win32":
            lockfile = os.path.join(vdir,ESKY_CONTROL_DIR,"bootstrap-manifest.txt")
            try:
    Severity: Minor
    Found in esky/util.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 _esky_lazy_load has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _esky_lazy_load(self):
            if self._esky_lazy_target is _LazyImport:
                self._esky_lazy_target = self._esky_lazy_loader()
                ns = self._esky_lazy_namespace
                if ns is not None:
    Severity: Minor
    Found in esky/util.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 deep_extract_zipfile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def deep_extract_zipfile(source,target,name_filter=None):
        """Extract the deep contents of a zipfile into a target directory.
    
        This is just like extract_zipfile() except that any common prefix dirs
        are removed.  For example, if everything in the zipfile is under the
    Severity: Minor
    Found in esky/util.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 appexe_from_executable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def appexe_from_executable(exepath):
        """Find the top-level application executable, given sys.executable."""
        appdir = appdir_from_executable(exepath)
        exename = os.path.basename(exepath)
        #  On OSX we might be in a bundle, run from Contents/MacOS/<exename>
    Severity: Minor
    Found in esky/util.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 create_zipfile has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def create_zipfile(source,target,get_zipinfo=None,members=None,compress=None):
    Severity: Minor
    Found in esky/util.py - About 35 mins to fix

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

      def common_prefix(iterables):
          """Find the longest common prefix of a series of iterables."""
          iterables = iter(iterables)
          try:
              prefix = iterables.next()
      Severity: Minor
      Found in esky/util.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 (data1 != data2)
      Severity: Major
      Found in esky/util.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                            return True
        Severity: Major
        Found in esky/util.py - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status