Strilanc/Quirk

View on GitHub
src/circuit/GateColumn.js

Summary

Maintainability
D
2 days
Test Coverage

File GateColumn.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Copyright 2017 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
Severity: Minor
Found in src/circuit/GateColumn.js - About 3 hrs to fix

    GateColumn has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class GateColumn {
        /**
         * A column of gates in a circuit with many qubits.
         *
         * @param {!Array.<undefined|!Gate>} gates The list of gates to apply to each wire, with the i'th gate applying to
    Severity: Minor
    Found in src/circuit/GateColumn.js - About 3 hrs to fix

      Function _disabledReason_remixing has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          _disabledReason_remixing(row, inputMeasureMask) {
              // Measured qubits can't be re-superposed for implementation simplicity reasons.
              let g = this.gates[row];
              let mask = ((1 << g.height) - 1) << row;
              let maskMeasured = mask & inputMeasureMask;
      Severity: Minor
      Found in src/circuit/GateColumn.js - 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 _disabledReason_remixing has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _disabledReason_remixing(row, inputMeasureMask) {
              // Measured qubits can't be re-superposed for implementation simplicity reasons.
              let g = this.gates[row];
              let mask = ((1 << g.height) - 1) << row;
              let maskMeasured = mask & inputMeasureMask;
      Severity: Minor
      Found in src/circuit/GateColumn.js - About 1 hr to fix

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

            perRowDisabledReasons(inputMeasureMask, outerRowOffset, outerContext, prevStickyCtx, isNested) {
                let context = Util.mergeMaps(outerContext, prevStickyCtx);
                let stickyCtx = new Map(prevStickyCtx);
                for (let row = this.gates.length - 1; row >= 0; row--) {
                    let g = this.gates[row];
        Severity: Minor
        Found in src/circuit/GateColumn.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 _disabledReason_overlappingTags has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            _disabledReason_overlappingTags(outerRow, row) {
                let keys = new Set(
                    this.gates[row].customColumnContextProvider(outerRow + row, this.gates[row]).map(e => e.key));
                if (keys.length === 0) {
                    return undefined;
        Severity: Minor
        Found in src/circuit/GateColumn.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 _disabledReason_inputs_coherenceMismatch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            static _disabledReason_inputs_coherenceMismatch(args, rangeVals) {
                let row = args.outerRow;
                if (args.gate.effectMightPermutesStates()) {
                    let hasMeasuredOutputs = ((args.measuredMask >> row) & ((1 << args.gate.height) - 1)) !== 0;
                    if (hasMeasuredOutputs) {
        Severity: Minor
        Found in src/circuit/GateColumn.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 _updateMeasureMask_gateStep has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            _updateMeasureMask_gateStep(state, row, disabledReasons) {
                if (disabledReasons[row] !== undefined) {
                    return;
                }
        
        
        Severity: Minor
        Found in src/circuit/GateColumn.js - 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

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

                        for (let {key, val} of g.customColumnContextProvider(row + outerRowOffset, g)) {
                            //noinspection JSUnusedAssignment
                            context.set(key, val);
                            if (!g.isContextTemporary) {
                                stickyCtx.set(key, val);
        Severity: Major
        Found in src/circuit/GateColumn.js and 1 other location - About 2 hrs to fix
        src/circuit/CircuitDefinition.js on lines 693..699

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

        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 2 locations. Consider refactoring.
        Open

                    if ((inputMeasureMask & (1 << i)) === 0 &&
                            this.gates[i] !== undefined &&
                            this.gates[i].isControl() &&
                            !this.gates[i].isClassicalControl()) {
        Severity: Minor
        Found in src/circuit/GateColumn.js and 1 other location - About 40 mins to fix
        src/circuit/GateColumn.js on lines 106..109

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

        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 2 locations. Consider refactoring.
        Open

                    if ((inputMeasureMask & (1 << i)) !== 0 &&
                            this.gates[i] !== undefined &&
                            this.gates[i].definitelyHasNoEffect() &&
                            this.gates[i].isControl()) {
        Severity: Minor
        Found in src/circuit/GateColumn.js and 1 other location - About 40 mins to fix
        src/circuit/GateColumn.js on lines 90..93

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

        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