lib/network/dotparser.js

Summary

Maintainability
F
5 days
Test Coverage

File dotparser.js has 589 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Parse a text source containing data in DOT language into a JSON object.
 * The object contains two lists: one with nodes and one with edges.
 *
 * DOT language reference: http://www.graphviz.org/doc/info/lang.html
Severity: Major
Found in lib/network/dotparser.js - About 1 day to fix

    Function getToken has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

    function getToken() {
      tokenType = TOKENTYPE.NULL;
      token = '';
    
      // skip over whitespaces
    Severity: Minor
    Found in lib/network/dotparser.js - About 1 day 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 getToken has 107 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getToken() {
      tokenType = TOKENTYPE.NULL;
      token = '';
    
      // skip over whitespaces
    Severity: Major
    Found in lib/network/dotparser.js - About 4 hrs to fix

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

      function parseAttributeList() {
        var attr = null;
      
        // edge styles of dot and vis
        var edgeStyles = {
      Severity: Minor
      Found in lib/network/dotparser.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 DOTToGraph has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function DOTToGraph (data) {
        // parse the DOT file
        var dotData = parseDOT(data);
        var graphData = {
          nodes: [],
      Severity: Major
      Found in lib/network/dotparser.js - About 2 hrs to fix

        Function addNode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        function addNode(graph, node) {
          var i, len;
          var current = null;
        
          // find root graph (in case of subgraph)
        Severity: Minor
        Found in lib/network/dotparser.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 parseAttributeList has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function parseAttributeList() {
          var attr = null;
        
          // edge styles of dot and vis
          var edgeStyles = {
        Severity: Minor
        Found in lib/network/dotparser.js - About 1 hr to fix

          Function addNode has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function addNode(graph, node) {
            var i, len;
            var current = null;
          
            // find root graph (in case of subgraph)
          Severity: Minor
          Found in lib/network/dotparser.js - About 1 hr to fix

            Function parseSubgraph has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function parseSubgraph (graph) {
              var subgraph = null;
            
              // optional subgraph keyword
              if (token === 'subgraph') {
            Severity: Minor
            Found in lib/network/dotparser.js - About 1 hr to fix

              Function parseGraph has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function parseGraph() {
                var graph = {};
              
                first();
                getToken();
              Severity: Minor
              Found in lib/network/dotparser.js - About 1 hr to fix

                Function parseSubgraph has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                function parseSubgraph (graph) {
                  var subgraph = null;
                
                  // optional subgraph keyword
                  if (token === 'subgraph') {
                Severity: Minor
                Found in lib/network/dotparser.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 parseEdge has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function parseEdge(graph, from) {
                  while (token === '->' || token === '--') {
                    var to;
                    var type = token;
                    getToken();
                Severity: Minor
                Found in lib/network/dotparser.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 convertAttr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function convertAttr (attr, mapping) {
                  var converted = {};
                
                  for (var prop in attr) {
                    if (attr.hasOwnProperty(prop)) {
                Severity: Minor
                Found in lib/network/dotparser.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 createEdge has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function createEdge(graph, from, to, type, attr) {
                Severity: Minor
                Found in lib/network/dotparser.js - About 35 mins to fix

                  Function parseGraph has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function parseGraph() {
                    var graph = {};
                  
                    first();
                    getToken();
                  Severity: Minor
                  Found in lib/network/dotparser.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 setValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function setValue(obj, path, value) {
                    var keys = path.split('.');
                    var o = obj;
                    while (keys.length) {
                      var key = keys.shift();
                  Severity: Minor
                  Found in lib/network/dotparser.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 merge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function merge (a, b) {
                    if (!a) {
                      a = {};
                    }
                  
                  
                  Severity: Minor
                  Found in lib/network/dotparser.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 parseStatement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function parseStatement(graph) {
                    // parse subgraph
                    var subgraph = parseSubgraph(graph);
                    if (subgraph) {
                      // edge statements
                  Severity: Minor
                  Found in lib/network/dotparser.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

                  Avoid too many return statements within this function.
                  Open

                      return;
                  Severity: Major
                  Found in lib/network/dotparser.js - About 30 mins to fix

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

                    function DOTToGraph (data) {
                      // parse the DOT file
                      var dotData = parseDOT(data);
                      var graphData = {
                        nodes: [],
                    Severity: Minor
                    Found in lib/network/dotparser.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

                    TODO found
                    Open

                        // TODO: implement comma separated list with "a_list: ID=ID [','] [a_list] "
                    Severity: Minor
                    Found in lib/network/dotparser.js by fixme

                    TODO found
                    Open

                     * TODO
                    Severity: Minor
                    Found in lib/network/dotparser.js by fixme

                    TODO found
                    Open

                          // TODO: support for attributes 'dir' and 'arrowhead' (edge arrows)
                    Severity: Minor
                    Found in lib/network/dotparser.js by fixme

                    TODO found
                    Open

                      // TODO: more precise parsing of numbers/strings (and the port separator ':')
                    Severity: Minor
                    Found in lib/network/dotparser.js by fixme

                    There are no issues that match your filters.

                    Category
                    Status