martinchristen/pyRT

View on GitHub

Showing 188 of 188 total issues

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 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

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 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

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

      Identical blocks of code found in 5 locations. Consider refactoring.
      Open

          image.drawRectangle(Vec2(random.randint(0, w - 1), random.randint(0, h - 1)),
      Severity: Major
      Found in examples/04_rectangle.py and 4 other locations - About 30 mins to fix
      examples/00_drawpoints.py on lines 13..13
      examples/01_drawlines.py on lines 14..14
      examples/01_drawlines.py on lines 15..15
      examples/03_circle.py on lines 15..15

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 32.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 5 locations. Consider refactoring.
      Open

          image.drawLine(Vec2(random.randint(0, w - 1), random.randint(0, h - 1)),
      Severity: Major
      Found in examples/01_drawlines.py and 4 other locations - About 30 mins to fix
      examples/00_drawpoints.py on lines 13..13
      examples/01_drawlines.py on lines 15..15
      examples/03_circle.py on lines 15..15
      examples/04_rectangle.py on lines 15..15

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 32.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Avoid too many return statements within this function.
      Open

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

        Identical blocks of code found in 5 locations. Consider refactoring.
        Open

            image.drawPoint(Vec2(random.randint(0, w - 1), random.randint(0, h - 1)),
        Severity: Major
        Found in examples/00_drawpoints.py and 4 other locations - About 30 mins to fix
        examples/01_drawlines.py on lines 14..14
        examples/01_drawlines.py on lines 15..15
        examples/03_circle.py on lines 15..15
        examples/04_rectangle.py on lines 15..15

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 32.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

                Identical blocks of code found in 5 locations. Consider refactoring.
                Open

                    image.drawCircle(Vec2(random.randint(0, w - 1), random.randint(0, h - 1)),  # Center
                Severity: Major
                Found in examples/03_circle.py and 4 other locations - About 30 mins to fix
                examples/00_drawpoints.py on lines 13..13
                examples/01_drawlines.py on lines 14..14
                examples/01_drawlines.py on lines 15..15
                examples/04_rectangle.py on lines 15..15

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 32.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 5 locations. Consider refactoring.
                Open

                                   Vec2(random.randint(0, w - 1), random.randint(0, h - 1)),
                Severity: Major
                Found in examples/01_drawlines.py and 4 other locations - About 30 mins to fix
                examples/00_drawpoints.py on lines 13..13
                examples/01_drawlines.py on lines 14..14
                examples/03_circle.py on lines 15..15
                examples/04_rectangle.py on lines 15..15

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 32.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                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 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

                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 _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

                Severity
                Category
                Status
                Source
                Language