dataplug-io/dataplug-xml

View on GitHub

Showing 11 of 11 total issues

Function serializeToXml has 103 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function serializeToXml (value, name = undefined, options = undefined, indentDepth = 0) {
  const isComplex = isComplexValue(value)
  const isScalar = isScalarValue(value)
  if (!isComplex && !isScalar && !_.isNil(value)) {
    throw new TypeError(`${typeof value} is not supported`)
Severity: Major
Found in lib/serializeToXml.js - About 4 hrs to fix

    Function serializeToXml has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    function serializeToXml (value, name = undefined, options = undefined, indentDepth = 0) {
      const isComplex = isComplexValue(value)
      const isScalar = isScalarValue(value)
      if (!isComplex && !isScalar && !_.isNil(value)) {
        throw new TypeError(`${typeof value} is not supported`)
    Severity: Minor
    Found in lib/serializeToXml.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

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

      _onParserCData (data) {
        logger.log('debug', 'CData found in XmlStreamReader')
        logger.log('silly', 'CData:', data)
    
        const node = this._document.createCDATASection(data)
    Severity: Major
    Found in lib/xmlStreamReader.js and 2 other locations - About 2 hrs to fix
    lib/xmlStreamReader.js on lines 186..194
    lib/xmlStreamReader.js on lines 212..220

    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 82.

    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 3 locations. Consider refactoring.
    Open

      _onParserCharacters (chars) {
        logger.log('debug', 'Characters found in XmlStreamReader')
        logger.log('silly', 'Characters:', chars)
    
        const node = this._document.createTextNode(chars)
    Severity: Major
    Found in lib/xmlStreamReader.js and 2 other locations - About 2 hrs to fix
    lib/xmlStreamReader.js on lines 199..207
    lib/xmlStreamReader.js on lines 212..220

    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 82.

    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 3 locations. Consider refactoring.
    Open

      _onParserComment (comment) {
        logger.log('debug', 'Comment found in XmlStreamReader')
        logger.log('silly', 'Comment:', comment)
    
        const node = this._document.createComment(comment)
    Severity: Major
    Found in lib/xmlStreamReader.js and 2 other locations - About 2 hrs to fix
    lib/xmlStreamReader.js on lines 186..194
    lib/xmlStreamReader.js on lines 199..207

    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 82.

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

    function deserializeFromXml (xml) {
      const node = _.isString(xml)
        ? new DOMParser().parseFromString(xml).documentElement
        : xml
    
    
    Severity: Minor
    Found in lib/deserializeFromXml.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

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

          if (isScalarValue(property)) {
            if (!isValidElementName(key)) {
              throw new Error(`"${key}" is not a valid name for declaration value`)
            }
    
    
    Severity: Major
    Found in lib/serializeToXml.js and 1 other location - About 1 hr to fix
    lib/serializeToXml.js on lines 129..139

    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 72.

    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 2 locations. Consider refactoring.
    Open

          if (isScalarValue(property)) {
            if (!isValidElementName(key)) {
              throw new Error(`"${key}" is not a valid name for attribute value`)
            }
    
    
    Severity: Major
    Found in lib/serializeToXml.js and 1 other location - About 1 hr to fix
    lib/serializeToXml.js on lines 103..113

    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 72.

    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 deserializeFromXml has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function deserializeFromXml (xml) {
      const node = _.isString(xml)
        ? new DOMParser().parseFromString(xml).documentElement
        : xml
    
    
    Severity: Minor
    Found in lib/deserializeFromXml.js - About 1 hr to fix

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

        constructor (selector = '/*/*') {
          check.assert.string(selector)
      
          super({
            objectMode: false,
      Severity: Minor
      Found in lib/xmlStreamReader.js - About 1 hr to fix

        Function _transform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          _transform (chunk, encoding, callback) {
            let xmlChunk
            try {
              xmlChunk = serializeToXml(chunk, this.itemElementName, {
                indent: this.indent
        Severity: Minor
        Found in lib/xmlStreamWriter.js - About 25 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