houtianze/bypy

View on GitHub

Showing 139 of 218 total issues

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

def check_requirements():
    result = CheckResult.Pass
    if iswindows():
        bannerwarn("You are running Python on Windows, which doesn't support Unicode so well.\n"
            "Files with non-ASCII names may not be handled correctly.")
Severity: Minor
Found in bypy/chkreq.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 _upload_file has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def _upload_file(self, localpath, remotepath, ondup = 'overwrite'):
        # TODO: this is a quick patch
        if not self._shallinclude(localpath, remotepath, True):
            # since we are not going to upload it, there is no error
            #return const.ENoError
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 _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

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

    def Select(self, event):
        if event.widget == self.wOK:
            self.Bye(self.rpath[len(const.AppPcsPath):])
        elif event.widget == self.wList:
            selected = ''
Severity: Minor
Found in bypy/gui.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 CreateWidgets has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def CreateWidgets(self):
        self.master.grid_columnconfigure(0, weight = 1)
        self.master.grid_rowconfigure(1, weight = 1)
        self.grid_columnconfigure(1, weight = 1)
        self.grid_rowconfigure(4, weight = 1)
Severity: Major
Found in bypy/gui.py - About 2 hrs to fix

    Function __init__ has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __init__(self,
            slice_size = const.DefaultSliceSize,
            dl_chunk_size = const.DefaultDlChunkSize,
            verify = True,
            retry = 5, timeout = const.DefaultTimeOutInSeconds,
    Severity: Major
    Found in bypy/bypy.py - About 2 hrs to fix

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

      def getparser():
          #name = os.path.basename(sys.argv[0])
          version = "v%s" % const.__version__
          version_message = '%%(prog)s %s' % (version)
          desc = "{} - {}".format(version_message, const.__desc__)
      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 _auth has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def _auth(self):
              params = {
                  'client_id' : self._apikey,
                  'response_type' : 'code',
                  'redirect_uri' : 'oob',
      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 upload has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def upload(self, localpath = '', remotepath = '', ondup = "overwrite"):
              ''' Usage: upload [localpath] [remotepath] [ondup] - \
      upload a file or directory (recursively)
          localpath - local path, is the current directory '.' if not specified
          remotepath - remote path at Baidu Yun (after app root directory at Baidu Yun)
      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 _verify_current_file has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def _verify_current_file(self, j, gotlmd5):
              # if we really don't want to verify
              if self._current_file == '/dev/null' and not self._verify:
                  return const.ENoError
      
      
      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 _cdl_addmon has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def _cdl_addmon(self, source_url, rpath, timeout = 3600):
              pars = self._prepare_cdl_add(source_url, rpath, timeout)
              jc = [{}] # out param
              result = self._post(pcsurl + 'services/cloud_dl',
                  pars, self._cdl_addmon_act, jc)
      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 combine has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def combine(self, remotefile, localfile = '*', *args):
              ''' Usage: combine <remotefile> [localfile] [md5s] - \
      try to create a file at PCS by combining slices, having MD5s specified
        remotefile - remote file at Baidu Yun (after app root directory at Baidu Yun)
        localfile - local file to verify against, passing in a star '*' or '/dev/null' means no verification
      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 _request has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def _request(self, url, pars, act, method, actargs = None, retry = True, addtoken = True, dumpex = True, **kwargs):
              tries = 1
              if retry:
                  tries = self._retry
      
      
      Severity: Minor
      Found in bypy/bypy.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 isbincache has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def isbincache(cache):
              for absdir in cache:
                  entry = cache[absdir]
                  for file in entry:
                      info = entry[file]
      Severity: Minor
      Found in bypy/cached.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 _downchunks has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _downchunks(self, rfile, start):
              rsize = self._remote_json['size']
      
              pars = {
                  'method' : 'download',
      Severity: Minor
      Found in bypy/bypy.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 _refresh_token has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _refresh_token(self):
              if self._use_server_auth:
                  pr('Refreshing, please be patient, it may take upto {} seconds...'.format(self._repr_timeout()))
      
                  pars = {
      Severity: Minor
      Found in bypy/bypy.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 __call__ has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, *args):
              assert len(args) > 0
              result = None
              path = args[0]
              dir, file = os.path.split(path) # the 'filename' parameter
      Severity: Minor
      Found in bypy/cached.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 _ok_to_use_remote_temp_dir has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _ok_to_use_remote_temp_dir(self):
              if const.SettingKey_OverwriteRemoteTempDir in self._setting and \
              self._setting[const.SettingKey_OverwriteRemoteTempDir]:
                  return True
      
      
      Severity: Minor
      Found in bypy/bypy.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 _syncup_diff_one has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def _syncup_diff_one(self, rpath, localdir, d):
              result = const.ENoError
              t = d[0] # type
              p = d[1] # path
              #lcpath = os.path.join(localdir, p) # local complete path
      Severity: Minor
      Found in bypy/bypy.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 _share_local_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def _share_local_file(self, lpath, rpath, fast):
              filesize = getfilesize(lpath)
              if filesize < const.MinRapidUploadFileSize:
                  perr("File size ({}) of '{}' is too small (must be greater or equal than {}) to be shared".format(
                      human_size(filesize), lpath, human_size(const.MinRapidUploadFileSize)))
      Severity: Minor
      Found in bypy/bypy.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

      Severity
      Category
      Status
      Source
      Language