masnagam/npm-diet

View on GitHub

Showing 16 of 16 total issues

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

  dup.packages.slice(1)
    .forEach((pkg) => utils.appendRow(table, columns, {
      label: utils.formatPackageSpecifier(pkg),
      size: utils.formatSize(pkg.size),
      pct: utils.formatPercent(pkg.size, analysis.size),
Severity: Major
Found in lib/show/duplicate.js and 1 other location - About 2 hrs to fix
lib/show/measure.js on lines 85..92

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

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

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

  sorted
    .forEach((pkg) => utils.appendRow(table, columns, {
      label: utils.formatPackageSpecifier(pkg),
      size: utils.formatSize(pkg.size),
      pct: utils.formatPercent(pkg.size, analysis.size),
Severity: Major
Found in lib/show/measure.js and 1 other location - About 2 hrs to fix
lib/show/duplicate.js on lines 48..55

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

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

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

  utils.appendRow(table, columns, {
    label: red(`TOTAL ${analysis.packages.length}`),
    size: red(utils.formatSize(analysis.size)),
    numFiles: red(analysis.numFiles),
  }, PADDINGS);
Severity: Major
Found in lib/show/measure.js and 1 other location - About 2 hrs to fix
lib/show/delta.js on lines 128..132

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

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

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

  utils.appendRow(table, columns, {
    label: red(`TOTAL ${analysis.packages.length}`),
    size: red(utils.formatSize(analysis.size)),
    numFiles: red(analysis.numFiles)
  }, PADDINGS);
Severity: Major
Found in lib/show/delta.js and 1 other location - About 2 hrs to fix
lib/show/measure.js on lines 108..112

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

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

function details(analysis, options) {
  const sorted = Array.from(analysis.packages).sort((a, b) => b.size - a.size);

  const trunc = options.top !== undefined && sorted.length > options.top;
  if (trunc) {
Severity: Minor
Found in lib/show/measure.js - About 1 hr to fix

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

        utils.appendRow(table, columns, {
          label: yellow(sumTitle),
          size: yellow(utils.formatSize(sumSize)),
          pct: yellow(utils.formatPercent(sumSize, analysis.size)),
          numFiles: yellow(sumNumFiles)
    Severity: Major
    Found in lib/show/delta.js and 1 other location - About 1 hr to fix
    lib/show/measure.js on lines 100..105

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

    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

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

        utils.appendRow(table, columns, {
          label: yellow(sumTitle),
          size: yellow(utils.formatSize(sumSize)),
          pct: yellow(utils.formatPercent(sumSize, analysis.size)),
          numFiles: yellow(sumNumFiles)
    Severity: Major
    Found in lib/show/measure.js and 1 other location - About 1 hr to fix
    lib/show/delta.js on lines 120..125

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

    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

      utils.appendRow(table, columns, {
        label: `BASELINE (${baselineSpecs.join(' ')})`,
        numPkgs: baseline.numPkgs,
        size: utils.formatSize(baseline.size),
        numFiles: baseline.numFiles
    Severity: Major
    Found in lib/show/delta.js and 1 other location - About 1 hr to fix
    lib/show/delta.js on lines 58..63

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

    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

      utils.appendRow(table, columns, {
        label: `SUBJECT (${subjectSpecs.join(' ')})`,
        numPkgs: subject.numPkgs,
        size: utils.formatSize(subject.size),
        numFiles: subject.numFiles
    Severity: Major
    Found in lib/show/delta.js and 1 other location - About 1 hr to fix
    lib/show/delta.js on lines 50..55

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

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

    function showTable(table, columns, title, baseline, analysis, options, top) {
      if (analysis.packages.length === 0) {
        return;
      }
    
    
    Severity: Minor
    Found in lib/show/delta.js - About 1 hr to fix

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

      function showTable_(table, columns, dup, analysis, options) {
        utils.appendRow(table, columns, {
          label: red('PACKAGE'),
          size: red('SIZE'),
          pct: red('%SIZE'),
      Severity: Minor
      Found in lib/show/duplicate.js - About 1 hr to fix

        Function normalizeSpecs_ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function normalizeSpecs_(specs) {
          let normalized = [];
          for (const spec of specs) {
            if (spec.name.startsWith('_')) {
              const name = spec.name.slice(1);
        Severity: Minor
        Found in lib/analyze/measure.js - About 1 hr 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

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

          utils.appendRow(table, columns, {
            label: red('PACKAGE'),
            size: red('SIZE'),
            pct: red('%SIZE'),
            numFiles: red('#FILES'),
        Severity: Major
        Found in lib/show/measure.js and 1 other location - About 1 hr to fix
        lib/show/duplicate.js on lines 22..28

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

        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

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

          utils.appendRow(table, columns, {
            label: red('PACKAGE'),
            size: red('SIZE'),
            pct: red('%SIZE'),
            numFiles: red('#FILES'),
        Severity: Major
        Found in lib/show/duplicate.js and 1 other location - About 1 hr to fix
        lib/show/measure.js on lines 69..75

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

        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 showTable has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function showTable(table, columns, title, baseline, analysis, options, top) {
        Severity: Major
        Found in lib/show/delta.js - About 50 mins to fix

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

          function showTable_(table, columns, dup, analysis, options) {
          Severity: Minor
          Found in lib/show/duplicate.js - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language