oceanprotocol/provider

View on GitHub
ocean_provider/utils/url.py

Summary

Maintainability
A
2 hrs
Test Coverage
B
85%

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 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 url
Severity: Major
Found in ocean_provider/utils/url.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return get_redirect(location, redirect_count + 1)
    Severity: Major
    Found in ocean_provider/utils/url.py - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status