NaturalIntelligence/fast-xml-parser

View on GitHub
src/v5/XmlSpecialTagsReader.js

Summary

Maintainability
C
1 day
Test Coverage

Function readDocType has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

function readDocType(parser){
  //<!D are already read till this point
  let str = parser.source.readStr(6); //OCTYPE
  parser.source.updateBufferBoundary(6);

Severity: Minor
Found in src/v5/XmlSpecialTagsReader.js - About 5 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 registerEntity has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function registerEntity(parser){
  //read Entity
  let attrBoundary="";
  let name ="", val ="";
  while(source.canRead()){
Severity: Minor
Found in src/v5/XmlSpecialTagsReader.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 readDocType has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function readDocType(parser){
  //<!D are already read till this point
  let str = parser.source.readStr(6); //OCTYPE
  parser.source.updateBufferBoundary(6);

Severity: Minor
Found in src/v5/XmlSpecialTagsReader.js - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

            }else if(str === "!-") {//comment
              readComment(parser);
            }else{ //ELEMENT, ATTLIST, NOTATION
              let dTagExp = parser.source.readUpto(">");
              const regx = DOCTYPE_tags[str];
    Severity: Major
    Found in src/v5/XmlSpecialTagsReader.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if(str !== "TITY") throw new Error("Invalid DOCTYPE ENTITY expression");
      Severity: Major
      Found in src/v5/XmlSpecialTagsReader.js - About 45 mins to fix

        'text' is not defined.
        Open

                name = text.trimStart();
        Severity: Minor
        Found in src/v5/XmlSpecialTagsReader.js by eslint

        Disallow Undeclared Variables (no-undef)

        This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

        Rule Details

        Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

        Examples of incorrect code for this rule:

        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        Examples of correct code for this rule with global declaration:

        /*global someFunction b:true*/
        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        The b:true syntax in /*global */ indicates that assignment to b is correct.

        Examples of incorrect code for this rule with global declaration:

        /*global b*/
        /*eslint no-undef: "error"*/
        
        b = 10;

        By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

        Options

        • typeof set to true will warn for variables used inside typeof check (Default false).

        typeof

        Examples of correct code for the default { "typeof": false } option:

        /*eslint no-undef: "error"*/
        
        if (typeof UndefinedIdentifier === "undefined") {
            // do something ...
        }

        You can use this option if you want to prevent typeof check on a variable which has not been declared.

        Examples of incorrect code for the { "typeof": true } option:

        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Examples of correct code for the { "typeof": true } option with global declaration:

        /*global a*/
        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Environments

        For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

        browser

        Examples of correct code for this rule with browser environment:

        /*eslint no-undef: "error"*/
        /*eslint-env browser*/
        
        setTimeout(function() {
            alert("Hello");
        });

        node

        Examples of correct code for this rule with node environment:

        /*eslint no-undef: "error"*/
        /*eslint-env node*/
        
        var fs = require("fs");
        module.exports = function() {
            console.log(fs);
        };

        When Not To Use It

        If explicit declaration of global variables is not to your taste.

        Compatibility

        This rule provides compatibility with treatment of global variables in JSHint and JSLint. Source: http://eslint.org/docs/rules/

        'source' is not defined.
        Open

            let ch = source.readCh();
        Severity: Minor
        Found in src/v5/XmlSpecialTagsReader.js by eslint

        Disallow Undeclared Variables (no-undef)

        This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

        Rule Details

        Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

        Examples of incorrect code for this rule:

        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        Examples of correct code for this rule with global declaration:

        /*global someFunction b:true*/
        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        The b:true syntax in /*global */ indicates that assignment to b is correct.

        Examples of incorrect code for this rule with global declaration:

        /*global b*/
        /*eslint no-undef: "error"*/
        
        b = 10;

        By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

        Options

        • typeof set to true will warn for variables used inside typeof check (Default false).

        typeof

        Examples of correct code for the default { "typeof": false } option:

        /*eslint no-undef: "error"*/
        
        if (typeof UndefinedIdentifier === "undefined") {
            // do something ...
        }

        You can use this option if you want to prevent typeof check on a variable which has not been declared.

        Examples of incorrect code for the { "typeof": true } option:

        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Examples of correct code for the { "typeof": true } option with global declaration:

        /*global a*/
        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Environments

        For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

        browser

        Examples of correct code for this rule with browser environment:

        /*eslint no-undef: "error"*/
        /*eslint-env browser*/
        
        setTimeout(function() {
            alert("Hello");
        });

        node

        Examples of correct code for this rule with node environment:

        /*eslint no-undef: "error"*/
        /*eslint-env node*/
        
        var fs = require("fs");
        module.exports = function() {
            console.log(fs);
        };

        When Not To Use It

        If explicit declaration of global variables is not to your taste.

        Compatibility

        This rule provides compatibility with treatment of global variables in JSHint and JSLint. Source: http://eslint.org/docs/rules/

        'text' is not defined.
        Open

                val = text;
        Severity: Minor
        Found in src/v5/XmlSpecialTagsReader.js by eslint

        Disallow Undeclared Variables (no-undef)

        This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

        Rule Details

        Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

        Examples of incorrect code for this rule:

        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        Examples of correct code for this rule with global declaration:

        /*global someFunction b:true*/
        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        The b:true syntax in /*global */ indicates that assignment to b is correct.

        Examples of incorrect code for this rule with global declaration:

        /*global b*/
        /*eslint no-undef: "error"*/
        
        b = 10;

        By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

        Options

        • typeof set to true will warn for variables used inside typeof check (Default false).

        typeof

        Examples of correct code for the default { "typeof": false } option:

        /*eslint no-undef: "error"*/
        
        if (typeof UndefinedIdentifier === "undefined") {
            // do something ...
        }

        You can use this option if you want to prevent typeof check on a variable which has not been declared.

        Examples of incorrect code for the { "typeof": true } option:

        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Examples of correct code for the { "typeof": true } option with global declaration:

        /*global a*/
        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Environments

        For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

        browser

        Examples of correct code for this rule with browser environment:

        /*eslint no-undef: "error"*/
        /*eslint-env browser*/
        
        setTimeout(function() {
            alert("Hello");
        });

        node

        Examples of correct code for this rule with node environment:

        /*eslint no-undef: "error"*/
        /*eslint-env node*/
        
        var fs = require("fs");
        module.exports = function() {
            console.log(fs);
        };

        When Not To Use It

        If explicit declaration of global variables is not to your taste.

        Compatibility

        This rule provides compatibility with treatment of global variables in JSHint and JSLint. Source: http://eslint.org/docs/rules/

        'text' is not defined.
        Open

                text = "";
        Severity: Minor
        Found in src/v5/XmlSpecialTagsReader.js by eslint

        Disallow Undeclared Variables (no-undef)

        This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

        Rule Details

        Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

        Examples of incorrect code for this rule:

        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        Examples of correct code for this rule with global declaration:

        /*global someFunction b:true*/
        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        The b:true syntax in /*global */ indicates that assignment to b is correct.

        Examples of incorrect code for this rule with global declaration:

        /*global b*/
        /*eslint no-undef: "error"*/
        
        b = 10;

        By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

        Options

        • typeof set to true will warn for variables used inside typeof check (Default false).

        typeof

        Examples of correct code for the default { "typeof": false } option:

        /*eslint no-undef: "error"*/
        
        if (typeof UndefinedIdentifier === "undefined") {
            // do something ...
        }

        You can use this option if you want to prevent typeof check on a variable which has not been declared.

        Examples of incorrect code for the { "typeof": true } option:

        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Examples of correct code for the { "typeof": true } option with global declaration:

        /*global a*/
        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Environments

        For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

        browser

        Examples of correct code for this rule with browser environment:

        /*eslint no-undef: "error"*/
        /*eslint-env browser*/
        
        setTimeout(function() {
            alert("Hello");
        });

        node

        Examples of correct code for this rule with node environment:

        /*eslint no-undef: "error"*/
        /*eslint-env node*/
        
        var fs = require("fs");
        module.exports = function() {
            console.log(fs);
        };

        When Not To Use It

        If explicit declaration of global variables is not to your taste.

        Compatibility

        This rule provides compatibility with treatment of global variables in JSHint and JSLint. Source: http://eslint.org/docs/rules/

        'text' is not defined.
        Open

              text+=ch;
        Severity: Minor
        Found in src/v5/XmlSpecialTagsReader.js by eslint

        Disallow Undeclared Variables (no-undef)

        This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

        Rule Details

        Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

        Examples of incorrect code for this rule:

        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        Examples of correct code for this rule with global declaration:

        /*global someFunction b:true*/
        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        The b:true syntax in /*global */ indicates that assignment to b is correct.

        Examples of incorrect code for this rule with global declaration:

        /*global b*/
        /*eslint no-undef: "error"*/
        
        b = 10;

        By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

        Options

        • typeof set to true will warn for variables used inside typeof check (Default false).

        typeof

        Examples of correct code for the default { "typeof": false } option:

        /*eslint no-undef: "error"*/
        
        if (typeof UndefinedIdentifier === "undefined") {
            // do something ...
        }

        You can use this option if you want to prevent typeof check on a variable which has not been declared.

        Examples of incorrect code for the { "typeof": true } option:

        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Examples of correct code for the { "typeof": true } option with global declaration:

        /*global a*/
        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Environments

        For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

        browser

        Examples of correct code for this rule with browser environment:

        /*eslint no-undef: "error"*/
        /*eslint-env browser*/
        
        setTimeout(function() {
            alert("Hello");
        });

        node

        Examples of correct code for this rule with node environment:

        /*eslint no-undef: "error"*/
        /*eslint-env node*/
        
        var fs = require("fs");
        module.exports = function() {
            console.log(fs);
        };

        When Not To Use It

        If explicit declaration of global variables is not to your taste.

        Compatibility

        This rule provides compatibility with treatment of global variables in JSHint and JSLint. Source: http://eslint.org/docs/rules/

        'text' is not defined.
        Open

                text = ""
        Severity: Minor
        Found in src/v5/XmlSpecialTagsReader.js by eslint

        Disallow Undeclared Variables (no-undef)

        This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

        Rule Details

        Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

        Examples of incorrect code for this rule:

        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        Examples of correct code for this rule with global declaration:

        /*global someFunction b:true*/
        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        The b:true syntax in /*global */ indicates that assignment to b is correct.

        Examples of incorrect code for this rule with global declaration:

        /*global b*/
        /*eslint no-undef: "error"*/
        
        b = 10;

        By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

        Options

        • typeof set to true will warn for variables used inside typeof check (Default false).

        typeof

        Examples of correct code for the default { "typeof": false } option:

        /*eslint no-undef: "error"*/
        
        if (typeof UndefinedIdentifier === "undefined") {
            // do something ...
        }

        You can use this option if you want to prevent typeof check on a variable which has not been declared.

        Examples of incorrect code for the { "typeof": true } option:

        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Examples of correct code for the { "typeof": true } option with global declaration:

        /*global a*/
        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Environments

        For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

        browser

        Examples of correct code for this rule with browser environment:

        /*eslint no-undef: "error"*/
        /*eslint-env browser*/
        
        setTimeout(function() {
            alert("Hello");
        });

        node

        Examples of correct code for this rule with node environment:

        /*eslint no-undef: "error"*/
        /*eslint-env node*/
        
        var fs = require("fs");
        module.exports = function() {
            console.log(fs);
        };

        When Not To Use It

        If explicit declaration of global variables is not to your taste.

        Compatibility

        This rule provides compatibility with treatment of global variables in JSHint and JSLint. Source: http://eslint.org/docs/rules/

        'source' is not defined.
        Open

          while(source.canRead()){
        Severity: Minor
        Found in src/v5/XmlSpecialTagsReader.js by eslint

        Disallow Undeclared Variables (no-undef)

        This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

        Rule Details

        Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

        Examples of incorrect code for this rule:

        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        Examples of correct code for this rule with global declaration:

        /*global someFunction b:true*/
        /*eslint no-undef: "error"*/
        
        var a = someFunction();
        b = 10;

        The b:true syntax in /*global */ indicates that assignment to b is correct.

        Examples of incorrect code for this rule with global declaration:

        /*global b*/
        /*eslint no-undef: "error"*/
        
        b = 10;

        By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

        Options

        • typeof set to true will warn for variables used inside typeof check (Default false).

        typeof

        Examples of correct code for the default { "typeof": false } option:

        /*eslint no-undef: "error"*/
        
        if (typeof UndefinedIdentifier === "undefined") {
            // do something ...
        }

        You can use this option if you want to prevent typeof check on a variable which has not been declared.

        Examples of incorrect code for the { "typeof": true } option:

        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Examples of correct code for the { "typeof": true } option with global declaration:

        /*global a*/
        /*eslint no-undef: ["error", { "typeof": true }] */
        
        if(typeof a === "string"){}

        Environments

        For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

        browser

        Examples of correct code for this rule with browser environment:

        /*eslint no-undef: "error"*/
        /*eslint-env browser*/
        
        setTimeout(function() {
            alert("Hello");
        });

        node

        Examples of correct code for this rule with node environment:

        /*eslint no-undef: "error"*/
        /*eslint-env node*/
        
        var fs = require("fs");
        module.exports = function() {
            console.log(fs);
        };

        When Not To Use It

        If explicit declaration of global variables is not to your taste.

        Compatibility

        This rule provides compatibility with treatment of global variables in JSHint and JSLint. Source: http://eslint.org/docs/rules/

        TODO found
        Open

          if (tagExp.tagName === "?xml") {//TODO: test if tagName is just xml
        Severity: Minor
        Found in src/v5/XmlSpecialTagsReader.js by fixme

        TODO found
        Open

            //TODO: use readChAt like used in partReader
        Severity: Minor
        Found in src/v5/XmlSpecialTagsReader.js by fixme

        There are no issues that match your filters.

        Category
        Status