oceanprotocol/provider

View on GitHub

Showing 67 of 71 total issues

Function get_c2d_environments has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_c2d_environments(flat=False):
    if not os.getenv("OPERATOR_SERVICE_URL"):
        return []

    standard_headers = {"Content-Type": "application/json", "Connection": "close"}
Severity: Minor
Found in ocean_provider/utils/compute_environments.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 get_redirect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_redirect(url, redirect_count=0):
    if not is_url(url):
        return None

    if redirect_count > 5:
Severity: Minor
Found in ocean_provider/utils/url.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 verify_order_tx has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

def verify_order_tx(
Severity: Major
Found in ocean_provider/utils/datatoken.py - About 1 hr to fix

    Function _decrypt has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _decrypt(
    Severity: Major
    Found in ocean_provider/routes/decrypt.py - About 1 hr to fix

      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

      Function validate_and_create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_and_create(file_obj) -> Tuple[bool, Any]:
              if not file_obj:
                  return False, "cannot decrypt files for this service."
      
              try:
      Severity: Minor
      Found in ocean_provider/file_types/file_types_factory.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

      Function send_proof has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def send_proof(
      Severity: Major
      Found in ocean_provider/utils/proof.py - About 50 mins to fix

        Function get_provider_fees_or_remote has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def get_provider_fees_or_remote(
        Severity: Major
        Found in ocean_provider/utils/provider_fees.py - About 50 mins to fix

          Function validate_order has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def validate_order(
          Severity: Major
          Found in ocean_provider/utils/datatoken.py - About 50 mins to fix

            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 record_consume_request has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def record_consume_request(
            Severity: Minor
            Found in ocean_provider/utils/datatoken.py - About 45 mins to fix

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

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

                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

                  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/file_types.py - About 40 mins to fix

                    Function validate_transfer_not_used_for_other_service has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def validate_transfer_not_used_for_other_service(
                    Severity: Minor
                    Found in ocean_provider/utils/datatoken.py - About 35 mins to fix

                      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

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

                        def send_proof(
                            chain_id,
                            order_tx_id,
                            provider_data,
                            consumer_data,
                        Severity: Minor
                        Found in ocean_provider/utils/proof.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 update_nonce has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def update_nonce(address, nonce_value):
                            """
                            Updates the value of `nonce` in the database
                            :param: address
                            :param: nonce_value
                        Severity: Minor
                        Found in ocean_provider/user_nonce.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 validate_dns_record has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def validate_dns_record(record, domain, record_type):
                            value = record if isinstance(record, str) else record.to_text().strip()
                            allow_non_public_ip = bool_value_of_env("ALLOW_NON_PUBLIC_IP")
                        
                            try:
                        Severity: Minor
                        Found in ocean_provider/utils/url.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

                        Avoid too many return statements within this function.
                        Open

                                    return error_response(f"Provider {network_name}: " + message, 400, logger)
                        Severity: Major
                        Found in ocean_provider/routes/consume.py - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language