Strilanc/Quirk

View on GitHub

Showing 478 of 478 total issues

Avoid too many return statements within this function.
Open

        return undefined;
Severity: Major
Found in src/gates/SwapGateHalf.js - About 30 mins to fix

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

    Controls.YControl = new GateBuilder().
        setAlternate(Controls.YAntiControl).
        setSerializedId("(/)").  // The drawn cross/slash convention was changed, but the serialized id must stay the same.
        setSymbol("⊗").
        setTitle("Y-Axis Control").
    Severity: Minor
    Found in src/gates/Controls.js and 1 other location - About 30 mins to fix
    src/gates/Controls.js on lines 116..125

    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

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

    Controls.YAntiControl = new GateBuilder().
        setSerializedId("⊗").  // The drawn cross/slash convention was changed, but the serialized id must stay the same.
        setSymbol("(/)").
        setTitle("Y-Axis Anti-Control").
        setBlurb("Conditions on a qubit being ON+iOFF.\n" +
    Severity: Minor
    Found in src/gates/Controls.js and 1 other location - About 30 mins to fix
    src/gates/Controls.js on lines 145..155

    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

    Avoid too many return statements within this function.
    Open

            return value.toFixed(digits);
    Severity: Major
    Found in src/base/Format.js - About 30 mins to fix

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

          plus(p) {
              return new Point(this.x + p.x, this.y + p.y);
          }
      Severity: Minor
      Found in src/math/Point.js and 1 other location - About 30 mins to fix
      src/math/Point.js on lines 84..86

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

          withTop(newTop) {
              return new DisplayedToolbox(
                  this.name,
                  newTop,
                  this.toolboxGroups,
      Severity: Minor
      Found in src/ui/DisplayedToolbox.js and 1 other location - About 30 mins to fix
      src/circuit/CircuitStats.js on lines 199..207

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

          withTime(time) {
              return new CircuitStats(
                  this.circuitDefinition,
                  time,
                  this._survivalRates,
      Severity: Minor
      Found in src/circuit/CircuitStats.js and 1 other location - About 30 mins to fix
      src/ui/DisplayedToolbox.js on lines 182..190

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

              if (couldBeBinary && token.binary_action === undefined && token !== ")") {
                  burnOps(mul.priority);
                  ops.push({f: mul.binary_action, w: mul.priority});
              }
      Severity: Minor
      Found in src/math/FormulaParser.js and 1 other location - About 30 mins to fix
      src/math/FormulaParser.js on lines 157..166

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

              if (couldBeBinary && token.binary_action !== undefined) {
                  burnOps(token.priority);
                  ops.push({f: token.binary_action, w: token.priority});
              } else if (token.unary_action !== undefined) {
                  burnOps(token.priority);
      Severity: Minor
      Found in src/math/FormulaParser.js and 1 other location - About 30 mins to fix
      src/math/FormulaParser.js on lines 152..155

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

          minus(p) {
              return new Point(this.x - p.x, this.y - p.y);
          }
      Severity: Minor
      Found in src/math/Point.js and 1 other location - About 30 mins to fix
      src/math/Point.js on lines 75..77

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

          static _paintGateTooltip_matrix(painter, gate, matrix, pad, dispSize, w, pushRect, nextY) {
              if (matrix === undefined) {
                  return;
              }
      
      
      Severity: Minor
      Found in src/draw/WidgetPainter.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 _shiftAndSpliceColumn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          _shiftAndSpliceColumn(rowShift, gatesOfCol, insertCol, isInsert) {
              // Move gates upward.
              while (rowShift < 0 && gatesOfCol[0] === undefined) {
                  gatesOfCol.shift();
                  gatesOfCol.push(undefined);
      Severity: Minor
      Found in src/ui/DisplayedCircuit.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 _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

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

          previewDrop(hand) {
              return hand.heldRow !== undefined ? this._previewDropMovedRow(hand) :
                  hand.heldColumn !== undefined ? this._previewDropMovedGateColumn(hand) :
                  hand.heldGate !== undefined ? this._previewDropMovedGate(hand) :
                  this._previewResizedGate(hand);
      Severity: Minor
      Found in src/ui/DisplayedCircuit.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 GATE_CIRCUIT_DRAWER has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      let GATE_CIRCUIT_DRAWER = args => {
          let circuit = args.gate.knownCircuit;
          if (circuit === undefined || args.gate.symbol !== '') {
              if (args.gate.stableDuration() === Infinity) {
                  GatePainting.DEFAULT_DRAWER(args);
      Severity: Minor
      Found in src/ui/DisplayedCircuit.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 describe_Object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function describe_Object(value, limit) {
          let entries = [];
          for (let k in value) {
              if (!value.hasOwnProperty(k)) {
                  continue;
      Severity: Minor
      Found in src/base/Describe.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 _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 isEqualTo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          isEqualTo(other, comparator = (e1, e2) => e1 === e2) {
              if (!isIterable(other)) {
                  return false;
              }
              if (other === this) {
      Severity: Minor
      Found in src/base/Seq.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 mergedReadFloats has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      KetTextureUtil.mergedReadFloats = textures => {
          let len = tex => tex.width === 0 ? 0 : 1 << currentShaderCoder().vec4.arrayPowerSizeOfTexture(tex);
          let totalPowerSize = Math.round(Math.log2(Util.ceilingPowerOf2(
              seq(textures).map(len).sum())));
      
      
      Severity: Minor
      Found in src/circuit/KetTextureUtil.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 superpositionToQubitDensities has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      KetTextureUtil.superpositionToQubitDensities = (stateTex, controls, keptBitMask) => {
          if (keptBitMask === 0) {
              return new WglTexture(0, 0, currentShaderCoder().vec4.pixelType);
          }
          let hasControls = !controls.isEqualTo(Controls.NONE);
      Severity: Minor
      Found in src/circuit/KetTextureUtil.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

      Severity
      Category
      Status
      Source
      Language