BabylonJS/Spector.js

View on GitHub

Showing 572 of 572 total issues

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

            this.contexts.push({
                canvas: contextSpy.context.canvas as HTMLCanvasElement | OffscreenCanvas,
                contextSpy,
            });
Severity: Minor
Found in src/spector.ts and 1 other location - About 30 mins to fix
src/spector.ts on lines 301..304

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

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

                if (state.VisualState.Attachments.length > 1) {
                    const attachment = document.createElement("span");
                    attachment.innerText = imageState.attachmentName;
                    liHolder.appendChild(attachment);
                }
src/embeddedFrontend/resultView/JSON/jsonVisualStateItemComponent.ts on lines 17..21
src/embeddedFrontend/resultView/visualStateList/visualStateListItemComponent.ts on lines 50..54

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

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

                if (state.Attachments.length > 1) {
                    const attachment = document.createElement("span");
                    attachment.innerText = imageState.attachmentName;
                    divHolder.appendChild(attachment);
                }
src/embeddedFrontend/resultView/visualStateList/visualStateListItemComponent.ts on lines 40..44
src/embeddedFrontend/resultView/visualStateList/visualStateListItemComponent.ts on lines 50..54

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

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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public render(state: IResultViewMenuState, stateId: number): Element {

        const htmlString = this.htmlTemplate`<ul class="resultViewMenuComponent">
                <li class="resultViewMenuOpen resultViewMenuSmall"><a href="#" role="button">Menu</a></li>

Severity: Minor
Found in src/embeddedFrontend/resultView/menu/resultViewMenuComponent.ts - 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 scrollIntoView has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static scrollIntoView(element: HTMLElement): void {
        const elementRect = element.getBoundingClientRect();

        let parentElement = element.parentElement;
        while (parentElement) {
Severity: Minor
Found in src/embeddedFrontend/ux/scrollIntoViewHelper.ts - 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 showError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public showError(errorMessage: string) {
        if (!this.editor) {
            return;
        }

Severity: Minor
Found in src/embeddedFrontend/resultView/sourceCode/sourceCodeComponent.ts - 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 isValidChangeCommand has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected isValidChangeCommand(command: ICommandCapture, stateName: string): boolean {
        if (command.name === "enable" || command.name === "disable") {
            return command.commandArguments[0] === WebGlConstants.STENCIL_TEST.value;
        }
        if (command.name === "stencilOp" || command.name === "stencilOpSeparate") {
Severity: Minor
Found in src/backend/states/context/stencilState.ts - 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 stringifyArgs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected stringifyArgs(args: IArguments): string[] {
        const stringified = [];
        for (let i = 0; i < args.length; i++) {
            const arg = args[i];

Severity: Minor
Found in src/backend/commands/bufferSubData.ts - 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 isValidChangeCommand has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected isValidChangeCommand(command: ICommandCapture, stateName: string): boolean {
        if (command.name === "enable" || command.name === "disable") {
            if (command.commandArguments[0] === WebGlConstants.SAMPLE_COVERAGE.value) {
                return stateName === WebGlConstants.SAMPLE_COVERAGE.name;
            }
Severity: Minor
Found in src/backend/states/context/coverageState.ts - 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 getCommandNameToStates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private getCommandNameToStates(): { [key: string]: string[] } {
        const result: { [key: string]: string[] } = {};
        for (const stateName in this.changeCommandsByState) {
            if (this.changeCommandsByState.hasOwnProperty(stateName)) {
                for (const changeCommand of this.changeCommandsByState[stateName]) {
Severity: Minor
Found in src/backend/states/baseState.ts - 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 getUboValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public getUboValue(bindingPoint: number, offset: number, size: number, type: number): any {
        const uboType = DrawCallUboInputState.uboTypes[type];
        if (!uboType) {
            return undefined;
        }
Severity: Minor
Found in src/backend/states/drawCalls/drawCallUboInputState.ts - 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 merge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function merge<T, U>(first: T, second: U): T & U {
    const result: any = {};
    for (const id in first) {
        if (first.hasOwnProperty(id)) {
            result[id] = first[id];
Severity: Minor
Found in src/shared/utils/merge.ts - 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