meteor/meteor

View on GitHub
packages/standard-minifier-css/plugin/minify-css.js

Summary

Maintainability
C
1 day
Test Coverage

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

const mergeCss = Profile("mergeCss", async function (css, postcssConfig) {
  // Filenames passed to AST manipulator mapped to their original files
  const originals = {};
  const deps = [];

Severity: Major
Found in packages/standard-minifier-css/plugin/minify-css.js - About 4 hrs to fix

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

      const newMap = await Profile.time("composing source maps", async function () {
        const newMap = new sourcemap.SourceMapGenerator();
        const concatConsumer = await new sourcemap.SourceMapConsumer(stringifiedCss.map);
        // Create a dictionary of source map consumers for fast access
        const consumers = Object.create(null);
    Severity: Minor
    Found in packages/standard-minifier-css/plugin/minify-css.js - About 1 hr to fix

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

        async minifyFiles (files, mode, postcssConfig) {
          const cacheKey = createCacheKey(files, mode);
          const cachedResult = this.cache.get(cacheKey);
      
          if (
      Severity: Minor
      Found in packages/standard-minifier-css/plugin/minify-css.js - About 1 hr to fix

        Function minifyFiles has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          async minifyFiles (files, mode, postcssConfig) {
            const cacheKey = createCacheKey(files, mode);
            const cachedResult = this.cache.get(cacheKey);
        
            if (
        Severity: Minor
        Found in packages/standard-minifier-css/plugin/minify-css.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 astPromises has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const astPromises = css.map(async function (file) {
            const filename = file.getPathInBundle();
            originals[filename] = file;
        
            let ast;
        Severity: Minor
        Found in packages/standard-minifier-css/plugin/minify-css.js - About 1 hr to fix

          Function mergeCss has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          const mergeCss = Profile("mergeCss", async function (css, postcssConfig) {
            // Filenames passed to AST manipulator mapped to their original files
            const originals = {};
            const deps = [];
          
          
          Severity: Minor
          Found in packages/standard-minifier-css/plugin/minify-css.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

          There are no issues that match your filters.

          Category
          Status