Princeton-CDH/ppa-django

View on GitHub
ppa/archive/import_util.py

Summary

Maintainability
C
7 hrs
Test Coverage

File import_util.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""

Import utility classes for creating :mod:`ppa.archives` records from
external sources.

Severity: Minor
Found in ppa/archive/import_util.py - About 4 hrs to fix

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

    def import_digitizedwork(
        self, gale_id, log_msg_src="", user=None, collections=None, **kwargs
    ):
        """Import a single work into the database.
        Retrieves bibliographic data from Gale API."""
Severity: Minor
Found in ppa/archive/import_util.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 import_digitizedwork has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def import_digitizedwork(
Severity: Minor
Found in ppa/archive/import_util.py - About 35 mins to fix

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

    def rsync_data(self):
        """Use rsync to retrieve data for the volumes to be imported."""

        # limit the number of ids included in the log message
        log_detail = ""
Severity: Minor
Found in ppa/archive/import_util.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 import_digitizedwork has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def import_digitizedwork(self, htid, log_msg_src, user):
        # if rsync did not create the expected directory,
        # set error code and bail out
        # if there is a directory but no zip file, bail out
        expected_path = os.path.join(settings.HATHI_DATA, self.pairtree_paths[htid])
Severity: Minor
Found in ppa/archive/import_util.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