oceanprotocol/provider

View on GitHub
ocean_provider/file_types/definitions.py

Summary

Maintainability
C
1 day
Test Coverage
B
84%

Function check_details has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def check_details(self, with_checksum=False):
        """
        If the url argument is invalid, returns False and empty dictionary.
        Otherwise it returns True and a dictionary containing contentType and
        contentLength. If the with_checksum flag is set to True, it also returns
Severity: Minor
Found in ocean_provider/file_types/definitions.py - About 4 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 build_download_response has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def build_download_response(
        self,
        request,
        validate_url=True,
    ):
Severity: Minor
Found in ocean_provider/file_types/definitions.py - About 2 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 _get_result_from_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_result_from_url(self, with_checksum=False):
        func, func_args = self._get_func_and_args()

        # overwrite checksum flag if file is too large
        if with_checksum:
Severity: Minor
Found in ocean_provider/file_types/definitions.py - About 55 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

Consider simplifying this complex logical expression.
Open

                if content_type or content_length or file_name:
                    details = {
                        "contentLength": content_length or "",
                        "contentType": content_type or "",
                        "filename": file_name or "",
Severity: Major
Found in ocean_provider/file_types/definitions.py - About 40 mins to fix

    There are no issues that match your filters.

    Category
    Status