hoverinc/ray-tracing-renderer

View on GitHub

Showing 82 of 82 total issues

Function set has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function set(name, value) {
    if (!uniforms[name]) {
      // console.warn('No uniform property with name ', name);
      return;
    }
Severity: Minor
Found in src/renderer/UniformBuffer.js - About 1 hr to fix

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

      } else if (storage === 'halfFloat') {
        internalFormat = {
          1: gl.R16F,
          2: gl.RG16F,
          3: gl.RGB16F,
    Severity: Major
    Found in src/renderer/Texture.js and 2 other locations - About 1 hr to fix
    src/renderer/Texture.js on lines 146..173
    src/renderer/Texture.js on lines 164..173

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

    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

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

      } else if (storage === 'float' || (!storage && isFloatArray)) {
        internalFormat = {
          1: gl.R32F,
          2: gl.RG32F,
          3: gl.RGB32F,
    Severity: Major
    Found in src/renderer/Texture.js and 2 other locations - About 1 hr to fix
    src/renderer/Texture.js on lines 155..173
    src/renderer/Texture.js on lines 164..173

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

    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

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

      } else if (storage === 'snorm') {
        internalFormat = {
          1: gl.R8_SNORM,
          2: gl.RG8_SNORM,
          3: gl.RGB8_SNORM,
    Severity: Major
    Found in src/renderer/Texture.js and 2 other locations - About 1 hr to fix
    src/renderer/Texture.js on lines 146..173
    src/renderer/Texture.js on lines 155..173

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

    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 initWebGL has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function initWebGL(envMapLDR, model) {
      unloadRenderer(renderer);
      renderer = new THREE.WebGLRenderer({
        antialias: true
      });
    Severity: Minor
    Found in scenes/webgl-comparison/main.js - About 1 hr to fix

      Function envMapDistribution has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function envMapDistribution(image) {
        const data = image.data;
      
        const cdfImage = {
          width: image.width + 2,
      Severity: Minor
      Found in src/renderer/envMapDistribution.js - About 1 hr to fix

        Function makePrimitiveInfo has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function makePrimitiveInfo(geometry) {
          const primitiveInfo = [];
          const indices = geometry.getIndex().array;
          const position = geometry.getAttribute('position');
          const materialMeshIndex = geometry.getAttribute('materialMeshIndex');
        Severity: Minor
        Found in src/renderer/bvhAccel.js - About 1 hr to fix

          Function partition has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          export function partition(array, compare, left = 0, right = array.length) {
            while (left !== right) {
              while (compare(array[left])) {
                left++;
                if (left === right) {
          Severity: Minor
          Found in src/renderer/bvhUtil.js - 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 getTextureFormat has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function getTextureFormat(gl, channels, storage, data, gammaCorrection) {
            let type;
            let internalFormat;
          
            const isByteArray =
          Severity: Minor
          Found in src/renderer/Texture.js - 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 addLightAtCoordinates has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function addLightAtCoordinates(light, image, originCoords) {
            const floatBuffer = image.data;
            const width = image.width;
            const height = image.height;
            const xTexels = floatBuffer.length / (3 * height);
          Severity: Minor
          Found in src/renderer/envMapCreation.js - 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 addLightAtCoordinates has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function addLightAtCoordinates(light, image, originCoords) {
            const floatBuffer = image.data;
            const width = image.width;
            const height = image.height;
            const xTexels = floatBuffer.length / (3 * height);
          Severity: Minor
          Found in src/renderer/envMapCreation.js - About 1 hr to fix

            Function init has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function init() {
              const [envMap, envMapLDR, gltf] = await Promise.all([
                load(THREE.RGBELoader, '../envmaps/street-by-water.hdr'),
                load(THREE.TextureLoader, 'envmap.jpg'),
                load(THREE.GLTFLoader, 'scene.gltf'),
            Severity: Minor
            Found in scenes/webgl-comparison/main.js - About 1 hr to fix

              Function mergeGeometry has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function mergeGeometry(geometryAndMaterialIndex, vertexCount, indexCount) {
                const positionAttrib = new BufferAttribute(new Float32Array(3 * vertexCount), 3, false);
                const normalAttrib = new BufferAttribute(new Float32Array(3 * vertexCount), 3, false);
                const uvAttrib = new BufferAttribute(new Float32Array(2 * vertexCount), 2, false);
                const materialMeshIndexAttrib = new BufferAttribute(new Int32Array(2 * vertexCount), 2, false);
              Severity: Minor
              Found in src/renderer/mergeMeshesToGeometry.js - About 1 hr to fix

                Function render has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  module.render = (scene, camera) => {
                    if (!module.renderWhenOffFocus) {
                      const hasFocus = document.hasFocus();
                      if (!hasFocus) {
                        lastFocus = hasFocus;
                Severity: Minor
                Found in src/RayTracingRenderer.js - About 1 hr to fix

                  Function drawFull has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function drawFull(camera) {
                      if (!ready) {
                        return;
                      }
                  
                  
                  Severity: Minor
                  Found in src/renderer/RenderingPipeline.js - About 1 hr to fix

                    Function initFrameBuffers has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function initFrameBuffers(width, height) {
                        const makeHdrBuffer = () => makeFramebuffer(gl, {
                          color: { 0: makeTexture(gl, { width, height, storage: 'float', magFilter: gl.LINEAR, minFilter: gl.LINEAR }) }
                        });
                    
                    
                    Severity: Minor
                    Found in src/renderer/RenderingPipeline.js - About 1 hr to fix

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

                      export function makeMaterialBuffer(gl, materials) {
                        const maps = getTexturesFromMaterials(materials, ['map', 'normalMap']);
                        const pbrMap = mergeTexturesFromMaterials(materials, ['roughnessMap', 'metalnessMap']);
                      
                        const textures = {};
                      Severity: Minor
                      Found in src/renderer/MaterialBuffer.js - 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 flattenBvh has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function flattenBvh(bvh) {
                        const flat = [];
                        const isBounds = [];
                      
                        const splitAxisMap = {
                      Severity: Minor
                      Found in src/renderer/bvhAccel.js - 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 makeStratifiedSampler has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function makeStratifiedSampler(strataCount, dimensions) {
                        const strata = [];
                        const l = strataCount ** dimensions;
                        for (let i = 0; i < l; i++) {
                          strata[i] = i;
                      Severity: Minor
                      Found in src/renderer/StratifiedSampler.js - About 1 hr to fix

                        Function init has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        async function init() {
                          window.addEventListener('resize', resize);
                          resize();
                        
                          selectEnvMapFromName(INITIAL_ENV_MAP.name);
                        Severity: Minor
                        Found in scenes/sample-models/main.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language