t32k/stylestats

View on GitHub

Showing 9 of 21 total issues

Function analyze has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

  analyze() {
    // Get analytics
    const ruleAnalysis = this.analyzeRules();
    const selectorAnalysis = this.analyzeSelectors();
    const declarationAnalysis = this.analyzeDeclarations();
Severity: Minor
Found in lib/analyzer.js - About 4 hrs 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 parse has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  parse() {
    // Object to return
    const parsedData = {
      cssString: '',
      cssSize: 0,
Severity: Major
Found in lib/parser.js - About 4 hrs to fix

    Function analyze has 98 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      analyze() {
        // Get analytics
        const ruleAnalysis = this.analyzeRules();
        const selectorAnalysis = this.analyzeSelectors();
        const declarationAnalysis = this.analyzeDeclarations();
    Severity: Major
    Found in lib/analyzer.js - About 3 hrs to fix

      Function analyzeDeclarations has 95 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        analyzeDeclarations() {
          // Object to return
          const result = {
            dataUriSize: '',
            importantKeywords: 0,
      Severity: Major
      Found in lib/analyzer.js - About 3 hrs to fix

        File analyzer.js has 280 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        const gzipSize = require('gzip-size');
        
        class Analyzer {
          /**
           * @param {Array} rules
        Severity: Minor
        Found in lib/analyzer.js - About 2 hrs to fix

          Function analyzeSelectors has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            analyzeSelectors() {
              // Object to return
              const result = {
                idSelectors: 0,
                universalSelectors: 0,
          Severity: Minor
          Found in lib/analyzer.js - About 1 hr to fix

            Function constructor has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              constructor(args, config) {
                args = Array.isArray(args) ? args : [args];
                this.urls = [];
                this.files = [];
                this.styles = [];
            Severity: Minor
            Found in lib/stylestats.js - About 1 hr to fix

              Function prettify has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function prettify(result) {
                const collection = {};
              
                Object.keys(result).forEach(key => {
                  const readableKey = aliases[key];
              Severity: Minor
              Found in lib/prettify.js - About 1 hr to fix

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

                  constructor(args, config) {
                    args = Array.isArray(args) ? args : [args];
                    this.urls = [];
                    this.files = [];
                    this.styles = [];
                Severity: Minor
                Found in lib/stylestats.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