cogniteev/docido-python-sdk

View on GitHub

Showing 49 of 49 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def delete_thumbnails_by_id(self, ids):
        errors = []
        with self.__update(thumbnails=True):
            for _id in ids:
                if _id not in self.__thumbnails:
Severity: Major
Found in docido_sdk/index/test.py and 1 other location - About 3 hrs to fix
docido_sdk/index/test.py on lines 167..175

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 72.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def delete_cards_by_id(self, ids):
        errors = []
        with self.__update(cards=True):
            for _id in ids:
                if _id not in self.__cards:
Severity: Major
Found in docido_sdk/index/test.py and 1 other location - About 3 hrs to fix
docido_sdk/index/test.py on lines 227..235

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 72.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        def delete_cards(self, query=None):
            if query != {'query': {'match_all': {}}}:
                raise IndexAPIError(
                    'only match_all query is currently supported, you should use' +
                    ' the ElasticSearch processor along with es-settings.yml ' +
    Severity: Major
    Found in docido_sdk/index/test.py and 1 other location - About 2 hrs to fix
    docido_sdk/index/test.py on lines 217..225

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 59.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        def delete_thumbnails(self, query):
            if query != {'query': {'match_all': {}}}:
                raise IndexAPIError(
                    'only match_all query is currently supported, you should use' +
                    ' the ElasticSearch processor along with es-settings.yml ' +
    Severity: Major
    Found in docido_sdk/index/test.py and 1 other location - About 2 hrs to fix
    docido_sdk/index/test.py on lines 157..165

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 59.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def delete_cards(self, query):
              try:
                  self.query_schema(query)
              except voluptuous.MultipleInvalid as e:
                  raise IndexAPIError(e)
      Severity: Major
      Found in docido_sdk/index/processor/check.py and 1 other location - About 1 hr to fix
      docido_sdk/index/processor/check.py on lines 91..96

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 48.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def delete_thumbnails(self, query):
              try:
                  self.query_schema(query)
              except voluptuous.MultipleInvalid as e:
                  raise IndexAPIError(e)
      Severity: Major
      Found in docido_sdk/index/processor/check.py and 1 other location - About 1 hr to fix
      docido_sdk/index/processor/check.py on lines 98..103

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 48.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

      Severity
      Category
      Status
      Source
      Language