martinchristen/pyRT

View on GitHub

Showing 58 of 188 total issues

Function _obj_parse has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

def _obj_parse(line, state):
    geometry = state["geometry"]


    if line[0:6] == "mtllib":
Severity: Minor
Found in pyrt/geometry/importer/obj.py - About 1 day 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 52 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, **kwargs):
        self.position = Vec3(0, 0, 0)
        self.normal = None
        self.color = Vec3(1.,1.,1.)
        self.texcoord = None
Severity: Minor
Found in pyrt/geometry/vertex.py - About 1 day 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 31 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, *args, **kwargs):
        """
        Vec3 can be constructed the following way:

        v1 = Vec4(x,y,z,w)     # 4 integers or floats
Severity: Minor
Found in pyrt/math/vec4.py - About 4 hrs 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

File test.py has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/python3

import unittest

from pyrt.math import *
Severity: Minor
Found in test.py - About 3 hrs to fix

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

        def __init__(self, *args, **kwargs):
            """
            Vec3 can be constructed the following way:
    
            v1 = Vec3(x,y,z)    # 3 integers or floats
    Severity: Minor
    Found in pyrt/math/vec3.py - About 3 hrs 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 _mat_parse has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def _mat_parse(materialfile, state):
        matfile = open(materialfile, "r")
    
        curmtl = ""
        materials = state["materials"]
    Severity: Minor
    Found in pyrt/geometry/importer/obj.py - About 3 hrs 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 hit has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def hit(self, ray: Ray, hitrecord: HitRecord) -> bool:
            """
            Ray Triangle Intersection
            Original Code from:
            "Practical Analysis of Optimized Ray-Triangle Intersection"
    Severity: Minor
    Found in pyrt/geometry/triangle.py - About 2 hrs 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

    File rgbimage.py has 280 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from ..math import Vec2, Vec3
    import random
    from time import time
    from time import sleep
    from typing import Type
    Severity: Minor
    Found in pyrt/renderer/rgbimage.py - About 2 hrs to fix

      File perlin.py has 276 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # Copyright (c) 2008 Casey Duncan (casey dot duncan at gmail dot com)
      
      # Permission is hereby granted, free of charge, to any person obtaining a copy
      # of this software and associated documentation files (the "Software"), to deal
      # in the Software without restriction, including without limitation the rights
      Severity: Minor
      Found in pyrt/math/perlin.py - About 2 hrs to fix

        Function __eq__ has a Cognitive Complexity of 18 (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) == 16:
                        for i in range(0, 16):
                            if abs(self.m[i] - other[i]) > G_EPSILON:
        Severity: Minor
        Found in pyrt/math/mat4.py - About 2 hrs 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 update has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def update(self, myid="pyrtfb", fps=0):
                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 2 hrs 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 noise3 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

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

            def drawLine(self, start: Vec2, end: Vec2, color: Vec3 = Vec3(1.,1.,1.), size : int = 1) -> None:
                """Bresenham's line algorithm
                   modified from: https://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#Python
                """
                dx = abs(end.x - start.x)
        Severity: Minor
        Found in pyrt/renderer/rgbimage.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 getBBox has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def getBBox(self):
                """
                Retrieve axis aligned bounding box of the triangle mesh
        
                :return: bounding box
        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 noise3 has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def noise3(self, x, y, z):
                """3D Perlin simplex noise. 
                
                Return a floating point value from -1 to 1 for the given x, y, z coordinate. 
                The same value is always returned for a given x, y, z pair unless the
        Severity: Minor
        Found in pyrt/math/perlin.py - About 1 hr to fix

          Function inverse4 has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def inverse4(mat: Mat4) -> Mat4:
              """
              Calculate the inverse of the matrix
          
              :param m: matrix to inverse
          Severity: Minor
          Found in pyrt/math/matops.py - About 1 hr to fix

            Function hitShadow has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def hitShadow(self, ray: Ray) -> bool:
                    """
                    :param ray:
                    :param tmin:
                    :param tmax:
            Severity: Minor
            Found in pyrt/geometry/triangle.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 12 (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) == 4:
                            return (abs(self.x - other[0]) < G_EPSILON) and \
                                   (abs(self.y - other[1]) < G_EPSILON) and \
            Severity: Minor
            Found in pyrt/math/vec4.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 _shadow has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def _shadow(self, scene: Scene, hitrecord: HitRecord) -> tuple:
                    # is hitpoint in shadow ?
                    fs = 0.0
                    local_num_shadow_rays = 0
                    numshadow = 0
            Severity: Minor
            Found in pyrt/renderer/simplert.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 make_frame has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def make_frame(t):
                # Specify width/height as in example 5
                width = 320
                height = 240
            
            
            Severity: Minor
            Found in examples/12b_animated_scene.py - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language