Strilanc/Quirk

View on GitHub

Showing 241 of 478 total issues

Function AMPLITUDE_DRAWER_FROM_CUSTOM_STATS has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AMPLITUDE_DRAWER_FROM_CUSTOM_STATS = GatePainting.makeDisplayDrawer(args => {
    let n = args.gate.height;
    let {quality, ket, phaseLockIndex, incoherentKet} = args.customStats || {
        ket: (n === 1 ? Matrix.zero(2, 1) : Matrix.zero(1 << Math.floor(n / 2), 1 << Math.ceil(n / 2))).times(NaN),
        quality: 1,
Severity: Major
Found in src/gates/AmplitudeDisplay.js - About 2 hrs to fix

    Function paintMatrix has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        static paintMatrix(painter,
                           matrix,
                           drawArea,
                           amplitudeCircleFillColor,
                           amplitudeCircleStrokeColor,
    Severity: Minor
    Found in src/draw/MathPainter.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 redrawControlWires has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    function redrawControlWires(args) {
        if (args.positionInCircuit === undefined || args.isHighlighted) {
            return;
        }
        let painter = args.painter;
    Severity: Minor
    Found in src/gates/Detector.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

    File Controls.js has 258 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/gates/Controls.js - About 2 hrs to fix

      Painter has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Painter {
          /**
           * @param {!HTMLCanvasElement} canvas
           * @param {!RestartableRng=} rng
           */
      Severity: Minor
      Found in src/draw/Painter.js - About 2 hrs to fix

        Function _drawWires has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _drawWires(painter, showLabels, hand) {
                let drawnWireCount = Math.min(this.circuitDefinition.numWires, (this._extraWireStartIndex || Infinity) + 1);
        
                // Initial value labels
                if (showLabels) {
        Severity: Major
        Found in src/ui/DisplayedCircuit.js - About 2 hrs to fix

          Function paintGateSymbol has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          GatePainting.paintGateSymbol = (args, symbolOverride=undefined, allowExponent=true) => {
              let painter = args.painter;
              let rect = args.rect.paddedBy(-2);
              if (symbolOverride === undefined) {
                  symbolOverride = args.gate.symbol;
          Severity: Minor
          Found in src/draw/GatePainting.js - About 1 hr to fix

            Function initUrlCircuitSync has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function initUrlCircuitSync(revision) {
                // Pull initial circuit out of URL '#x=y' arguments.
                const getHashParameters = () => {
                    let hashText = document.location.hash.substr(1);
                    let paramsMap = new Map();
            Severity: Minor
            Found in src/ui/url.js - About 1 hr to fix

              Function paintBlochSphereRotation has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  static paintBlochSphereRotation(painter,
                                                  operation,
                                                  drawArea,
                                                  backgroundColor = Config.DISPLAY_GATE_BACK_COLOR,
                                                  fillColor = Config.DISPLAY_GATE_FORE_COLOR) {
              Severity: Minor
              Found in src/draw/MathPainter.js - About 1 hr to fix

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

                    _drawWires(painter, showLabels, hand) {
                        let drawnWireCount = Math.min(this.circuitDefinition.numWires, (this._extraWireStartIndex || Infinity) + 1);
                
                        // Initial value labels
                        if (showLabels) {
                Severity: Minor
                Found in src/ui/DisplayedCircuit.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 _drawHintLabels has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _drawHintLabels(painter, stats) {
                        let gridRect = this._rectForSuperpositionDisplay();
                
                        // Amplitude hint.
                        painter.print(
                Severity: Minor
                Found in src/ui/DisplayedCircuit.js - About 1 hr to fix

                  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 amplitudeDisplayStatTextures has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function amplitudeDisplayStatTextures(stateKet, controls, controlsTexture, rangeOffset, rangeLength) {
                        let incoherentKet = probabilityStatTexture(stateKet, controlsTexture, rangeOffset, rangeLength);
                    
                        let trader = new WglTextureTrader(stateKet);
                        trader.dontDeallocCurrentTexture();
                    Severity: Minor
                    Found in src/gates/AmplitudeDisplay.js - About 1 hr to fix

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

                          static _fromCircuitAtTime_noFallback(circuitDefinition, time) {
                              circuitDefinition = circuitDefinition.withMinimumWireCount();
                              const numWires = circuitDefinition.numWires;
                      
                              // Advance state while collecting stats into textures.
                      Severity: Minor
                      Found in src/circuit/CircuitStats.js - About 1 hr 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 processOutputs has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function processOutputs(span, pixelGroups, circuitDefinition) {
                              let [ketPixels, qualityPixels, rawIncoherentKetPixels] = pixelGroups;
                              let denormalizedQuality = qualityPixels[0];
                              let n = 1 << span;
                              let w = n === 2 ? 2 : 1 << Math.floor(Math.round(Math.log2(n))/2);
                          Severity: Minor
                          Found in src/gates/AmplitudeDisplay.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 paintDensityMatrix has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                                static paintDensityMatrix(painter,
                                                          matrix,
                                                          drawArea,
                                                          focusPoints = [],
                                                          backgroundColor = Config.DISPLAY_GATE_BACK_COLOR,
                            Severity: Minor
                            Found in src/draw/MathPainter.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

                            Severity
                            Category
                            Status
                            Source
                            Language