Strilanc/Quirk

View on GitHub
src/circuit/Serializer.js

Summary

Maintainability
C
1 day
Test Coverage

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

    Function toJson_Gate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    let toJson_Gate = (gate, context=new CustomGateSet()) => {
        let found = Gates.findKnownGateById(gate.serializedId, context);
        if (found === gate) {
            return gate.serializedId;
        }
    Severity: Minor
    Found in src/circuit/Serializer.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 toJson_CircuitDefinition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    let toJson_CircuitDefinition = (v, context) => {
        let result = {
            cols: v.trimEmptyColumnsAtEndIgnoringGateWidths().columns.
                map(e => toJson_GateColumn(e, context || v.customGateSet)).
                map(c => seq(c).skipTailWhile(e => e === 1).toArray())
    Severity: Minor
    Found in src/circuit/Serializer.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 fromJson_Gate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    let fromJson_Gate = (json, context=new CustomGateSet()) => {
        let props = fromJson_Gate_props(json);
    
        try {
            if (props.matrix !== undefined) {
    Severity: Minor
    Found in src/circuit/Serializer.js - About 1 hr to fix

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

      let fromJson_Gate_Matrix = props => {
          let mat = _parseGateMatrix(props.matrix);
      
          // Special case the mystery gate.
          if (props.id === MysteryGateSymbol) {
      Severity: Minor
      Found in src/circuit/Serializer.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 _fromJson_InitialState has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function _fromJson_InitialState(json) {
          let {init} = json;
          if (init === undefined) {
              return new Map();
          }
      Severity: Minor
      Found in src/circuit/Serializer.js - About 45 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 fromJson_Gate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      let fromJson_Gate = (json, context=new CustomGateSet()) => {
          let props = fromJson_Gate_props(json);
      
          try {
              if (props.matrix !== undefined) {
      Severity: Minor
      Found in src/circuit/Serializer.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 fromJson_Gate_props has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      let fromJson_Gate_props = json => {
          let id = _getGateId(json);
          let matrix = json["matrix"];
          let circuit = json["circuit"];
          let param = json["arg"];
      Severity: Minor
      Found in src/circuit/Serializer.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

      There are no issues that match your filters.

      Category
      Status