xybu/onedrived-dev

View on GitHub

Showing 56 of 166 total issues

File merge_dir.py has 467 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import itertools
import logging
import os
import shutil
 
 
Severity: Minor
Found in onedrived/od_tasks/merge_dir.py - About 7 hrs to fix

    Function _handle_remote_file_with_record has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

    def _handle_remote_file_with_record(self, remote_item, item_record, item_stat, item_local_abspath, all_local_items):
    """
    :param onedrivesdk.model.item.Item remote_item:
    :param onedrived.od_repo.ItemRecord item_record:
    :param posix.stat_result | None item_stat:
    Severity: Minor
    Found in onedrived/od_tasks/merge_dir.py - About 6 hrs to fix

    File od_pref.py has 408 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python3
     
    import json
    import locale
    import os
    Severity: Minor
    Found in onedrived/od_pref.py - About 5 hrs to fix

      Function set_drive has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

      def set_drive(drive_id=None, email=None, local_root=None, ignore_file=None):
      try:
      all_drives, drive_table = print_all_drives()
      click.echo()
      except Exception as e:
      Severity: Minor
      Found in onedrived/od_pref.py - About 5 hrs to fix

      File od_watcher.py has 365 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import logging
      import os
      import threading
       
      import onedrivesdk.error
      Severity: Minor
      Found in onedrived/od_watcher.py - About 4 hrs to fix

        Function _handle_local_file has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

        def _handle_local_file(self, item_name, item_record, item_stat, item_local_abspath):
        """
        :param str item_name:
        :param onedrived.od_repo.ItemRecord | None item_record:
        :param posix.stat_result | None item_stat:
        Severity: Minor
        Found in onedrived/od_tasks/merge_dir.py - About 3 hrs to fix

        Function _handle_unpaired_move_to has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

        def _handle_unpaired_move_to(self, to_ev, to_flags, to_repo,
        to_parent_dir=None, to_parent_relpath=None):
         
        if to_parent_dir is None:
        to_parent_dir = self.watch_descriptors[to_ev.wd]
        Severity: Minor
        Found in onedrived/od_watcher.py - About 3 hrs to fix

        Function _handle_move_pair has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        def _handle_move_pair(self, move_pair):
        """
        :param [[inotify_simple.Event, inotify_simple.flags], [inotify_simple.Event, inotify_simple.flags]] move_pair:
        """
        from_tup, to_tup = move_pair
        Severity: Minor
        Found in onedrived/od_watcher.py - About 3 hrs to fix

        Function handle_event has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        def handle_event(self, ev, flags, move_pairs):
        """
        :param inotify_simple.Event ev:
        :param [inotify_simple.flags] flags:
        :param dict[int, [inotify_simple.Event, inotify_simple.flags]] move_pairs:
        Severity: Minor
        Found in onedrived/od_watcher.py - About 3 hrs to fix

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

        def handle(self):
        if not os.path.isdir(self.local_abspath):
        logging.error('Error: Local path "%s" is not a directory.' % self.local_abspath)
        return
         
         
        Severity: Minor
        Found in onedrived/od_tasks/merge_dir.py - About 2 hrs to fix

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

        def handle(self):
        logging.info('Uploading file "%s" to OneDrive.', self.local_abspath)
        occupy_task = self.task_pool.occupy_path(self.local_abspath, self)
        if occupy_task is not self:
        logging.warning('Cannot upload "%s" because %s.', self.local_abspath,
        Severity: Minor
        Found in onedrived/od_tasks/upload_file.py - About 2 hrs to fix

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

        def read_drive_config_interactively(drive_exists, curr_drive_config):
        local_root = None
        ignore_file = None
        if drive_exists:
        local_root_default = curr_drive_config.localroot_path
        Severity: Minor
        Found in onedrived/od_pref.py - About 2 hrs to fix

        Function delete_account has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def delete_account(yes=False, index=None, email=None, account_id=None):
        click.echo('All OneDrive accounts associated with user "%s":\n' % context.user_name)
        all_account_ids = print_all_accounts(context)
        click.echo()
         
         
        Severity: Minor
        Found in onedrived/od_pref.py - About 1 hr to fix

        Function delete_drive has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def delete_drive(drive_id=None, yes=False):
        all_drive_ids = print_saved_drives()
         
        if len(all_drive_ids) == 0:
        return
        Severity: Minor
        Found in onedrived/od_pref.py - About 1 hr to fix

        Function _read_ngrok_tunnels has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def _read_ngrok_tunnels(self):
        webhook_urls = dict()
        self._api_url = 'http://%s:%d/api' % self._find_ngrok_inspection_port()
        logging.info('Local ngrok API url: %s', self._api_url)
        for _ in range(0, self.POLL_TUNNELS_MAX_TRIES):
        Severity: Minor
        Found in onedrived/od_webhooks/ngrok_server.py - About 1 hr to fix

        Function _squash_tasks has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def _squash_tasks(self, repo, rel_path):
        for t in self.task_queue.copy():
        if (isinstance(t, merge_dir.MergeDirectoryTask) or
        isinstance(t, delete_item.DeleteRemoteItemTask)) and t.repo is repo:
        if t.rel_path == rel_path or rel_path.startswith(t.rel_path + '/'):
        Severity: Minor
        Found in onedrived/od_watcher.py - About 1 hr to fix

        Function set_config has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def set_config(key, value):
        try:
        config_guard[key] = value
        save_context(context)
        click.echo('config.%s = %s' % (key, str(context.config[key])))
        Severity: Minor
        Found in onedrived/od_pref.py - About 1 hr to fix

        Function _recognize_event_patterns has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def _recognize_event_patterns(events):
        move_pairs = dict()
        move_pairs_tmp = dict()
        all_events = []
        for ev in events:
        Severity: Minor
        Found in onedrived/od_watcher.py - About 1 hr to fix

        Function list_local_names has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def list_local_names(self):
        """
        List all names under the task local directory.
        Try resolving naming conflict (same name case-INsensitive) as it goes.
        :return [str]: A list of entry names.
        Severity: Minor
        Found in onedrived/od_tasks/merge_dir.py - About 1 hr to fix

        Function _handle_local_folder has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def _handle_local_folder(self, item_name, item_record, item_local_abspath):
        """
        :param str item_name:
        :param onedrived.od_repo.ItemRecord | None item_record:
        :param str item_local_abspath:
        Severity: Minor
        Found in onedrived/od_tasks/merge_dir.py - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language