BabylonJS/Spector.js

View on GitHub
src/backend/states/drawCalls/drawCallState.ts

Summary

Maintainability
F
4 days
Test Coverage

File drawCallState.ts has 456 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { BaseState } from "../baseState";
import { WebGlConstants, WebGlConstantsByName, WebGlConstant, WebGlConstantsByValue } from "../../types/webglConstants";
import { DrawCallTextureInputState } from "./drawCallTextureInputState";
import { DrawCallUboInputState } from "./drawCallUboInputState";
import { ProgramRecompilerHelper } from "../../utils/programRecompilerHelper";
Severity: Minor
Found in src/backend/states/drawCalls/drawCallState.ts - About 6 hrs to fix

    Function readFromContext has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        protected readFromContext(): void {
            const program = this.context.getParameter(WebGlConstants.CURRENT_PROGRAM.value);
            if (!program) {
                return;
            }
    Severity: Minor
    Found in src/backend/states/drawCalls/drawCallState.ts - About 5 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 readFromContext has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected readFromContext(): void {
            const program = this.context.getParameter(WebGlConstants.CURRENT_PROGRAM.value);
            if (!program) {
                return;
            }
    Severity: Major
    Found in src/backend/states/drawCalls/drawCallState.ts - About 3 hrs to fix

      Function readUniformFromContext has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          protected readUniformFromContext(program: WebGLProgram, activeUniformIndex: number): {} {
              const info = this.context.getActiveUniform(program, activeUniformIndex);
              const location = this.context.getUniformLocation(program, info.name);
              if (location) {
      
      
      Severity: Minor
      Found in src/backend/states/drawCalls/drawCallState.ts - 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 readFrameBufferFromContext has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          protected readFrameBufferFromContext(): any {
              const frameBuffer = this.context.getParameter(WebGlConstants.FRAMEBUFFER_BINDING.value);
              if (!frameBuffer) {
                  return null;
              }
      Severity: Minor
      Found in src/backend/states/drawCalls/drawCallState.ts - 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 readFrameBufferAttachmentFromContext has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          protected readFrameBufferAttachmentFromContext(attachment: number): any {
              const target = WebGlConstants.FRAMEBUFFER.value;
              const type = this.context.getFramebufferAttachmentParameter(target, attachment, WebGlConstants.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.value);
              if (type === WebGlConstants.NONE.value) {
                  return undefined;
      Severity: Minor
      Found in src/backend/states/drawCalls/drawCallState.ts - 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 readUniformFromContext has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected readUniformFromContext(program: WebGLProgram, activeUniformIndex: number): {} {
              const info = this.context.getActiveUniform(program, activeUniformIndex);
              const location = this.context.getUniformLocation(program, info.name);
              if (location) {
      
      
      Severity: Minor
      Found in src/backend/states/drawCalls/drawCallState.ts - About 2 hrs to fix

        Function readFrameBufferAttachmentFromContext has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected readFrameBufferAttachmentFromContext(attachment: number): any {
                const target = WebGlConstants.FRAMEBUFFER.value;
                const type = this.context.getFramebufferAttachmentParameter(target, attachment, WebGlConstants.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.value);
                if (type === WebGlConstants.NONE.value) {
                    return undefined;
        Severity: Minor
        Found in src/backend/states/drawCalls/drawCallState.ts - About 1 hr to fix

          Function readTextureFromContext has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected readTextureFromContext(textureUnit: number, target: WebGlConstant): {} {
                  const activeTexture = this.context.getParameter(WebGlConstants.ACTIVE_TEXTURE.value);
          
                  this.context.activeTexture(WebGlConstants.TEXTURE0.value + textureUnit);
                  const textureState: any = {
          Severity: Minor
          Found in src/backend/states/drawCalls/drawCallState.ts - About 1 hr to fix

            Function readFrameBufferFromContext has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected readFrameBufferFromContext(): any {
                    const frameBuffer = this.context.getParameter(WebGlConstants.FRAMEBUFFER_BINDING.value);
                    if (!frameBuffer) {
                        return null;
                    }
            Severity: Minor
            Found in src/backend/states/drawCalls/drawCallState.ts - About 1 hr to fix

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

                  private appendBufferCustomData(state: any, buffer: WebGLBuffer) {
                      if (buffer) {
                          // Check for custom data.
                          const customData: IBufferRecorderData = (buffer as any).__SPECTOR_Object_CustomData;
                          if (customData) {
              Severity: Minor
              Found in src/backend/states/drawCalls/drawCallState.ts - 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 readAttributeFromContext has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected readAttributeFromContext(program: WebGLProgram, activeAttributeIndex: number): {} {
                      const info = this.context.getActiveAttrib(program, activeAttributeIndex);
                      const location = this.context.getAttribLocation(program, info.name);
                      if (location === -1) {
                          return {
              Severity: Minor
              Found in src/backend/states/drawCalls/drawCallState.ts - About 1 hr to fix

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

                    protected readUniformsFromContextIntoState(program: WebGLProgram, uniformIndices: number[], uniformsState: any[], uniformBlockState: any[]) {
                        const context2 = this.context as WebGL2RenderingContext;
                
                        const typeValues = context2.getActiveUniforms(program, uniformIndices, WebGlConstants.UNIFORM_TYPE.value);
                        const sizes = context2.getActiveUniforms(program, uniformIndices, WebGlConstants.UNIFORM_SIZE.value);
                Severity: Minor
                Found in src/backend/states/drawCalls/drawCallState.ts - About 1 hr to fix

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

                      protected readTextureFromContext(textureUnit: number, target: WebGlConstant): {} {
                          const activeTexture = this.context.getParameter(WebGlConstants.ACTIVE_TEXTURE.value);
                  
                          this.context.activeTexture(WebGlConstants.TEXTURE0.value + textureUnit);
                          const textureState: any = {
                  Severity: Minor
                  Found in src/backend/states/drawCalls/drawCallState.ts - 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

                  Avoid deeply nested control flow statements.
                  Open

                                          for (let j = 0; j < values.length; j++) {
                                              uniformState.textures.push(this.readTextureFromContext(values[j].value, textureTarget));
                                          }
                  Severity: Major
                  Found in src/backend/states/drawCalls/drawCallState.ts - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (value.length) {
                                                value = Array.prototype.slice.call(value);
                                            }
                    Severity: Major
                    Found in src/backend/states/drawCalls/drawCallState.ts - About 45 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return undefined;
                      Severity: Major
                      Found in src/backend/states/drawCalls/drawCallState.ts - About 30 mins to fix

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

                                for (let i = 0; i < attributes; i++) {
                                    const attributeState = this.readAttributeFromContext(program, i);
                                    this.currentState.attributes.push(attributeState);
                                }
                        Severity: Major
                        Found in src/backend/states/drawCalls/drawCallState.ts and 2 other locations - About 1 hr to fix
                        src/backend/states/drawCalls/drawCallState.ts on lines 112..115
                        src/backend/states/drawCalls/drawCallState.ts on lines 126..129

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

                        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

                                        for (let i = 0; i < transformFeedbacks; i++) {
                                            const transformFeedbackState = this.readTransformFeedbackFromContext(program, i);
                                            this.currentState.transformFeedbacks.push(transformFeedbackState);
                                        }
                        Severity: Major
                        Found in src/backend/states/drawCalls/drawCallState.ts and 2 other locations - About 1 hr to fix
                        src/backend/states/drawCalls/drawCallState.ts on lines 95..98
                        src/backend/states/drawCalls/drawCallState.ts on lines 112..115

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

                        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

                                    for (let i = 0; i < uniformBlocks; i++) {
                                        const uniformBlockState = this.readUniformBlockFromContext(program, i);
                                        this.currentState.uniformBlocks.push(uniformBlockState);
                                    }
                        Severity: Major
                        Found in src/backend/states/drawCalls/drawCallState.ts and 2 other locations - About 1 hr to fix
                        src/backend/states/drawCalls/drawCallState.ts on lines 95..98
                        src/backend/states/drawCalls/drawCallState.ts on lines 126..129

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

                        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

                        There are no issues that match your filters.

                        Category
                        Status