NaturalIntelligence/fast-xml-parser

View on GitHub

Showing 267 of 267 total issues

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

    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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          if( !isEmpty(this.attributes)){
            value = {};
            if(this.options.attributes.groupBy){
              value[this.options.attributes.groupBy] = this.attributes;
            }else{
      Severity: Major
      Found in src/v5/OutputBuilders/JsObjBuilder.js and 1 other location - About 2 hrs to fix
      src/v5/OutputBuilders/JsObjBuilder.js on lines 44..51

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 86.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          if( !isEmpty(this.attributes)){
            value = {};
            if(this.options.attributes.groupBy){
              value[this.options.attributes.groupBy] = this.attributes;
            }else{
      Severity: Major
      Found in src/v5/OutputBuilders/JsObjBuilder.js and 1 other location - About 2 hrs to fix
      src/v5/OutputBuilders/JsObjBuilder.js on lines 136..143

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 86.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      function validateEntityName(name){
          for (let i = 0; i < specialChar.length; i++) {
              const ch = specialChar[i];
              if(name.indexOf(ch) !== -1) throw new Error(`Invalid character ${ch} in entity name`);
          }
      Severity: Major
      Found in src/v5/valueParsers/EntitiesParser.js and 1 other location - About 2 hrs to fix
      src/v5/EntitiesParser.js on lines 99..105

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 84.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      function validateEntityName(name){
          for (let i = 0; i < specialChar.length; i++) {
              const ch = specialChar[i];
              if(name.indexOf(ch) !== -1) throw new Error(`Invalid character ${ch} in entity name`);
          }
      Severity: Major
      Found in src/v5/EntitiesParser.js and 1 other location - About 2 hrs to fix
      src/v5/valueParsers/EntitiesParser.js on lines 99..105

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 84.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            {
                context: __dirname,
                entry: "./src/fxp.js",
                mode: "production",
                devtool: "source-map",
        Severity: Major
        Found in webpack-prod.config.js and 3 other locations - About 2 hrs to fix
        webpack-prod.config.js on lines 24..44
        webpack-prod.config.js on lines 44..64
        webpack-prod.config.js on lines 64..84

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 77.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            },{
                context: __dirname,
                entry: "./src/xmlparser/XMLParser.js",
                mode: "production",
                devtool: "source-map",
        Severity: Major
        Found in webpack-prod.config.js and 3 other locations - About 2 hrs to fix
        webpack-prod.config.js on lines 4..24
        webpack-prod.config.js on lines 24..44
        webpack-prod.config.js on lines 64..84

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 77.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            },{
                context: __dirname,
                entry: "./src/validator.js",
                mode: "production",
                devtool: "source-map",
        Severity: Major
        Found in webpack-prod.config.js and 3 other locations - About 2 hrs to fix
        webpack-prod.config.js on lines 4..24
        webpack-prod.config.js on lines 24..44
        webpack-prod.config.js on lines 44..64

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 77.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            },{
                context: __dirname,
                entry: "./src/xmlbuilder/json2xml.js",
                mode: "production",
                devtool: "source-map",
        Severity: Major
        Found in webpack-prod.config.js and 3 other locations - About 2 hrs to fix
        webpack-prod.config.js on lines 4..24
        webpack-prod.config.js on lines 44..64
        webpack-prod.config.js on lines 64..84

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 77.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        suite
            .add("fxp v3", function() {
                fxpv3.parse(xmlData);
            })
            .add("fxp", function() {
        Severity: Major
        Found in benchmark/XmlParser.js and 1 other location - About 1 hr to fix
        benchmark/XmlBuilder.js on lines 20..48

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 74.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        suite
            .add("fxp", function() {
                fxpBuilder.build(jsonData);
            })
            .add("fxp - preserve order", function() {
        Severity: Major
        Found in benchmark/XmlBuilder.js and 1 other location - About 1 hr to fix
        benchmark/XmlParser.js on lines 23..64

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 74.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

            Severity
            Category
            Status
            Source
            Language