masnagam/npm-diet

View on GitHub

Showing 6 of 16 total issues

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

    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

        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