dataplug-io/dataplug-xml

View on GitHub

Showing 6 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

    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

    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