USDA-ARS-NWRC/topocalc

View on GitHub

Showing 5 of 19 total issues

Function horizon has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def horizon(azimuth, dem, spacing):
    """Calculate horizon angles for one direction. Horizon angles
    are based on Dozier and Frew 1990 and are adapted from the
    IPW C code.

Severity: Minor
Found in topocalc/horizon.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 skew has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def skew(arr, angle, fwd=True, fill_min=True):
    """
    Skew the origin of successive lines by a specified angle
    A skew with angle of 30 degrees causes the following transformation:

Severity: Minor
Found in topocalc/skew.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

Consider simplifying this complex logical expression.
Open

    if azimuth == 90:
        # East
        hcos = hor2d_c(dem, spacing, fwd=True)

    elif azimuth == -90:
Severity: Major
Found in topocalc/horizon.py - About 40 mins to fix

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

    def viewf(dem, spacing, nangles=72, sin_slope=None, aspect=None):
    Severity: Minor
    Found in topocalc/viewf.py - About 35 mins to fix

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

      def viewf(dem, spacing, nangles=72, sin_slope=None, aspect=None):
          """
          Calculate the sky view factor of a dem.
      
          The sky view factor from equation 7b from Dozier and Frew 1990
      Severity: Minor
      Found in topocalc/viewf.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

      Severity
      Category
      Status
      Source
      Language