SimenB/stylint

View on GitHub

Showing 48 of 133 total issues

Function reporter has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var reporter = function( msg, done, kill ) {
    if ( done === 'done' ) {
        // total errors
        this.cache.msg = 'Stylint: ' + this.cache.errs.length + ' Errors.'
        this.cache.msg += this.config.maxErrors ? ' (Max Errors: ' + this.config.maxErrors + ')' : ''
Severity: Minor
Found in src/core/reporter.js - About 1 hr to fix

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

    var parenSpace = function( line, origLine ) {
        if ( !parensRe.test( origLine ) ) { return }
    
        var hasStartSpace = parensBeginWithSpaceRe.exec( origLine )
        var hasEndSpace = parensEndWithSpaceRe.exec( origLine )
    Severity: Minor
    Found in src/checks/parenSpace.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 prefixVarsWithDollar has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    var prefixVarsWithDollar = function( line ) {
        if ( this.state.hashOrCSS || ignoreRe.test( line ) ) { return }
    
        var hasDolla = true
    
    
    Severity: Minor
    Found in src/checks/prefixVarsWithDollar.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 duplicates has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    var duplicates = function( line ) {
        var arr = this.splitAndStrip( new RegExp( /[\s\t]/ ), line )
        var dupe = false
        var dupeIndex
        var origFile
    Severity: Minor
    Found in src/checks/duplicates.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 setState has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var setState = function( line ) {
        this.state.context = this.setContext( this.cache.line )
    
        // ignore the current line if @stylint ignore
        if ( this.cache.origLine.indexOf( '@stylint ignore' ) !== -1 ) {
    Severity: Minor
    Found in src/core/setState.js - About 1 hr to fix

      Function getFiles has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var getFiles = function( dir ) {
          if ( typeof dir !== 'string' && !( dir instanceof Array ) ) {
              throw new TypeError( 'getFiles err. Expected string or array, but received: ' + typeof dir )
          }
      
      
      Severity: Minor
      Found in src/utils/getFiles.js - About 1 hr to fix

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

        module.exports = function valid( line ) {
            // from and to are valid keyframes properties, but not outside that context
            if ( !this.state.keyframes && line.match( keyRe ) ) { return }
        
            // 1 split by tabs and spaces, tabs mess with pattern matching
        Severity: Minor
        Found in src/checks/valid.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 colons has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var colons = function( line ) {
            if ( ignoreRe.test( line ) || this.state.context === 0 ) { return }
        
            var colon
            var hasPseudo = false
        Severity: Minor
        Found in src/checks/colons.js - About 1 hr to fix

          Function read has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var read = function( filepath ) {
              // if user passes in a glob, we forEach over them
              // and pass it into read() as filepath
              var path = filepath || this.state.path
          
          
          Severity: Minor
          Found in src/core/read.js - About 1 hr to fix

            Function semicolons has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            var semicolons = function( line ) {
                if ( ignoreRe.test( line.trim() ) ) return
                if ( this.state.hashOrCss ) return
            
                var semicolon
            Severity: Minor
            Found in src/checks/semicolons.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 efficient has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            var efficient = function( line ) {
                // line doesnt have margin or padding then there's nothin to do here
                if ( !valueRe.test( line ) ) { return }
            
                var isEfficient = true
            Severity: Minor
            Found in src/checks/efficient.js - About 1 hr to fix

              Function quotePref has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var quotePref = function( line, origLine ) {
                  if ( origLine.indexOf( '"' ) === -1 &&
                          origLine.indexOf( "'" ) === -1 ) {
                      return
                  }
              Severity: Minor
              Found in src/checks/quotePref.js - About 1 hr to fix

                Function colons has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                var colons = function( line ) {
                    if ( ignoreRe.test( line ) || this.state.context === 0 ) { return }
                
                    var colon
                    var hasPseudo = false
                Severity: Minor
                Found in src/checks/colons.js - About 55 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

                Function getExitCode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function getExitCode( errsLength, warningsLength, maxErrors, maxWarnings ) {
                    if ( errsLength > 0 ) {
                        if ( typeof maxErrors === 'number' ) {
                            if ( errsLength > maxErrors ) return 1
                        }
                Severity: Minor
                Found in src/core/done.js - About 45 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

                Avoid deeply nested control flow statements.
                Open

                            else if ( this.state.conf === 'lowercase-dash' ) {
                                // if no - present, or _ present, or A-Z present
                                if ( arr[0].indexOf( '-' ) === -1 ||
                                    arr[0].indexOf( '_' ) !== -1 ||
                                    upperRe.test( arr[0] ) ) {
                Severity: Major
                Found in src/checks/namingConvention.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                  if ( arr[0].indexOf( '-' ) !== -1 ||
                                      arr[0].indexOf( '_' ) === -1 ||
                                      upperRe.test( arr[0] ) ) {
                                      badConvention = true
                                  }
                  Severity: Major
                  Found in src/checks/namingConvention.js - About 45 mins to fix

                    Function mixed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    var mixed = function( line, origLine ) {
                        var trimRight = origLine.replace( trimRightRe, '' )
                        var isMixed = false
                        var indentPref = this.config.indentPref.expect || this.config.indentPref
                        var isNum = typeof indentPref === 'number'
                    Severity: Minor
                    Found in src/checks/mixed.js - About 45 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

                    Consider simplifying this complex logical expression.
                    Open

                        if ( this.state.hashOrCSS || // 1
                            this.state.root || // 1
                            interpolatedRe.test( this.cache.origLine ) ||
                            ignoreRe.test( line.trim() ) || // 2
                            attrOrMixinRe.test( line ) || // 3
                    Severity: Major
                    Found in src/checks/valid.js - About 40 mins to fix

                      Function zeroUnits has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      var zeroUnits = function( line ) {
                          // if in keyframes dont check
                          // if no 0 on line dont check
                          // if relative values like font-weight, dont check
                          if ( this.state.keyframes ||
                      Severity: Minor
                      Found in src/checks/zeroUnits.js - About 35 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

                      Function blocks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      var blocks = function( line ) {
                          if ( line.indexOf( '=' ) === -1 ) { return }
                      
                          var block
                          var index = line.indexOf( '@block' )
                      Severity: Minor
                      Found in src/checks/blocks.js - About 35 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