prantlf/minified-size

View on GitHub

Showing 8 of 11 total issues

File index.js has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict'

const minifyScriptWithBabel = require('babel-minify')
const { transform: transformWithESBuild } = require('esbuild')
const { minify: minifySwc } = require('@swc/core')
Severity: Minor
Found in lib/index.js - About 3 hrs to fix

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

    function printResult ({ error, file, originalSize, minifiedSize, gzippedSize, brotliedSize }) {
      if (error) {
        printError(file, error)
      } else {
        let sizes = []
    Severity: Minor
    Found in bin/minified-size.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 convertError has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function convertError ({ message, line, col }) {
      const error = { message }
      if (line) {
        error.message = message
        error.reason = message
    Severity: Minor
    Found in lib/index.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 computeTotalSizes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function computeTotalSizes (results) {
      const accumulator = { total: true, originalSize: 0, minifiedSize: 0, gzippedSize: 0, brotliedSize: 0 }
      for (const { error, originalSize, minifiedSize, gzippedSize, brotliedSize } of results) {
        if (!error) {
          accumulator.originalSize += originalSize
    Severity: Minor
    Found in lib/index.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 estimateSizes has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    async function estimateSizes (language, { file, source, size: originalSize, error }, gzip, brotli, minifier, sourceType) {
    Severity: Minor
    Found in lib/index.js - About 45 mins to fix

      Function collectResults has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      async function collectResults (language, generator, gzip, brotli, minifier, sourceType) {
      Severity: Minor
      Found in lib/index.js - About 45 mins to fix

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

        async function minifyByType (file, language, source, minifier, sourceType) {
        Severity: Minor
        Found in lib/index.js - About 35 mins to fix

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

          async function estimateSizes (language, { file, source, size: originalSize, error }, gzip, brotli, minifier, sourceType) {
            if (error) {
              return { file, error: convertError(error) }
            }
            try {
          Severity: Minor
          Found in lib/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

          Severity
          Category
          Status
          Source
          Language