html-to-text/node-html-to-text

View on GitHub

Showing 55 of 85 total issues

Avoid deeply nested control flow statements.
Open

          for (let j = 0; j < cell.lines.length; j++) {
            const line = cell.lines[j];
            const lineOffset = rowOffsets[y] + j;
            outputLines[lineOffset] = (outputLines[lineOffset] || '').padEnd(colOffsets[x]) + line;
            cellWidth = (line.length > cellWidth) ? line.length : cellWidth;
Severity: Major
Found in packages/html-to-text/src/table-printer.js - About 45 mins to fix

    Function renderRowsFirst has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function renderRowsFirst (layout, colNumber, rowNumber) {
      const outputLines = [];
      for (let x = 0; x < colNumber; x++) {
        for (let y = 0; y < rowNumber; y++) {
          const cell = layout[x][y];
    Severity: Minor
    Found in packages/html-to-md/src/table-printer.js - About 45 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

    Avoid deeply nested control flow statements.
    Open

                if (word.length > this.maxLineLength) {
                  continue;
                }
    Severity: Major
    Found in packages/base/src/inline-text-builder.js - About 45 mins to fix

      Function formatList has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function formatList (elem, walk, builder, formatOptions, nextPrefixCallback) {
      Severity: Minor
      Found in packages/html-to-text/src/text-formatters.js - About 35 mins to fix

        Function pathRewrite has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function pathRewrite (path, rewriter, baseUrl, metadata, elem) {
        Severity: Minor
        Found in packages/html-to-md/src/md-formatters.js - About 35 mins to fix

          Function pathRewrite has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function pathRewrite (path, rewriter, baseUrl, metadata, elem) {
          Severity: Minor
          Found in packages/html-to-text/src/text-formatters.js - About 35 mins to fix

            Function formatList has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function formatList (elem, walk, builder, formatOptions, nextPrefixCallback) {
            Severity: Minor
            Found in packages/html-to-md/src/md-formatters.js - About 35 mins to fix

              Function renderRowsRepeat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function renderRowsRepeat (layout, colNumber, rowNumber) {
                const outputLines = [];
                for (let x = 0; x < colNumber; x++) {
                  for (let y = 0; y < rowNumber; y++) {
                    const cell = layout[x][y];
              Severity: Minor
              Found in packages/html-to-md/src/table-printer.js - About 35 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 transposeInPlace has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function transposeInPlace (matrix, maxSize) {
                for (let i = 0; i < maxSize; i++) {
                  const rowI = getRow(matrix, i);
                  for (let j = 0; j < i; j++) {
                    const rowJ = getRow(matrix, j);
              Severity: Minor
              Found in packages/html-to-text/src/table-printer.js - About 35 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 formatAnchor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function formatAnchor (elem, walk, builder, formatOptions) {
                const attribs = elem.attribs || {};
                if (attribs.name && !attribs.href) {
                  builder.startNoWrap();
                  builder.addInline(
              Severity: Minor
              Found in packages/html-to-md/src/md-formatters.js - About 35 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 formatImage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function formatImage (elem, walk, builder, formatOptions) {
                const attribs = elem.attribs || {};
                const alt = (attribs.alt)
                  ? attribs.alt
                  : '';
              Severity: Minor
              Found in packages/html-to-text/src/text-formatters.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 recursiveWalk has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function recursiveWalk (walk, dom, builder) {
                if (!dom) { return; }
              
                const options = builder.options;
              
              
              Severity: Minor
              Found in packages/base/src/index.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 formatDefinitionList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function formatDefinitionList (elem, walk, builder, formatOptions) {
                const groups = collectDefinitionGroups(elem);
                for (const group of groups) {
                  builder.openList({
                    interRowLineBreaks: 1,
              Severity: Minor
              Found in packages/html-to-md/src/md-formatters.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 trimCharacter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function trimCharacter (str, char) {
                let start = 0;
                let end = str.length;
                while (start < end && str[start] === char) { ++start; }
                while (end > start && str[end - 1] === char) { --end; }
              Severity: Minor
              Found in packages/base/src/util.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 formatImage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function formatImage (elem, walk, builder, formatOptions) {
                const attribs = elem.attribs || {};
                if (attribs.src && attribs.src.startsWith('data:')) {
                  builder.startNoWrap();
                  builder.addInline(
              Severity: Minor
              Found in packages/html-to-md/src/md-formatters.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