CenterForOpenScience/scrapi

View on GitHub
scrapi/base/helpers.py

Summary

Maintainability
C
1 day
Test Coverage

File helpers.py has 354 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import unicode_literals

import re
import logging
import functools
Severity: Minor
Found in scrapi/base/helpers.py - About 4 hrs to fix

    Function seperate_provider_object_uris has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def seperate_provider_object_uris(identifiers):
        object_uris = gather_object_uris(identifiers)
        provider_uris = []
        for item in identifiers:
    
    
    Severity: Minor
    Found in scrapi/base/helpers.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 format_tags has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def format_tags(all_tags, sep=','):
        tags = []
        if isinstance(all_tags, six.string_types):
            tags = all_tags.split(sep)
        elif isinstance(all_tags, list):
    Severity: Minor
    Found in scrapi/base/helpers.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 oai_get_records_and_token has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def oai_get_records_and_token(url, throttle, force, namespaces, verify):
    Severity: Minor
    Found in scrapi/base/helpers.py - About 35 mins to fix

      Function oai_extract_dois has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def oai_extract_dois(*args):
          identifiers = gather_identifiers(args)
          dois = []
          for item in identifiers:
              if 'doi' in item.lower():
      Severity: Minor
      Found in scrapi/base/helpers.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 gather_identifiers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def gather_identifiers(args):
          identifiers = []
          for arg in args:
              if isinstance(arg, list):
                  for identifier in arg:
      Severity: Minor
      Found in scrapi/base/helpers.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 oai_process_uris has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def oai_process_uris(*args, **kwargs):
          use_doi = kwargs.get('use_doi', False)
      
          identifiers = gather_identifiers(args)
          provider_uris, object_uris = seperate_provider_object_uris(identifiers)
      Severity: Minor
      Found in scrapi/base/helpers.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 gather_object_uris has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def gather_object_uris(identifiers):
          '''
          Gathers object URIs if there are any
          >>> gathered = gather_object_uris(['nopenope', 'doi:10.10.gettables', 'http://dx.doi.org/yep'])
          >>> print(gathered[0])
      Severity: Minor
      Found in scrapi/base/helpers.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

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

      def updated_schema(old, new):
          ''' Creates a dictionary resulting from adding all keys/values of the second to the first
              The second dictionary will overwrite the first.
      
              >>> old, new = {'name': 'ric', 'job': None}, {'name': 'Rick'}
      Severity: Minor
      Found in scrapi/base/helpers.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