Strilanc/Quirk

View on GitHub
src/circuit/Gate.js

Summary

Maintainability
F
3 days
Test Coverage

File Gate.js has 478 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/Gate.js - About 7 hrs to fix

    GateBuilder has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class GateBuilder {
        constructor() {
            this.gate = new Gate();
        }
    
    
    Severity: Minor
    Found in src/circuit/Gate.js - About 6 hrs to fix

      Function _copy has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _copy() {
              let g = new Gate();
              g.symbol = this.symbol;
              g.name = this.name;
              g.blurb = this.blurb;
      Severity: Minor
      Found in src/circuit/Gate.js - About 1 hr to fix

        Function constructor has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            constructor() {
                /** @type {!string} The text shown when drawing the gate. */
                this.symbol = '';
                /** @type {!string} The identifier text used for the gate when serializing/parsing JSON. */
                this.serializedId = '';
        Severity: Minor
        Found in src/circuit/Gate.js - About 1 hr to fix

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

              static buildFamily(minSize, maxSize, gateBuildFunc) {
                  let gates = [];
                  for (let span = minSize; span <= maxSize; span++) {
                      let builder = new GateBuilder();
                      builder.setHeight(span);
          Severity: Minor
          Found in src/circuit/Gate.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

              promiseEffectOnlyPermutesAndPhases() {
                  this.gate._hasNoEffect = false;
                  this.gate._effectPermutesStates = true;
                  this.gate._effectCreatesSuperpositions = false;
                  this.gate._isDefinitelyUnitary = true;
          Severity: Major
          Found in src/circuit/Gate.js and 1 other location - About 2 hrs to fix
          src/circuit/Gate.js on lines 826..832

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

          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

              promiseEffectOnlyPhases() {
                  this.gate._hasNoEffect = false;
                  this.gate._effectPermutesStates = false;
                  this.gate._effectCreatesSuperpositions = false;
                  this.gate._isDefinitelyUnitary = true;
          Severity: Major
          Found in src/circuit/Gate.js and 1 other location - About 2 hrs to fix
          src/circuit/Gate.js on lines 801..807

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

          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

              effectMightCreateSuperpositions() {
                  return this._effectCreatesSuperpositions !== undefined ? this._effectCreatesSuperpositions :
                      this._knownMatrix !== undefined ? !this._knownMatrix.isPhasedPermutation() :
                      true;
              }
          Severity: Major
          Found in src/circuit/Gate.js and 1 other location - About 1 hr to fix
          src/circuit/Gate.js on lines 442..446

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

          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

              effectMightPermutesStates() {
                  return this._effectPermutesStates !== undefined ? this._effectPermutesStates :
                      this._knownMatrix !== undefined ? !this._knownMatrix.isDiagonal() :
                      true;
              }
          Severity: Major
          Found in src/circuit/Gate.js and 1 other location - About 1 hr to fix
          src/circuit/Gate.js on lines 451..455

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

          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

              canDecreaseInSize() {
                  return !this.gateFamily.every(e => e.height !== this.height - 1);
              }
          Severity: Minor
          Found in src/circuit/Gate.js and 1 other location - About 40 mins to fix
          src/circuit/Gate.js on lines 397..399

          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

              canIncreaseInSize() {
                  return !this.gateFamily.every(e => e.height !== this.height + 1);
              }
          Severity: Minor
          Found in src/circuit/Gate.js and 1 other location - About 40 mins to fix
          src/circuit/Gate.js on lines 404..406

          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

              setContextProvider(customColumnContextProvider) {
                  this.gate.customColumnContextProvider = customColumnContextProvider;
                  this.gate.isContextTemporary = true;
                  return this;
              }
          Severity: Minor
          Found in src/circuit/Gate.js and 1 other location - About 35 mins to fix
          src/circuit/Gate.js on lines 949..953

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

              setStickyContextProvider(customColumnContextProvider) {
                  this.gate.customColumnContextProvider = customColumnContextProvider;
                  this.gate.isContextTemporary = false;
                  return this;
              }
          Severity: Minor
          Found in src/circuit/Gate.js and 1 other location - About 35 mins to fix
          src/circuit/Gate.js on lines 938..942

          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