Strilanc/Quirk

View on GitHub

Showing 478 of 478 total issues

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

PARSE_COMPLEX_TOKEN_MAP_DEG.set("asin", {
    unary_action: e => {
        if (Complex.imagPartOf(e) !== 0) {
            throw new DetailedError("asin input out of range", {e});
        }
Severity: Major
Found in src/math/Complex.js and 1 other location - About 3 hrs to fix
src/math/Complex.js on lines 462..469

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

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

PARSE_COMPLEX_TOKEN_MAP_DEG.set("acos", {
    unary_action: e => {
        if (Complex.imagPartOf(e) !== 0) {
            throw new DetailedError("acos input out of range", {e});
        }
Severity: Major
Found in src/math/Complex.js and 1 other location - About 3 hrs to fix
src/math/Complex.js on lines 454..461

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

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

File Serializer.js has 300 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/Serializer.js - About 3 hrs to fix

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

    ComparisonGates.ALessThanOrEqualToB = new GateBuilder().
        setSerializedId("^A<=B").
        setSymbol("⊕A≤B").
        setTitle("At-Most Gate").
        setBlurb("Toggles a qubit if input A is at most input B.").
    Severity: Major
    Found in src/gates/ComparisonGates.js and 2 other locations - About 3 hrs to fix
    src/gates/ComparisonGates.js on lines 41..49
    src/gates/ComparisonGates.js on lines 83..91

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

    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

    ComparisonGates.ALessThanB = new GateBuilder().
        setSerializedId("^A<B").
        setSymbol("⊕A<B").
        setTitle("Less-Than Gate").
        setBlurb("Toggles a qubit if input A is less than input B.").
    Severity: Major
    Found in src/gates/ComparisonGates.js and 2 other locations - About 3 hrs to fix
    src/gates/ComparisonGates.js on lines 51..59
    src/gates/ComparisonGates.js on lines 83..91

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

    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

    ExponentiatingGates.XBackward = new GateBuilder().
        setAlternate(ExponentiatingGates.XForward).
        setSerializedIdAndSymbol("e^iXt").
        setTitle("X-Exponentiating Gate (backward)").
        setBlurb("Left-hand rotation around the X axis.\nPasses through ±iX instead of X.").
    Severity: Major
    Found in src/gates/ExponentiatingGates.js and 1 other location - About 3 hrs to fix
    src/gates/ExponentiatingGates.js on lines 68..76

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

    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

    ComparisonGates.AEqualToB = new GateBuilder().
        setSerializedId("^A=B").
        setSymbol("⊕A=B").
        setTitle("Equality Gate").
        setBlurb("Toggles a qubit if input A is equal to input B.").
    Severity: Major
    Found in src/gates/ComparisonGates.js and 2 other locations - About 3 hrs to fix
    src/gates/ComparisonGates.js on lines 41..49
    src/gates/ComparisonGates.js on lines 51..59

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

    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

    ExponentiatingGates.YBackward = new GateBuilder().
        setAlternate(ExponentiatingGates.YForward).
        setSerializedIdAndSymbol("e^iYt").
        setTitle("Y-Exponentiating Gate (backward)").
        setBlurb("Left-hand rotation around the Y axis.\nPasses through ±iY instead of Y.").
    Severity: Major
    Found in src/gates/ExponentiatingGates.js and 1 other location - About 3 hrs to fix
    src/gates/ExponentiatingGates.js on lines 49..57

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

    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

    File Complex.js has 299 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/math/Complex.js - About 3 hrs to fix

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

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

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

        PoweringGates.XBackward = new GateBuilder().
            setAlternate(PoweringGates.XForward).
            setSerializedIdAndSymbol("X^-t").
            setTitle("X-Raising Gate (backward)").
            setBlurb("Left-handed cycle from no-op to X.").
        Severity: Major
        Found in src/gates/PoweringGates.js and 1 other location - About 3 hrs to fix
        src/gates/PoweringGates.js on lines 68..76

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

        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

        MultiplyAccumulateGates.Legacy_MultiplyAddFamily = Gate.buildFamily(3, 16, (span, builder) => builder.
            setSerializedId("c+=ab" + span).
            setSymbol("c+=ab").
            setTitle("Multiply-Add Gate").
            setBlurb("Adds the product of two numbers into a third.").
        Severity: Major
        Found in src/gates/MultiplyAccumulateGates.js and 1 other location - About 3 hrs to fix
        src/gates/MultiplyAccumulateGates.js on lines 89..104

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

        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

        PoweringGates.YBackward = new GateBuilder().
            setAlternate(PoweringGates.YForward).
            setSerializedIdAndSymbol("Y^-t").
            setTitle("Y-Raising Gate (backward)").
            setBlurb("Left-handed cycle from no-op to Y.").
        Severity: Major
        Found in src/gates/PoweringGates.js and 1 other location - About 3 hrs to fix
        src/gates/PoweringGates.js on lines 49..57

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

        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

        MultiplyAccumulateGates.Legacy_MultiplySubtractFamily = Gate.buildFamily(3, 16, (span, builder) => builder.
            setAlternateFromFamily(MultiplyAccumulateGates.Legacy_MultiplyAddFamily).
            setSerializedId("c-=ab" + span).
            setSymbol("c-=ab").
            setTitle("Multiply-Subtract Gate").
        Severity: Major
        Found in src/gates/MultiplyAccumulateGates.js and 1 other location - About 3 hrs to fix
        src/gates/MultiplyAccumulateGates.js on lines 72..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 98.

        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

        File menu.js has 296 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/ui/menu.js - About 3 hrs to fix

          Function paintDensityMatrix has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static paintDensityMatrix(painter,
                                        matrix,
                                        drawArea,
                                        focusPoints = [],
                                        backgroundColor = Config.DISPLAY_GATE_BACK_COLOR,
          Severity: Major
          Found in src/draw/MathPainter.js - About 3 hrs to fix

            Function parseFormula has 74 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function parseFormula(text, tokenMap) {
                let tokens = _tokenize(text).map(e => _translate_token(e, tokenMap));
            
                // Cut off trailing operation, so parse fails less often as users are typing.
                if (tokens.length > 0 && tokens[tokens.length - 1].priority !== undefined) {
            Severity: Major
            Found in src/math/FormulaParser.js - About 2 hrs to fix

              File AmplitudeDisplay.js has 289 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/AmplitudeDisplay.js - About 2 hrs to fix

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

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

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                            if (measured) {
                                painter.strokeLine(new Point(x+1, y1), new Point(x+1, y2));
                                painter.strokeLine(new Point(x-1, y1), new Point(x-1, y2));
                            } else {
                                painter.strokeLine(new Point(x, y1), new Point(x, y2));
                Severity: Major
                Found in src/ui/DisplayedCircuit.js and 1 other location - About 2 hrs to fix
                src/gates/Detector.js on lines 334..339

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

                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

                Severity
                Category
                Status
                Source
                Language