houtianze/bypy

View on GitHub

Showing 138 of 217 total issues

File bypy.py has 3024 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python -tt
# encoding: utf-8
# PYTHON_ARGCOMPLETE_OK
# ===  IMPORTANT  ====
# NOTE: In order to support non-ASCII file names,
Severity: Major
Found in bypy/bypy.py - About 1 wk to fix

    ByPy has 186 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ByPy(object):
        '''The main class of the bypy program'''
        # TODO: Apply to configdir instead of ~/.bypy
        @staticmethod
        def migratesettings():
    Severity: Major
    Found in bypy/bypy.py - About 3 days to fix

      Function __init__ has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self,
              slice_size = const.DefaultSliceSize,
              dl_chunk_size = const.DefaultDlChunkSize,
              verify = True,
              retry = 5, timeout = const.DefaultTimeOutInSeconds,
      Severity: Minor
      Found in bypy/bypy.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

      Function _request_work has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
      Open

          def _request_work(self, url, pars, act, method, actargs = None, addtoken = True, dumpex = True, **kwargs):
              result = const.ENoError
              r = None
      
              self._extraupdate()
      Severity: Minor
      Found in bypy/bypy.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

      Function _downfile has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          def _downfile(self, remotefile, localfile):
              pinfo('{} <- {}'.format(localfile, remotefile))
              # TODO: this is a quick patch
              if not self._shallinclude(localfile, remotefile, False):
                  # since we are not going to download it, there is no error
      Severity: Minor
      Found in bypy/bypy.py - About 5 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 main has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

      def main(argv=None): # IGNORE:C0111
          ''' Main Entry '''
          # printBaiduBanner()
      
          by = None
      Severity: Minor
      Found in bypy/bypy.py - About 5 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 cleancache has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def cleancache():
              if cached.loadcache():
                  for absdir in cached.cache.keys():
                      if not os.path.exists(absdir):
                          if cached.verbose:
      Severity: Minor
      Found in bypy/cached.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 _upload_file_slices has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          def _upload_file_slices(self, localpath, remotepath, ondup = 'overwrite'):
              pieces = const.MaxSlicePieces
              slice = self._slice_size
              if self._current_file_size <= self._slice_size * const.MaxSlicePieces:
                  # slice them using slice size
      Severity: Minor
      Found in bypy/bypy.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 loadcache has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          def loadcache(existingcache = {}):
              # load cache even we don't use cached hash values,
              # because we will save (possibly updated) and hash values
              if not cached.cacheloaded: # no double-loading
                  if cached.verbose:
      Severity: Minor
      Found in bypy/cached.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 mergeinto has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          def mergeinto(fromc, to, keepto = True):
              conflicts = 0
              for absdir in fromc:
                  entry = fromc[absdir]
                  if not absdir in to:
      Severity: Minor
      Found in bypy/cached.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 __init__ has 27 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self,
      Severity: Major
      Found in bypy/bypy.py - About 3 hrs to fix

        File gui.py has 295 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/env python
        # coding=utf-8
        
        # A simple GUI for bypy, using Tkinter
        
        
        Severity: Minor
        Found in bypy/gui.py - About 3 hrs to fix

          Function _compare has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def _compare(self, remotedir = None, localdir = None, skip_remote_only_dirs = False):
                  if not localdir:
                      localdir = '.'
          
                  self.pv("Gathering local directory ...")
          Severity: Minor
          Found in bypy/bypy.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 _dump_exception has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def _dump_exception(self, ex, url, pars, r, act):
                  if self.debug or self.verbose:
                      perr("Error accessing '{}'".format(url))
                      if self.debug:
                          perr(formatex(ex))
          Severity: Minor
          Found in bypy/bypy.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

          Consider simplifying this complex logical expression.
          Open

                          if ec == 111 or ec == 110 or ec == 6 or ec == const.IEAppIDIsEmpty: # and sc == 401:
                              self.pd("ec = {}".format(ec))
                              self.pd("Need to refresh token, refreshing")
                              if const.ENoError == self._refresh_token(): # refresh the token and re-request
                                  # TODO: avoid infinite recursive loops
          Severity: Critical
          Found in bypy/bypy.py - About 2 hrs to fix

            File cached.py has 275 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #!/usr/bin/env python
            # encoding: utf-8
            # PYTHON_ARGCOMPLETE_OK
            
            # from __future__ imports must occur at the beginning of the file
            Severity: Minor
            Found in bypy/cached.py - About 2 hrs to fix

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

                  def _walk_upload(self, localpath, remotepath, ondup, walk):
                      (dirpath, dirnames, filenames) = walk
              
                      rdir = os.path.relpath(dirpath, localpath)
                      if rdir == '.':
              Severity: Minor
              Found in bypy/bypy.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 limit_unit has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              def limit_unit(timestr, num = 2):
                  ''' DocTests:
                  >>> limit_unit('1m2s', 1) == '1m'
                  True
                  >>> limit_unit('1m2s') == '1m2s'
              Severity: Minor
              Found in bypy/printer_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

              File util.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              #!/usr/bin/env python
              # encoding: utf-8
              # PYTHON_ARGCOMPLETE_OK
              
              # from __future__ imports must occur at the beginning of the file
              Severity: Minor
              Found in bypy/util.py - About 2 hrs to fix

                Function _walk_remote_dir has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _walk_remote_dir(self, remotepath, remoterootpath, args = None, skip_remote_only_dirs = False, recursive = True):
                        dirjs = []
                        filejs = []
                        listStart = 0
                        # https://github.com/houtianze/bypy/issues/285
                Severity: Minor
                Found in bypy/bypy.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

                Severity
                Category
                Status
                Source
                Language