CenterForOpenScience/scrapi

View on GitHub
scrapi/processing/cassandra.py

Summary

Maintainability
B
5 hrs
Test Coverage

File cassandra.py has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import absolute_import

import six
import json
import logging
Severity: Minor
Found in scrapi/processing/cassandra.py - About 2 hrs to fix

    Function to_normalized has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_normalized(self, doc):
            # make the new dict actually contain real items
            normed = {}
            do_not_include = ['docID', 'doc', 'filetype', 'timestamps', 'source', 'versions', 'key']
            for key, value in dict(doc).items():
    Severity: Minor
    Found in scrapi/processing/cassandra.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 documents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def documents(self, *sources):
            q = DocumentModel.objects.timeout(500).allow_filtering().all().limit(100)
            querysets = (q.filter(source=source) for source in sources) if sources else [q]
            for query in querysets:
                page = try_n_times(5, list, query)
    Severity: Minor
    Found in scrapi/processing/cassandra.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 setup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def setup(self, force=False, sync=True):
            if self._setup and not force:
                return True
    
            try:
    Severity: Minor
    Found in scrapi/processing/cassandra.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

    There are no issues that match your filters.

    Category
    Status