oceanprotocol/provider

View on GitHub
ocean_provider/validation/algo.py

Summary

Maintainability
F
3 days
Test Coverage
B
89%

File algo.py has 476 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#
# Copyright 2023 Ocean Protocol Foundation
# SPDX-License-Identifier: Apache-2.0
#
import json
Severity: Minor
Found in ocean_provider/validation/algo.py - About 7 hrs to fix

    Function validate_input has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_input(self, index=0):
            """Validates input dictionary."""
            main_input = self.data["dataset"]
            additional_inputs = self.data.get("additionalDatasets", list())
    
    
    Severity: Minor
    Found in ocean_provider/validation/algo.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 validate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self):
            required_keys = (
                ["documentId", "transferTxId"] if self.check_usage else ["documentId"]
            )
    
    
    Severity: Minor
    Found in ocean_provider/validation/algo.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 _validate_trusted_algos has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _validate_trusted_algos(
            self, algorithm_did, trusted_algorithms, trusted_publishers
        ):
            if not trusted_algorithms and not trusted_publishers:
                return True
    Severity: Minor
    Found in ocean_provider/validation/algo.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 _build_and_validate_algo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def _build_and_validate_algo(self, algo_data):
            """Returns False if invalid, otherwise sets the validated_algo_dict attribute."""
            algorithm_did = algo_data.get("documentId")
            self.algo_service = None
            self.algo = None
    Severity: Minor
    Found in ocean_provider/validation/algo.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 preliminary_algo_validation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def preliminary_algo_validation(self):
            algo_data = self.data["algorithm"]
            algorithm_did = algo_data.get("documentId")
            algorithm_service_id = algo_data.get("serviceId")
            algorithm_meta = algo_data.get("meta")
    Severity: Minor
    Found in ocean_provider/validation/algo.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in ocean_provider/validation/algo.py - About 35 mins to fix

      Avoid too many return statements within this function.
      Open

                  return False
      Severity: Major
      Found in ocean_provider/validation/algo.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return False
        Severity: Major
        Found in ocean_provider/validation/algo.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return False
          Severity: Major
          Found in ocean_provider/validation/algo.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return False
            Severity: Major
            Found in ocean_provider/validation/algo.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return True
              Severity: Major
              Found in ocean_provider/validation/algo.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return False
                Severity: Major
                Found in ocean_provider/validation/algo.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return True
                  Severity: Major
                  Found in ocean_provider/validation/algo.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return False
                    Severity: Major
                    Found in ocean_provider/validation/algo.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return False
                      Severity: Major
                      Found in ocean_provider/validation/algo.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return self.validate_usage() if self.check_usage else True
                        Severity: Major
                        Found in ocean_provider/validation/algo.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return False
                          Severity: Major
                          Found in ocean_provider/validation/algo.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return True
                            Severity: Major
                            Found in ocean_provider/validation/algo.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                              return False
                              Severity: Major
                              Found in ocean_provider/validation/algo.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return False
                                Severity: Major
                                Found in ocean_provider/validation/algo.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                              return False
                                  Severity: Major
                                  Found in ocean_provider/validation/algo.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return True
                                    Severity: Major
                                    Found in ocean_provider/validation/algo.py - About 30 mins to fix

                                      There are no issues that match your filters.

                                      Category
                                      Status