cogniteev/docido-python-sdk

View on GitHub

Showing 39 of 49 total issues

File rate_limits.py has 318 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import Mapping
import copy
import functools
import inspect
import logging
Severity: Minor
Found in docido_sdk/toolbox/rate_limits.py - About 3 hrs to fix

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

        def from_str(cls, timestr, shaked=False):
            """Use `dateutil` module to parse the give string
    
            :param basestring timestr: string representing a date to parse
            :param bool shaked: whether the input parameter been already
    Severity: Minor
    Found in docido_sdk/toolbox/date_ext.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 __push_es_docs has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def __push_es_docs(self, docs, es, index, doc_type):
            action = dict(index=dict(_index=index, _type=doc_type))
            body, error_docs = self._prepare_index_bulk_query(docs, action)
            if len(body) == 0:
                return error_docs
    Severity: Minor
    Found in docido_sdk/index/processor/es_api.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 flatten_dict has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def flatten_dict(d, prefix='', sep='.'):
        """In place dict flattening.
        """
        def apply_and_resolve_conflicts(dest, item, prefix):
            for k, v in flatten_dict(item, prefix=prefix, sep=sep).items():
    Severity: Minor
    Found in docido_sdk/toolbox/collections_ext.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 teb_retry has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def teb_retry(exc=RequestException,
                  when=dict(response__status_code=429),
                  delay='response__headers__Retry-After',
                  max_collisions=MAX_COLLISIONS,
                  default_retry=DEFAULT_RETRY):
    Severity: Minor
    Found in docido_sdk/toolbox/rate_limits.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 load_eggs has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_eggs(entry_point_name):
        """Loader that loads any eggs in `sys.path`."""
        def _load_eggs(env):
            distributions, errors = working_set.find_plugins(
                pkg_resources.Environment()
    Severity: Minor
    Found in docido_sdk/loader.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 catch has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def catch(cls, catch_exception, config='default'):
            """Decorator class method catching exceptions raised by the wrapped
            member function. When exception is caught, the decorator waits
            for an amount of time specified in the `ha_config`.
    
    
    Severity: Minor
    Found in docido_sdk/toolbox/ha.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 edsl.py has 264 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # encoding: utf-8
    """
    Provides Python Embedded Domain Specific Languages.
    """
    from collections import Mapping, Sequence
    Severity: Minor
    Found in docido_sdk/toolbox/edsl.py - About 2 hrs to fix

      Function to_unicode has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def to_unicode(text, charset=None):
          """Convert input to an `unicode` object.
      
          For a `str` object, we'll first try to decode the bytes using the given
          `charset` encoding (or UTF-8 if none is specified), then we fall back to
      Severity: Minor
      Found in docido_sdk/toolbox/text.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 levenshtein has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def levenshtein(s, t):
          """ Compute the Levenshtein distance between 2 strings, which
          is the minimum number of operations required to perform on a string to
          get another one.
      
      
      Severity: Minor
      Found in docido_sdk/toolbox/text.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 resolve_name has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def resolve_name(name, module=None):
          """Resolve a dotted name to a module and its parts. This is stolen
          wholesale from unittest.TestLoader.loadTestByName.
          """
          parts = name.split('.')
      Severity: Minor
      Found in docido_sdk/toolbox/loader.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 split_crawl_tasks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def split_crawl_tasks(tasks, concurrency):
          """ Reorganize tasks according to the tasks max concurrency value.
      
          :param tasks:
            sub-tasks to execute, can be either a list of tasks of a list of list
      Severity: Minor
      Found in docido_sdk/crawler/tasks.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 token_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def token_info(token, refresh=True, refresh_cb=None, session=None):
          """
          :param OAuthToken token
      
          :param bool refresh:
      Severity: Minor
      Found in docido_sdk/toolbox/google_ext.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 _read_n has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _read_n(self, size):
              while len(self._buf) < size:
                  try:
                      data = self.next()
                  except StopIteration:
      Severity: Minor
      Found in docido_sdk/toolbox/file_ext.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 convert has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def convert(cls, **kwargsql):
              """
              :param dict kwargsql:
                Kwargsql expression to convert
      
      
      Severity: Minor
      Found in docido_sdk/toolbox/mongo_ext.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 oauth_tokens_from_file has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def oauth_tokens_from_file():
          path = os.environ.get('DOCIDO_DCC_RUNS', '.dcc-runs.yml')
          crawlers = Configuration.from_env('DOCIDO_CC_RUNS', '.dcc-runs.yml',
                                            Configuration())
          for crawler, runs in crawlers.iteritems():
      Severity: Minor
      Found in docido_sdk/scripts/dcc_run.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 _iter_crawl_tasks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _iter_crawl_tasks(self):
              attempt = 1
              while True:
                  try:
                      tasks = self.crawler.iter_crawl_tasks(
      Severity: Minor
      Found in docido_sdk/crawler/run.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 run_all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def run_all(self, crawls):
              crawler_runs = oauth_tokens_from_file()
              for service, launches in crawler_runs.iteritems():
                  self.service = service
                  c = [c for c in self.crawlers if c.get_service_name() == service]
      Severity: Minor
      Found in docido_sdk/scripts/dcc_run.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 _run_task has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _run_task(self, task, prev_result):
              attempt = 1
              result = None
              kwargs = dict()
              while True:
      Severity: Minor
      Found in docido_sdk/crawler/run.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 search_cards has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def search_cards(self, query=None):
              with self.__lock.read():
                  fetch_fields = None
                  if query and 'fields' in query.keys():
                      fetch_fields = query.get('fields', None)
      Severity: Minor
      Found in docido_sdk/index/test.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

      Severity
      Category
      Status
      Source
      Language