infoderm/medidoc

View on GitHub

Showing 25 of 25 total issues

File parseBundle.js has 508 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import assert from 'node:assert';

import * as tape from '@async-abstraction/tape';
import {asyncIterableToArray} from '@async-iterable-iterator/async-iterable-to-array';
import {ll1, ast} from '@formal-language/grammar';
Severity: Major
Found in src/parseBundle.js - About 1 day to fix

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

    const parsePhone = (tree) => {
        assert(tree.type === 'leaf');
        assert(tree.terminal === 'doctor-phone');
        assert(tree.lines.length === 1);
        const line = tree.lines[0].contents;
    Severity: Major
    Found in src/parseBundle.js and 4 other locations - About 3 hrs to fix
    src/parseBundle.js on lines 41..52
    src/parseBundle.js on lines 201..212
    src/parseBundle.js on lines 404..415
    src/parseBundle.js on lines 417..428

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

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

    const parseLabName = (tree) => {
        assert(tree.type === 'leaf');
        assert(tree.terminal === 'lab-name');
        assert(tree.lines.length === 1);
        const line = tree.lines[0].contents;
    Severity: Major
    Found in src/parseBundle.js and 4 other locations - About 3 hrs to fix
    src/parseBundle.js on lines 41..52
    src/parseBundle.js on lines 201..212
    src/parseBundle.js on lines 390..401
    src/parseBundle.js on lines 404..415

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

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

    const parseBlockTitle = (tree) => {
        assert(tree.type === 'leaf');
        assert(tree.terminal === 'R-title');
        assert(tree.lines.length === 1);
        const line = tree.lines[0].contents;
    Severity: Major
    Found in src/parseBundle.js and 4 other locations - About 3 hrs to fix
    src/parseBundle.js on lines 201..212
    src/parseBundle.js on lines 390..401
    src/parseBundle.js on lines 404..415
    src/parseBundle.js on lines 417..428

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

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

    const parseLabIdentifier = (tree) => {
        assert(tree.type === 'leaf');
        assert(tree.terminal === 'lab-identifier');
        assert(tree.lines.length === 1);
        const line = tree.lines[0].contents;
    Severity: Major
    Found in src/parseBundle.js and 4 other locations - About 3 hrs to fix
    src/parseBundle.js on lines 41..52
    src/parseBundle.js on lines 201..212
    src/parseBundle.js on lines 390..401
    src/parseBundle.js on lines 417..428

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

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

    const parseReference = (tree) => {
        assert(tree.type === 'leaf');
        assert(tree.terminal === 'A-reference');
        assert(tree.lines.length === 1);
        const line = tree.lines[0].contents;
    Severity: Major
    Found in src/parseBundle.js and 4 other locations - About 3 hrs to fix
    src/parseBundle.js on lines 41..52
    src/parseBundle.js on lines 390..401
    src/parseBundle.js on lines 404..415
    src/parseBundle.js on lines 417..428

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

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

    async function* _tokens(tape) {
        let line = FIRST_LINE;
        let position = FIRST_POSITION;
    
        let buffer = '';
    Severity: Major
    Found in src/tokens.js - About 2 hrs to fix

      Function _tokens has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      async function* _tokens(tape) {
          let line = FIRST_LINE;
          let position = FIRST_POSITION;
      
          let buffer = '';
      Severity: Minor
      Found in src/tokens.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 lines has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      const lines = async (tree) => {
          // TODO use depth first traversal or make newline a terminal
          const result = [];
          const it = iter(leaves(tree));
          let position = null;
      Severity: Minor
      Found in src/transform/simplify.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 documentHeaderParts has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const documentHeaderParts = function* (header) {
          if (header.kind === 'lab') {
              yield {
                  type: 'lab',
                  lab: {
      Severity: Minor
      Found in src/split.js - About 1 hr to fix

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

        const lines = async (tree) => {
            // TODO use depth first traversal or make newline a terminal
            const result = [];
            const it = iter(leaves(tree));
            let position = null;
        Severity: Minor
        Found in src/transform/simplify.js - About 1 hr to fix

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

          const parseDocumentFooter = (tree) => {
              assert(tree.type === 'leaf');
              assert(tree.terminal === 'footer');
              assert(tree.lines.length === 1);
              return tree;
          Severity: Major
          Found in src/parseBundle.js and 1 other location - About 1 hr to fix
          src/parseBundle.js on lines 283..288

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

          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

          const parseReportFooter = (tree) => {
              assert(tree.type === 'leaf');
              assert(tree.terminal === '#A/');
              assert(tree.lines.length === 1);
              return tree;
          Severity: Major
          Found in src/parseBundle.js and 1 other location - About 1 hr to fix
          src/parseBundle.js on lines 515..520

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

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

          const lines = async function* (documents) {
              for await (const {header, reports, footer} of documents) {
                  console.debug(JSON.stringify({header, reports, footer}, undefined, 2));
                  if (header.kind === 'lab') {
                      yield* header.lab.identifier.lines;
          Severity: Minor
          Found in src/stringifyBundle.js - About 1 hr to fix

            Function parseBlockBody has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const parseBlockBody = (type, tree) => {
                assert(tree.type === 'leaf');
                assert(tree.terminal === 'R-body');
                if (type === 'c') {
                    return {
            Severity: Minor
            Found in src/parseBundle.js - About 1 hr to fix

              Function parseIntensity has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const parseIntensity = (symbol) => {
                  switch (symbol) {
                      case '--':
                      case 'LL':
                      case '1': {
              Severity: Minor
              Found in src/parseBundle.js - About 1 hr to fix

                Function parseReport has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const parseReport = async (report) => {
                    assert(report.type === 'node');
                    assert(report.nonterminal === 'A');
                    const it = iter(report.children);
                    const identifier = parseReportIdentifier(await next(it));
                Severity: Minor
                Found in src/parseBundle.js - About 1 hr to fix

                  Function lines has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const lines = async function* (documents) {
                      for await (const {header, reports, footer} of documents) {
                          console.debug(JSON.stringify({header, reports, footer}, undefined, 2));
                          if (header.kind === 'lab') {
                              yield* header.lab.identifier.lines;
                  Severity: Minor
                  Found in src/stringifyBundle.js - About 55 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

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

                      if (type === 'c') {
                          return {
                              ...tree,
                              parsed: {
                                  comments: tree.lines.map(({contents}) => contents),
                  Severity: Minor
                  Found in src/parseBundle.js and 1 other location - About 50 mins to fix
                  src/parseBundle.js on lines 143..150

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

                  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 (type === 'b') {
                          return {
                              ...tree,
                              parsed: {
                                  text: tree.lines.map(({contents}) => contents),
                  Severity: Minor
                  Found in src/parseBundle.js and 1 other location - About 50 mins to fix
                  src/parseBundle.js on lines 134..141

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language