NaturalIntelligence/fast-xml-parser

View on GitHub

Showing 135 of 265 total issues

Function parseXml has a Cognitive Complexity of 153 (exceeds 5 allowed). Consider refactoring.
Open

const parseXml = function(xmlData) {
  xmlData = xmlData.replace(/\r\n?/g, "\n"); //TODO: remove this line
  const xmlObj = new xmlNode('!xml');
  let currentNode = xmlObj;
  let textData = "";
Severity: Minor
Found in src/xmlparser/OrderedObjParser.js - About 3 days 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 validate has a Cognitive Complexity of 133 (exceeds 5 allowed). Consider refactoring.
Open

exports.validate = function (xmlData, options) {
  options = Object.assign({}, defaultOptions, options);

  //xmlData = xmlData.replace(/(\r\n|\n|\r)/gm,"");//make it single line
  //xmlData = xmlData.replace(/(^\s*<\?xml.*?\?>)/g,"");//Remove XML starting tag
Severity: Minor
Found in src/validator.js - About 2 days 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 j2x has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

Builder.prototype.j2x = function(jObj, level) {
  let attrStr = '';
  let val = '';
  for (let key in jObj) {
    if(!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
Severity: Minor
Found in src/xmlbuilder/json2xml.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

File OrderedObjParser.js has 473 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';
///@ts-check

const util = require('../util');
const xmlNode = require('./xmlNode');
Severity: Minor
Found in src/xmlparser/OrderedObjParser.js - About 7 hrs to fix

    Function arrToStr has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    function arrToStr(arr, options, jPath, indentation) {
        let xmlStr = "";
        let isPreviousElementTag = false;
    
        for (let i = 0; i < arr.length; i++) {
    Severity: Minor
    Found in src/xmlbuilder/orderedJs2Xml.js - About 6 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 parseXml has 160 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const parseXml = function(xmlData) {
      xmlData = xmlData.replace(/\r\n?/g, "\n"); //TODO: remove this line
      const xmlObj = new xmlNode('!xml');
      let currentNode = xmlObj;
      let textData = "";
    Severity: Major
    Found in src/xmlparser/OrderedObjParser.js - About 6 hrs to fix

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

      function readDocType(xmlData, i){
          
          const entities = {};
          if( xmlData[i + 3] === 'O' &&
               xmlData[i + 4] === 'C' &&
      Severity: Minor
      Found in src/xmlparser/DocTypeReader.js - About 6 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 compress has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

      function compress(arr, options, jPath){
        let text;
        const compressedObj = {};
        for (let i = 0; i < arr.length; i++) {
          const tagObj = arr[i];
      Severity: Minor
      Found in src/xmlparser/node2json.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 buildAttributesMap has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      function buildAttributesMap(attrStr, jPath, tagName) {
        if (!this.options.ignoreAttributes && typeof attrStr === 'string') {
          // attrStr = attrStr.replace(/\r?\n/g, ' ');
          //attrStr = attrStr || attrStr.trim();
      
      
      Severity: Minor
      Found in src/xmlparser/OrderedObjParser.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 validate has 139 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.validate = function (xmlData, options) {
        options = Object.assign({}, defaultOptions, options);
      
        //xmlData = xmlData.replace(/(\r\n|\n|\r)/gm,"");//make it single line
        //xmlData = xmlData.replace(/(^\s*<\?xml.*?\?>)/g,"");//Remove XML starting tag
      Severity: Major
      Found in src/validator.js - About 5 hrs to fix

        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 readStopNode has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

        function readStopNode(xmlDoc, tagName, i){
            const startIndex = i;
            // Starting at 1 since we already have an open tag
            let openTagCount = 1;
          
        Severity: Minor
        Found in src/v5/XmlPartReader.js - About 4 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 readStopNodeData has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

        function readStopNodeData(xmlData, tagName, i){
          const startIndex = i;
          // Starting at 1 since we already have an open tag
          let openTagCount = 1;
        
        
        Severity: Minor
        Found in src/xmlparser/OrderedObjParser.js - About 4 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

        File validator.js has 327 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        const util = require('./util');
        
        const defaultOptions = {
        Severity: Minor
        Found in src/validator.js - About 3 hrs to fix

          Function constructor has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

            constructor(pathStr){
              let text = "";
              let tName = "";
              let pos;
              let aName = "";
          Severity: Minor
          Found in src/v5/TagPath.js - About 3 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 readCommentAndCDATA has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          function readCommentAndCDATA(xmlData, i) {
            if (xmlData.length > i + 5 && xmlData[i + 1] === '-' && xmlData[i + 2] === '-') {
              //comment
              for (i += 3; i < xmlData.length; i++) {
                if (xmlData[i] === '-' && xmlData[i + 1] === '-' && xmlData[i + 2] === '>') {
          Severity: Minor
          Found in src/validator.js - About 3 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 parseTextData has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
            if (val !== undefined) {
              if (this.options.trimValues && !dontTrim) {
                val = val.trim();
              }
          Severity: Minor
          Found in src/xmlparser/OrderedObjParser.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 readUptoCloseTag has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

            readUptoCloseTag(stopStr) { //stopStr: "</tagname"
              const inputLength = this.buffer.length;
              const stopLength = stopStr.length;
              let stopIndex = 0;
              //0: non-matching, 1: matching stop string, 2: matching closing
          Severity: Minor
          Found in src/v5/inputSource/StringSource.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 readUptoCloseTag has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          readUptoCloseTag(stopStr) { //stopStr: "</tagname"
              const inputLength = this.buffer.length;
              const stopLength = stopStr.length;
              const stopBuffer = Buffer.from(stopStr);
              let stopIndex = 0;
          Severity: Minor
          Found in src/v5/inputSource/BufferSource.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 arrToStr has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function arrToStr(arr, options, jPath, indentation) {
              let xmlStr = "";
              let isPreviousElementTag = false;
          
              for (let i = 0; i < arr.length; i++) {
          Severity: Major
          Found in src/xmlbuilder/orderedJs2Xml.js - About 2 hrs to fix
            Severity
            Category
            Status
            Source
            Language