CenterForOpenScience/scrapi

View on GitHub
tasks.py

Summary

Maintainability
B
4 hrs
Test Coverage

File tasks.py has 255 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import base64
import logging
import platform
from datetime import date, timedelta
Severity: Minor
Found in tasks.py - About 2 hrs to fix

    Function migrate has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def migrate(migration, sources=None, kwargs_string=None, dry=True, async=False, group_size=1000):
    Severity: Minor
    Found in tasks.py - About 45 mins to fix

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

      def migrate(migration, sources=None, kwargs_string=None, dry=True, async=False, group_size=1000):
          ''' Task to run a migration.
      
          :param migration: The migration function to run. This is passed in
          as a string then interpreted as a function by the invoke task.
      Severity: Minor
      Found in tasks.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 test has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def test(cov=True, doctests=True, verbose=False, debug=False, pdb=False):
      Severity: Minor
      Found in tasks.py - About 35 mins to fix

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

        def harvesters(async=False, start=None, end=None):
            ''' Runs all harvesters '''
            from scrapi import settings
            settings.CELERY_ALWAYS_EAGER = not async
            from scrapi import registry
        Severity: Minor
        Found in tasks.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