Strilanc/Quirk

View on GitHub
src/circuit/CircuitDefinition.js

Summary

Maintainability
F
6 days
Test Coverage

File CircuitDefinition.js has 738 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: Major
Found in src/circuit/CircuitDefinition.js - About 1 day to fix

    CircuitDefinition has 59 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CircuitDefinition {
        /**
         * @param {!int} numWires
         * @param {!Array.<!GateColumn>} columns
         * @param {undefined|!int=} outerRowOffset
    Severity: Major
    Found in src/circuit/CircuitDefinition.js - About 1 day to fix

      Function _computeGateSlotCoverMap has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          _computeGateSlotCoverMap() {
              let result = new Map();
              for (let col = 0; col < this.columns.length; col++) {
                  for (let row = 0; row < this.numWires; row++) {
                      let gate = this.columns[col].gates[row];
      Severity: Minor
      Found in src/circuit/CircuitDefinition.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 getUnmetContextKeys has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          getUnmetContextKeys() {
              let result = new Set();
              for (let c = 0; c < this.columns.length; c++) {
                  let col = this.columns[c];
                  let ctx = this.colCustomContextFromGates(c, 0);
      Severity: Minor
      Found in src/circuit/CircuitDefinition.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 constructor has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          constructor(numWires,
                      columns,
                      outerRowOffset=0,
                      outerContext=new Map(),
                      customGateSet=new CustomGateSet(),
      Severity: Minor
      Found in src/circuit/CircuitDefinition.js - About 1 hr to fix

        Function colControls has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            colControls(col) {
                if (col < 0 || col >= this.columns.length) {
                    return Controls.NONE;
                }
                let column = this.columns[col];
        Severity: Minor
        Found in src/circuit/CircuitDefinition.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 _uncached_customContextFromGates has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            _uncached_customContextFromGates(outerRowOffset) {
                let results = [];
                let stickyCtx = new Map();
                for (let col = 0; col < this.columns.length; col++) {
                    let ctx = new Map(stickyCtx);
        Severity: Minor
        Found in src/circuit/CircuitDefinition.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 withHeightOverlapsFixed has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            withHeightOverlapsFixed(recurseLimit=5) {
                let newCols = [];
                for (let col = 0; col < this.columns.length; col++) {
                    let pushedGateIndexes = this._findHeightWiseOverlapsInCol(col);
                    if (pushedGateIndexes.size === 0) {
        Severity: Minor
        Found in src/circuit/CircuitDefinition.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 fromTextDiagram has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static fromTextDiagram(gateMap, diagram) {
                let lines = seq(diagram.split('\n')).map(e => e.trim()).filter(e => e !== '').toArray();
                if (seq(lines.map(e => e.length)).distinct().count() > 1) {
                    throw new DetailedError("Uneven diagram", {diagram});
                }
        Severity: Minor
        Found in src/circuit/CircuitDefinition.js - About 1 hr to fix

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

              constructor(numWires,
                          columns,
                          outerRowOffset=0,
                          outerContext=new Map(),
                          customGateSet=new CustomGateSet(),
          Severity: Minor
          Found in src/circuit/CircuitDefinition.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 countGatesUpTo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              countGatesUpTo(max) {
                  let n = 0;
                  for (let c of this.columns) {
                      for (let g of c.gates) {
                          if (g !== undefined) {
          Severity: Minor
          Found in src/circuit/CircuitDefinition.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 controlLinesRanges has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              controlLinesRanges(columnIndex) {
                  let col = this.columns[columnIndex];
                  let n = col.gates.length;
          
                  let swapRows = this.colGetEnabledSwapGate(columnIndex);
          Severity: Minor
          Found in src/circuit/CircuitDefinition.js - About 1 hr to fix

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

                colControls(col) {
                    if (col < 0 || col >= this.columns.length) {
                        return Controls.NONE;
                    }
                    let column = this.columns[col];
            Severity: Minor
            Found in src/circuit/CircuitDefinition.js - About 1 hr to fix

              Function withWidthOverlapsFixed has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  withWidthOverlapsFixed() {
                      let newCols = [];
                      for (let col = 0; col < this.columns.length; col++) {
                          let paddingRequired = Seq.range(this.numWires).map(row => {
                              let gate = this.columns[col].gates[row];
              Severity: Minor
              Found in src/circuit/CircuitDefinition.js - About 55 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 colGetEnabledSwapGate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  colGetEnabledSwapGate(col) {
                      if (col < 0 || col >= this.columns.length) {
                          return undefined;
                      }
                      let locs = [];
              Severity: Minor
              Found in src/circuit/CircuitDefinition.js - About 55 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 < gate.height; j++) {
                                          result.set((col+i)+":"+(row+j), {col, row, gate});
                                      }
              Severity: Major
              Found in src/circuit/CircuitDefinition.js - About 45 mins to fix

                Function fromTextDiagram has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    static fromTextDiagram(gateMap, diagram) {
                        let lines = seq(diagram.split('\n')).map(e => e.trim()).filter(e => e !== '').toArray();
                        if (seq(lines.map(e => e.length)).distinct().count() > 1) {
                            throw new DetailedError("Uneven diagram", {diagram});
                        }
                Severity: Minor
                Found in src/circuit/CircuitDefinition.js - About 35 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 _findWidthWiseOverlapInRect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    _findWidthWiseOverlapInRect(col, row, width, height) {
                        for (let i = 1; i < width && col + i < this.columns.length; i++) {
                            for (let j = 0; j < height; j++) {
                                let otherGate = this.findGateCoveringSlot(col+i, row+j);
                                if (otherGate === undefined || otherGate.col === col) {
                Severity: Minor
                Found in src/circuit/CircuitDefinition.js - About 35 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 _findHeightWiseOverlapsInCol has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    _findHeightWiseOverlapsInCol(col) {
                        let pushedGates = new Set();
                        let h = 0;
                        for (let row = 0; row < this.numWires; row++) {
                            h -= 1;
                Severity: Minor
                Found in src/circuit/CircuitDefinition.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

                Function _applyOpsInCol has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    _applyOpsInCol(colIndex, ctx, opGetter) {
                        if (colIndex < 0 || colIndex >= this.columns.length) {
                            return;
                        }
                        let col = this.columns[colIndex];
                Severity: Minor
                Found in src/circuit/CircuitDefinition.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

                Function firstLastMatchInRange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function firstLastMatchInRange(rangeLen, predicate){
                    let first = undefined;
                    let last = undefined;
                    for (let i = 0; i < rangeLen; i++) {
                        if (predicate(i)) {
                Severity: Minor
                Found in src/circuit/CircuitDefinition.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(outerRowOffset + row, g)) {
                                    //noinspection JSUnusedAssignment
                                    ctx.set(key, val);
                                    if (!g.isContextTemporary) {
                                        stickyCtx.set(key, val);
                Severity: Major
                Found in src/circuit/CircuitDefinition.js and 1 other location - About 2 hrs to fix
                src/circuit/GateColumn.js on lines 386..392

                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

                    colHasDoubleWireControl(col) {
                        if (col < 0 || col >= this.columns.length) {
                            return false;
                        }
                        return this.columns[col].hasMeasuredControl(this._measureMasks[col]);
                Severity: Major
                Found in src/circuit/CircuitDefinition.js and 1 other location - About 1 hr to fix
                src/circuit/CircuitDefinition.js on lines 858..863

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

                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

                    colHasSingleWireControl(col) {
                        if (col < 0 || col >= this.columns.length) {
                            return false;
                        }
                        return this.columns[col].hasCoherentControl(this._measureMasks[col]);
                Severity: Major
                Found in src/circuit/CircuitDefinition.js and 1 other location - About 1 hr to fix
                src/circuit/CircuitDefinition.js on lines 869..874

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

                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

                    locStartsDoubleControlWire(pt) {
                        return this.locIsControlWireStarter(pt) &&
                            this.locClassifyMeasuredIncludingGateExtension(pt) !== false &&
                            this.gateAtLocIsDisabledReason(pt.x, pt.y) === undefined;
                    }
                Severity: Major
                Found in src/circuit/CircuitDefinition.js and 1 other location - About 1 hr to fix
                src/circuit/CircuitDefinition.js on lines 775..779

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

                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

                    locStartsSingleControlWire(pt) {
                        return this.locIsControlWireStarter(pt) &&
                            this.locClassifyMeasuredIncludingGateExtension(pt) !== true &&
                            this.gateAtLocIsDisabledReason(pt.x, pt.y) === undefined;
                    }
                Severity: Major
                Found in src/circuit/CircuitDefinition.js and 1 other location - About 1 hr to fix
                src/circuit/CircuitDefinition.js on lines 785..789

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

                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

                    locIsControlWireStarter(pt) {
                        let gate = this.gateInSlot(pt.x, pt.y);
                        return gate !== undefined && gate.isControlWireSource;
                    }
                Severity: Minor
                Found in src/circuit/CircuitDefinition.js and 1 other location - About 50 mins to fix
                src/circuit/CircuitDefinition.js on lines 838..841

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

                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

                    locHasControllableGate(pt) {
                        let g = this.gateInSlot(pt.x, pt.y);
                        return g !== undefined && g.interestedInControls;
                    }
                Severity: Minor
                Found in src/circuit/CircuitDefinition.js and 1 other location - About 50 mins to fix
                src/circuit/CircuitDefinition.js on lines 766..769

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

                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

                        let allGates = seq(this.columns)
                            .flatMap(e => e.gates)
                            .filter(e => e !== undefined)
                            .map(e => e.symbol)
                Severity: Minor
                Found in src/circuit/CircuitDefinition.js and 2 other locations - About 35 mins to fix
                src/circuit/CircuitDefinition.js on lines 131..134
                src/circuit/CircuitDefinition.js on lines 371..374

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

                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

                        return seq(this.columns).
                            flatMap(e => e.gates).
                            filter(e => e !== undefined).
                            map(e => e.knownCircuit === undefined ? 1 : e.knownCircuit.gateWeight()).
                Severity: Minor
                Found in src/circuit/CircuitDefinition.js and 2 other locations - About 35 mins to fix
                src/circuit/CircuitDefinition.js on lines 371..374
                src/circuit/CircuitDefinition.js on lines 387..390

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

                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

                        return seq(this.columns).
                            flatMap(c => c.gates).
                            filter(g => g !== undefined).
                            map(g => g.stableDuration()).
                Severity: Minor
                Found in src/circuit/CircuitDefinition.js and 2 other locations - About 35 mins to fix
                src/circuit/CircuitDefinition.js on lines 131..134
                src/circuit/CircuitDefinition.js on lines 387..390

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

                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