cogniteev/docido-python-sdk

View on GitHub

Showing 49 of 49 total issues

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

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

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

          class CrawlerError(DocidoError):
              """Common base exception class for crawl issues"""
              def __init__(self, message=None):
                  """
                  @param message: optional printable object providing
          Severity: Major
          Found in docido_sdk/crawler/errors.py and 3 other locations - About 35 mins to fix
          docido_sdk/crawler/errors.py on lines 21..31
          docido_sdk/crawler/errors.py on lines 34..43
          docido_sdk/crawler/errors.py on lines 46..56

          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 33.

          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 4 locations. Consider refactoring.
          Open

          class OAuthTokenRefreshRequiredError(CrawlerError):
              """Exception class used to notify crawler manager when
              the OAuth token of an account has expired or will expire
              shortly, and need to be refreshed programmaticaly.
              """
          Severity: Major
          Found in docido_sdk/crawler/errors.py and 3 other locations - About 35 mins to fix
          docido_sdk/crawler/errors.py on lines 11..18
          docido_sdk/crawler/errors.py on lines 21..31
          docido_sdk/crawler/errors.py on lines 34..43

          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 33.

          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 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

          Severity
          Category
          Status
          Source
          Language