cogniteev/docido-python-sdk

View on GitHub
docido_sdk/index/processor/es_api.py

Summary

Maintainability
B
4 hrs
Test Coverage

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

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

    There are no issues that match your filters.

    Category
    Status