rimiti/object-hl7-parser

View on GitHub

Showing 3 of 3 total issues

Function _createContent has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

  _createContent(segmentName, segmentConfig) {
    let segment_arguments = []
    segment_arguments.push(segmentName.toUpperCase())
    for (let component_index = 0; component_index < segmentConfig.configuration.components.count; component_index++) {
      let numberOfSeparatorInsideComponent = segmentConfig.configuration.components.seperators.filter((component) => {
Severity: Minor
Found in src/class/encoder/index.js - About 7 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 _createContent has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _createContent(segmentName, segmentConfig) {
    let segment_arguments = []
    segment_arguments.push(segmentName.toUpperCase())
    for (let component_index = 0; component_index < segmentConfig.configuration.components.count; component_index++) {
      let numberOfSeparatorInsideComponent = segmentConfig.configuration.components.seperators.filter((component) => {
Severity: Minor
Found in src/class/encoder/index.js - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                if (this._deepFind(this.message_to_encode, fields[i].field) && fields[i].type != 'array') {
                  for (let rep = 0; rep < fields[i].children.length; rep++) {
                    fields_content[fields[i].children[rep].component[1] - 1] = this._getFieldContent(this._deepFind(this.message_to_encode, fields[i].field), fields[i].children[rep])
                  }
                } else if (this._deepFind(this.message_to_encode, fields[i].field)) {
    Severity: Major
    Found in src/class/encoder/index.js - About 45 mins to fix
      Severity
      Category
      Status
      Source
      Language