NaturalIntelligence/fast-xml-parser

View on GitHub

Showing 135 of 267 total issues

Consider simplifying this complex logical expression.
Open

  } else if (
    xmlData.length > i + 9 &&
    xmlData[i + 1] === '[' &&
    xmlData[i + 2] === 'C' &&
    xmlData[i + 3] === 'D' &&
Severity: Critical
Found in src/validator.js - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

      } else if (
        xmlData.length > i + 8 &&
        xmlData[i + 1] === 'D' &&
        xmlData[i + 2] === 'O' &&
        xmlData[i + 3] === 'C' &&
    Severity: Critical
    Found in src/validator.js - About 1 hr to fix

      Function constructor has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor(options){
          this.options = options;
          this.currentNode = null;
          this.tagsNodeStack = [];
          this.docTypeEntities = {};
      Severity: Minor
      Found in src/xmlparser/OrderedObjParser.js - About 1 hr to fix

        Function replaceEntitiesValue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            replaceEntitiesValue(val){
                if(typeof val === "string" && val.length > 0){
                    for(let entityName in this.docTypeEntities){
                        const entity = this.docTypeEntities[entityName];
                        val = val.replace( entity.regx, entity.val);
        Severity: Minor
        Found in src/v5/EntitiesParser.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 validateAttributeString has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        function validateAttributeString(attrStr, options) {
          //console.log("start:"+attrStr+":end");
        
          //if(attrStr.trim().length === 0) return true; //empty string
        
        
        Severity: Minor
        Found in src/validator.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 replaceEntitiesValue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            replaceEntitiesValue(val){
                if(typeof val === "string" && val.length > 0){
                    for(let entityName in this.docTypeEntities){
                        const entity = this.docTypeEntities[entityName];
                        val = val.replace( entity.regx, entity.val);
        Severity: Minor
        Found in src/v5/valueParsers/EntitiesParser.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 readUptoCloseTag has 28 lines of code (exceeds 25 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 1 hr to fix

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

            const callback = function(xmlData) {
              let output = '';
              if (validate) {
                const parser = new XMLParser(options);
                output = parser.parse(xmlData,validate);
          Severity: Minor
          Found in src/cli/cli.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 parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              parse(xmlData,validationOption){
                  if(typeof xmlData === "string"){
                  }else if( xmlData.toString){
                      xmlData = xmlData.toString();
                  }else{
          Severity: Minor
          Found in src/xmlparser/XMLParser.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 attr_to_str has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function attr_to_str(attrMap, options) {
              let attrStr = "";
              if (attrMap && !options.ignoreAttributes) {
                  for (let attr in attrMap) {
                      if(!attrMap.hasOwnProperty(attr)) continue;
          Severity: Minor
          Found in src/xmlbuilder/orderedJs2Xml.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 replaceEntitiesValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          const replaceEntitiesValue = function(val){
          
            if(this.options.processEntities){
              for(let entityName in this.docTypeEntities){
                const entity = this.docTypeEntities[entityName];
          Severity: Minor
          Found in src/xmlparser/OrderedObjParser.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 readPiExp has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function readPiExp(parser) {
            let inSingleQuotes = false;
            let inDoubleQuotes = false;
            let i;
            let EOE = false;
          Severity: Minor
          Found in src/v5/XmlPartReader.js - About 1 hr to fix

            Function tagExpWithClosingIndex has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function tagExpWithClosingIndex(xmlData, i, closingChar = ">"){
              let attrBoundary;
              let tagExp = "";
              for (let index = i; index < xmlData.length; index++) {
                let ch = xmlData[index];
            Severity: Minor
            Found in src/xmlparser/OrderedObjParser.js - About 1 hr to fix

              Function readAttributeStr has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function readAttributeStr(xmlData, i) {
                let attrStr = '';
                let startChar = '';
                let tagClosed = false;
                for (; i < xmlData.length; i++) {
              Severity: Minor
              Found in src/validator.js - About 1 hr to fix

                Function readUptoCloseTag has 27 lines of code (exceeds 25 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 1 hr to fix

                  Function readTagExp has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function readTagExp(xmlData,i, removeNSPrefix, closingChar = ">"){
                    const result = tagExpWithClosingIndex(xmlData, i+1, closingChar);
                    if(!result) return;
                    let tagExp = result.data;
                    const closeIndex = result.index;
                  Severity: Minor
                  Found in src/xmlparser/OrderedObjParser.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                        if(xmlData[i+1] === '!' &&
                        xmlData[i+2] === 'E' &&
                        xmlData[i+3] === 'N' &&
                        xmlData[i+4] === 'T' &&
                        xmlData[i+5] === 'I' &&
                    Severity: Major
                    Found in src/xmlparser/DocTypeReader.js - About 1 hr to fix

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

                      function readPI(xmlData, i) {
                        const start = i;
                        for (; i < xmlData.length; i++) {
                          if (xmlData[i] == '?' || xmlData[i] == ' ') {
                            //tagname
                      Severity: Minor
                      Found in src/validator.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 match has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        match(tagStack,node){
                          if(this.stack[0].name !== "*"){
                            if(this.stack.length !== tagStack.length +1) return false;
                        
                            //loop through tagPath and tagStack and match
                      Severity: Minor
                      Found in src/v5/TagPath.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 readSpecialTag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          readSpecialTag(startCh){
                            if(startCh == "!"){
                              let nextChar = this.source.readCh();
                              if (nextChar === null || nextChar === undefined) throw new Error("Unexpected ending of the source");
                              
                      Severity: Minor
                      Found in src/v5/Xml2JsParser.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

                      Severity
                      Category
                      Status
                      Source
                      Language