NaturalIntelligence/fast-xml-parser

View on GitHub

Showing 135 of 267 total issues

Function j2x has 66 lines of code (exceeds 25 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: Major
Found in src/xmlbuilder/json2xml.js - About 2 hrs to fix

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

        parseXml() {
          //TODO: Separate TagValueParser as separate class. So no scope issue in node builder class 
    
          //OutputBuilder should be set in XML Parser
          this.outputBuilder = this.options.OutputBuilder.getInstance(this.options);
    Severity: Minor
    Found in src/v5/Xml2JsParser.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 tagExpWithClosingIndex has a Cognitive Complexity of 17 (exceeds 5 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 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 readDocType has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function readDocType(xmlData, i){
        
        const entities = {};
        if( xmlData[i + 3] === 'O' &&
             xmlData[i + 4] === 'C' &&
    Severity: Major
    Found in src/xmlparser/DocTypeReader.js - About 2 hrs to fix

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

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

          Function readPiExp has a Cognitive Complexity of 14 (exceeds 5 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

          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 readAttributeStr has a Cognitive Complexity of 14 (exceeds 5 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

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

          function copyProperties(target, source) {
            for (let key in source) {
              if (source.hasOwnProperty(key)) {
                if (key === 'OutputBuilder') {
                  target[key] = source[key];
          Severity: Minor
          Found in src/v5/OptionsBuilder.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 compress has 42 lines of code (exceeds 25 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 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

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

              Function copyProperties has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              function copyProperties(target, source) {
                for (let key in source) {
                  if (source.hasOwnProperty(key)) {
                    if (typeof source[key] === 'object' && !Array.isArray(source[key])) {
                      // Recursively copy nested properties
              Severity: Minor
              Found in src/v5/OutputBuilders/ParserOptionsBuilder.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 buildObjectNode has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              Builder.prototype.buildObjectNode = function(val, key, attrStr, level) {
                if(val === ""){
                  if(key[0] === "?") return  this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;
                  else {
                    return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;
              Severity: Minor
              Found in src/xmlbuilder/json2xml.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 constructor has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                constructor(pathStr){
                  let text = "";
                  let tName = "";
                  let pos;
                  let aName = "";
              Severity: Minor
              Found in src/v5/TagPath.js - About 1 hr to fix

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

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

                    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

                      Consider simplifying this complex logical expression.
                      Open

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

                        Consider simplifying this complex logical expression.
                        Open

                            if(xmlData[i+1] === '!' &&
                            xmlData[i+2] === 'A' &&
                            xmlData[i+3] === 'T' &&
                            xmlData[i+4] === 'T' &&
                            xmlData[i+5] === 'L' &&
                        Severity: Critical
                        Found in src/xmlparser/DocTypeReader.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language