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
Function getToken
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
function getToken() {
tokenType = TOKENTYPE.NULL;
token = '';
// skip over whitespaces
- Read upRead up
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
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 = {
- Read upRead up
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: [],
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)
- Read upRead up
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 = {
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)
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') {
Function parseGraph
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseGraph() {
var graph = {};
first();
getToken();
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') {
- Read upRead up
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();
- Read upRead up
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)) {
- Read upRead up
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) {
Function parseGraph
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function parseGraph() {
var graph = {};
first();
getToken();
- Read upRead up
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();
- Read upRead up
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 = {};
}
- Read upRead up
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
- Read upRead up
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;
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: [],
- Read upRead up
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] "
- Exclude checks
TODO found Open
* TODO
- Exclude checks
TODO found Open
// TODO: support for attributes 'dir' and 'arrowhead' (edge arrows)
- Exclude checks
TODO found Open
// TODO: more precise parsing of numbers/strings (and the port separator ':')
- Exclude checks