department-of-veterans-affairs/vets-website

View on GitHub
src/applications/mhv-medical-records/util/radiologyUtil.js

Summary

Maintainability
C
1 day
Test Coverage

Function parseRadiologyReport has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

export const parseRadiologyReport = radiologyReportText => {
  const radiologyReportMap = {};
  const lines = radiologyReportText ? radiologyReportText.split(/\r?\n/) : [];
  let i = 0;
  let clinicalHistory = '';
Severity: Minor
Found in src/applications/mhv-medical-records/util/radiologyUtil.js - About 6 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 parseRadiologyReport has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const parseRadiologyReport = radiologyReportText => {
  const radiologyReportMap = {};
  const lines = radiologyReportText ? radiologyReportText.split(/\r?\n/) : [];
  let i = 0;
  let clinicalHistory = '';
Severity: Major
Found in src/applications/mhv-medical-records/util/radiologyUtil.js - About 3 hrs to fix

    Avoid deeply nested control flow statements.
    Open

        } else if (line.startsWith('Report:')) {
          // Begin collecting "Report" and "Impression"
          reportText = '';
          impressionText = '';
          inImpression = false;
    Severity: Major
    Found in src/applications/mhv-medical-records/util/radiologyUtil.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

            while (i < lines.length) {
              const historyLine = lines[i].trim();
              if (historyLine.startsWith('Report Status:')) {
                // Extract "Report Status" and remove "Date Reported" if present
                let statusValue = historyLine
      Severity: Major
      Found in src/applications/mhv-medical-records/util/radiologyUtil.js - About 45 mins to fix

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

        export const areDatesEqualToMinute = (var1, var2) => {
          const parseDate = input => {
            let date;
            if (/^\d+$/.test(input)) {
              // Input is a numeric string, parse it as a number (timestamp)
        Severity: Minor
        Found in src/applications/mhv-medical-records/util/radiologyUtil.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

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

        export const findMatchingPhrAndCvixStudies = async (
          id,
          phrResponse,
          cvixResponse,
        ) => {
        Severity: Minor
        Found in src/applications/mhv-medical-records/util/radiologyUtil.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

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

        export const findMatchingCvixReport = (phrResponse, cvixResponseList) => {
          if (phrResponse && Array.isArray(cvixResponseList)) {
            for (const cvixResponse of cvixResponseList) {
              if (radiologyReportsMatch(phrResponse, cvixResponse)) {
                return cvixResponse;
        Severity: Minor
        Found in src/applications/mhv-medical-records/util/radiologyUtil.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

        There are no issues that match your filters.

        Category
        Status