martinchristen/pyRT

View on GitHub

Showing 58 of 188 total issues

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

    def load(self, filename):
        """
        Load 3d object from file (obj format).
        (Please note that a triangle mesh is not a scene! Only single material, single meshes are imported.)
        (also, the importer is really simple. Meshes must be triangulated before!!)
Severity: Minor
Found in pyrt/geometry/trianglemesh.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 __eq__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def __eq__(self, other):
        if type(other) == list or type(other) == tuple:  # not checking type within tuple/list
            if len(other) == 3:
                return (abs(self.x - other[0]) < G_EPSILON) and (abs(self.y - other[1]) < G_EPSILON) and (
                    abs(self.z - other[2]) < G_EPSILON)
Severity: Minor
Found in pyrt/math/vec3.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 testCamera has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def testCamera(self):
        w=320
        h=240

        # Create a camere with width, height and field of view:
Severity: Minor
Found in test.py - About 1 hr to fix

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

        def __init__(self, elm=None):
            """
            elm:
                if None this will create a matrix initialized with 0
    
    
    Severity: Minor
    Found in pyrt/math/mat4.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 __eq__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def __eq__(self, other):
            if type(other) == list or type(other) == tuple:  # not checking type within tuple/list
                if len(other) == 2:
                    return (abs(self.x - other[0]) < G_EPSILON) and (abs(self.y - other[1]) < G_EPSILON)
                else:
    Severity: Minor
    Found in pyrt/math/vec2.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 __init__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, period=None, permutation_table=None, randint_function=None):
            """Initialize the noise generator. With no arguments, the default
            period and permutation table are used (256). The default permutation
            table generates the exact same noise pattern each time.
            
    Severity: Minor
    Found in pyrt/math/perlin.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 snowflake has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def snowflake(image: Image, lev: int, x1: int, y1: int, x5: int, y5: int, color: Vec3) -> None:
    Severity: Major
    Found in examples/02_snowflake.py - About 50 mins to fix

      Function clamp4 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def clamp4(v: Vec4, minVal: Vec4, maxVal: Vec4):
          """
          Component-wise clamp
      
          In case v is smaller than minVal, minVal is returned.
      Severity: Minor
      Found in pyrt/math/vecops.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 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, position: Vec3, direction: Vec3, p: int, a = 0.02, b = 0.1, c = 0) -> None:
      Severity: Minor
      Found in pyrt/light/spotlight.py - About 45 mins to fix

        Function __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, start: Vec3, direction: Vec3) -> None:
                if type(start) != Vec3 or type(direction) != Vec3:
                    print("Error: start and direction must be Vec3")
                    return
        
        
        Severity: Minor
        Found in pyrt/math/ray.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 createOrtho4 has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def createOrtho4(left: float, right : float, bottom: float, top: float, znear: float, zfar: float) -> Mat4:
        Severity: Minor
        Found in pyrt/math/matops.py - About 45 mins to fix

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

              def __init__(self, color: Vec3 = Vec3(1., 1., 1.), shininess: float = 10.0, reflectivity: float = 0.0,
          Severity: Minor
          Found in pyrt/material/normalmappedmaterial.py - About 45 mins to fix

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

                def drawPixelFast8(self, x: int, y: int, r: int, g: int, b: int) -> None:
            Severity: Minor
            Found in pyrt/renderer/rgbimage.py - About 35 mins to fix

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

                  def __init__(self, color: Vec3 = Vec3(1.,1.,1.), shininess: float = 10.0, reflectivity: float = 0.0, refraction: float = 1.0,
              Severity: Minor
              Found in pyrt/material/texturematerial.py - About 35 mins to fix

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

                    def __init__(self, color: Vec3 = Vec3(0.,0.,0.), shininess: float = 0.0, reflectivity: float = 0.5, refraction: float = 1.0, transparency = 0.0):
                Severity: Minor
                Found in pyrt/material/material.py - About 35 mins to fix

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

                      def noise3(self, x, y, z, repeat, base=0.0):
                  Severity: Minor
                  Found in pyrt/math/perlin.py - About 35 mins to fix

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

                        def setProjection(self, fov: float, width: int, height: int, znear: float, zfar: float):
                    Severity: Minor
                    Found in pyrt/camera/perspectivecamera.py - About 35 mins to fix

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

                          def drawCircleFilled(self, center: Vec2, radius: int, color: Vec3, fillcolor: Vec3, size : int = 1):
                      Severity: Minor
                      Found in pyrt/renderer/rgbimage.py - About 35 mins to fix

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

                            def __init__(self, color: Vec3 = Vec3(1.,1.,1.), shininess: float = 10.0, reflectivity: float = 0.0, refraction: float = 1.0, transparency = 0.0):
                        Severity: Minor
                        Found in pyrt/material/phongmaterial.py - About 35 mins to fix

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

                              def hit(self, ray: Ray, hitrecord: HitRecord) -> bool:
                                  """
                                  Hit ray with sphere.
                          
                                  :param ray: the ray to check hit
                          Severity: Minor
                          Found in pyrt/geometry/sphere.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