cogniteev/docido-python-sdk

View on GitHub

Showing 39 of 49 total issues

Function refresh_token has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def refresh_token(token, session=None):
    """Refresh Google OAuth token.

    :param OAuthToken token:
      the token to refresh
Severity: Minor
Found in docido_sdk/toolbox/google_ext.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 _prepare_index_bulk_query has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _prepare_index_bulk_query(cls, docs, action):
        body = []
        errors = []
        for doc in docs:
            if not isinstance(doc, (dict, Mapping)):
Severity: Minor
Found in docido_sdk/index/processor/es_api.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 push_cards has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def push_cards(self, cards):
        for i in range(len(cards)):
            try:
                c = cards[i]
                if 'kind' not in c:
Severity: Minor
Found in docido_sdk/index/processor/check.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

Avoid deeply nested control flow statements.
Open

                        if item[operation]['status'] not in [200, 201]:
                            error_docs.append({
                                'card': docs[index],
                                'status': item[operation]['status'],
                                'id': docs[index]['id']
Severity: Major
Found in docido_sdk/index/processor/es_api.py - About 45 mins to fix

    Function wait_or_raise has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def wait_or_raise(logger, retry_exc, attempt):
        wait_time = None
        if attempt == retry_exc.max_retries:
            raise retry_exc
        if retry_exc.countdown is not None:
    Severity: Minor
    Found in docido_sdk/crawler/run.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 from_env has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_env(cls, envvars, default, default_config):
            try:
                if isinstance(envvars, six.string_types):
                    envvars = [envvars]
                config_file = default
    Severity: Minor
    Found in docido_sdk/toolbox/collections_ext.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, kwargs=None, countdown=None, exc=None,
    Severity: Minor
    Found in docido_sdk/crawler/errors.py - About 35 mins to fix

      Function teb_retry has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def teb_retry(exc=RequestException,
      Severity: Minor
      Found in docido_sdk/toolbox/rate_limits.py - About 35 mins to fix

        Function truncated_exponential_backoff has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def truncated_exponential_backoff(
        Severity: Minor
        Found in docido_sdk/toolbox/rate_limits.py - About 35 mins to fix

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

              def register(cls, component=None):
                  component = component or cls
                  cls._components.add(component)
                  registry = cls._registry
                  for cls in component.__mro__:
          Severity: Minor
          Found in docido_sdk/core.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

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

              def _eval_exp(cls, obj, exp, value):
                  op = operator.eq
                  tokens = exp.split('__')[::-1]
                  _op = cls._get_operation(tokens[0])
                  if _op is not None:
          Severity: Minor
          Found in docido_sdk/toolbox/edsl.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

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

          def decorate_instance_methods(obj, decorator, includes=None, excludes=None):
              """Decorator instance methods of an object.
          
              :param obj: Python object whose instance methods have to be decorated
              :param decorator:
          Severity: Minor
          Found in docido_sdk/toolbox/decorators.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 unicode(text)
          Severity: Major
          Found in docido_sdk/toolbox/text.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return ' '.join([to_unicode(arg) for arg in text.args])
            Severity: Major
            Found in docido_sdk/toolbox/text.py - About 30 mins to fix

              Function mount_rate_limit_adapters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def mount_rate_limit_adapters(cls, session=None,
                                                rls_config=None, **kwargs):
                      """Mount rate-limits adapters on the specified `requests.Session`
                      object.
              
              
              Severity: Minor
              Found in docido_sdk/toolbox/http_ext.py - About 25 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 _get_obj_attr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _get_obj_attr(cls, obj, path, pos):
                      """Resolve one kwargsql expression for a given object and returns
                      its result.
              
                      :param obj: the object to evaluate
              Severity: Minor
              Found in docido_sdk/toolbox/edsl.py - About 25 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 __getitem__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __getitem__(self, cls):
                      """Activate the component instance for the given class, or
                      return the existing instance if the component has already been
                      activated.
              
              
              Severity: Minor
              Found in docido_sdk/core.py - About 25 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 fix_mispelled_day has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def fix_mispelled_day(cls, timestr):
                      """fix mispelled day when written in english
              
                      :return: `None` if the day was not modified, the new date otherwise
                      """
              Severity: Minor
              Found in docido_sdk/toolbox/date_ext.py - About 25 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 __call__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __call__(self, units=1, waits=True, context=None):
                      """To be called before consuming a resource that is subject to rate-limits.
              
                      :param units:
                        Number of units consumed by the API call that is about to be made.
              Severity: Minor
              Found in docido_sdk/toolbox/rate_limits.py - About 25 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