martinchristen/pyRT

View on GitHub

Showing 58 of 188 total issues

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

    def shade(self, camera: Camera, ray: Ray, hitrecord: HitRecord,  lights: list) -> Vec3:
        """
        Shade method: Texture

        texture shader
Severity: Minor
Found in pyrt/material/texturematerial.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 clear has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def clear(self, color: Vec3) -> None:
        """
        Clear Image with specified color
        """
        r = int(color[0]*255.)
Severity: Minor
Found in pyrt/renderer/rgbimage.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 framebuffer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def framebuffer(self, myid="pyrtfb"):
        t0 = time()
        if RGBImage_has_ipython and RBGImage_has_pillow:
            if RGBImage_use_numpy_array:
                im = Image.fromarray(self.data)
Severity: Minor
Found in pyrt/renderer/rgbimage.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 trace_ray_multiprocess has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def trace_ray_multiprocess(engine, scene, x, y):
        ray = scene.camera.primaryRay(x, y)
        hitrecord = HitRecord()
        engine.num_rays += 1

Severity: Minor
Found in pyrt/renderer/mprt.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 True
Severity: Major
Found in pyrt/geometry/triangle.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return False
    Severity: Major
    Found in pyrt/geometry/triangle.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return False
      Severity: Major
      Found in pyrt/geometry/triangle.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return False
        Severity: Major
        Found in pyrt/geometry/triangle.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return True
          Severity: Major
          Found in pyrt/geometry/triangle.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return False
            Severity: Major
            Found in pyrt/geometry/triangle.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return False
              Severity: Major
              Found in pyrt/geometry/triangle.py - About 30 mins to fix

                Function noise2 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def noise2(self, x, y):
                        """2D Perlin simplex noise. 
                        
                        Return a floating point value from -1 to 1 for the given x, y coordinate. 
                        The same value is always returned for a given x, y pair unless the
                Severity: Minor
                Found in pyrt/math/perlin.py - About 25 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 clamp3 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def clamp3(v: Vec3, minVal: Vec3, maxVal:Vec3):
                    """
                    Component-wise clamp
                
                    In case v is smaller than minVal, minVal is returned.
                Severity: Minor
                Found in pyrt/math/vecops.py - About 25 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 __setitem__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __setitem__(self, key, value):
                        if type(key) == tuple:
                            if len(key) != 2:
                                raise IndexError("Index must be 2-dimensional!")
                            x, y = key
                Severity: Minor
                Found in pyrt/math/mat4.py - About 25 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 _repr_html_ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _repr_html_(self):
                        if RGBImage_has_ipython and RBGImage_has_pillow:
                            if RGBImage_use_numpy_array:
                                im = Image.fromarray(self.data)
                            else:
                Severity: Minor
                Found in pyrt/renderer/rgbimage.py - About 25 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 _shade has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _shade(self, scene: Scene, ray: Ray, hitrecord: HitRecord) -> tuple:
                        r = g = b = 0  # background color
                        hit = False
                        for element in scene.nodes:
                            if element.hit(ray, hitrecord):
                Severity: Minor
                Found in pyrt/renderer/simplert.py - About 25 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 __getitem__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __getitem__(self, key):
                        if type(key) == tuple:
                            if len(key) != 2:
                                raise IndexError("Index must be 2-dimensional!")
                            x, y = key
                Severity: Minor
                Found in pyrt/math/mat4.py - About 25 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def snowflake(image: Image, lev: int, x1: int, y1: int, x5: int, y5: int, color: Vec3) -> None:
                    if lev == 0:
                        image.drawLine(Vec2(x1, y1), Vec2(x5, y5), color)
                    else:
                        deltaX = x5 - x1
                Severity: Minor
                Found in examples/02_snowflake.py - About 25 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