SimenB/stylint

View on GitHub

Showing 133 of 133 total issues

Function setState has a Cognitive Complexity of 15 (exceeds 5 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

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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        it( 'true if line has a zero before a decimal point and', function() {
            assert.ok( zeroTest( 'color (0, 0, 0, 0.18)' ) )
            assert.ok( zeroTest( 'color (0,0,0,0.18)' ) )
            assert.ok( zeroTest( 'transform rotate(0.33deg)' ) )
            assert.ok( zeroTest( 'transform rotate( 0.33deg )' ) )
Severity: Major
Found in test/test.js and 2 other locations - About 1 hr to fix
test/test.js on lines 1328..1333
test/test.js on lines 1783..1788

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 73.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        it( 'true if $ is found and is correct', function() {
            assert.ok( varTest( '$my-var = 0' ) )
            assert.ok( varTest( '$first-value = floor( (100% / $columns) * $index )' ) )
            assert.ok( varTest( '$-my-private-var = red' ) )
            assert.ok( varTest( '$_myPrivateVar = red' ) )
Severity: Major
Found in test/test.js and 2 other locations - About 1 hr to fix
test/test.js on lines 1328..1333
test/test.js on lines 1375..1380

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 73.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        it( 'true if line has a zero before a decimal point and not part of range', function() {
            assert.ok( zeroTest( 'color (0, 0, 0, 0.18)' ) )
            assert.ok( zeroTest( 'color (0,0,0,0.18)' ) )
            assert.ok( zeroTest( 'transform rotate(0.33deg)' ) )
            assert.ok( zeroTest( 'transform rotate( 0.33deg )' ) )
Severity: Major
Found in test/test.js and 2 other locations - About 1 hr to fix
test/test.js on lines 1375..1380
test/test.js on lines 1783..1788

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 73.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function reporter has a Cognitive Complexity of 14 (exceeds 5 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

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 41 lines of code (exceeds 25 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

    Function quotePref has a Cognitive Complexity of 13 (exceeds 5 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

    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 sortOrder has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    var sortOrder = function( line ) {
        // we don't alphabetize the root yet
        if ( this.state.context === 0 || this.state.hash ) {
            this.cache.sortOrderCache = []
            return
    Severity: Minor
    Found in src/checks/sortOrder.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 valid has 39 lines of code (exceeds 25 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

      Function Stylint has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var Stylint = function( path, config, callback ) {
          return stampit().compose(
              require( './src/core/' ),
              require( './src/checks/' ),
              require( './src/state/' ),
      Severity: Minor
      Found in index.js - About 1 hr to fix

        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 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 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  it( 'return app.parse if passed directory', function() {
                      app.getFiles( '/styl' )
                      app.getFiles.getCall( 0 ).returned( sinon.match.same( app.parse ) )
                  } )
          Severity: Major
          Found in test/test.js and 1 other location - About 1 hr to fix
          test/test.js on lines 414..417

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 63.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    it( 'return app.parse if passed filename', function() {
                        app.getFiles( '/styl/test2.styl' )
                        app.getFiles.getCall( 1 ).returned( sinon.match.same( app.parse ) )
                    } )
            Severity: Major
            Found in test/test.js and 1 other location - About 1 hr to fix
            test/test.js on lines 409..412

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 63.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 7 locations. Consider refactoring.
            Open

                    it( 'false if range', function() {
                        assert.equal( undefined, zeroTest( 'for 0..9' ) )
                        assert.equal( undefined, zeroTest( 'for 0...9' ) )
                        assert.equal( undefined, zeroTest( 'for $ in (0..9)' ) )
                    } )
            Severity: Major
            Found in test/test.js and 6 other locations - About 1 hr to fix
            test/test.js on lines 708..712
            test/test.js on lines 1335..1339
            test/test.js on lines 1341..1345
            test/test.js on lines 1347..1351
            test/test.js on lines 1382..1386
            test/test.js on lines 1883..1887

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 7 locations. Consider refactoring.
            Open

                    it( 'undefined if range', function() {
                        assert.equal( undefined, zeroTest( 'for 0..9' ) )
                        assert.equal( undefined, zeroTest( 'for 0...9' ) )
                        assert.equal( undefined, zeroTest( 'for $ in (0..9)' ) )
                    } )
            Severity: Major
            Found in test/test.js and 6 other locations - About 1 hr to fix
            test/test.js on lines 708..712
            test/test.js on lines 1341..1345
            test/test.js on lines 1347..1351
            test/test.js on lines 1369..1373
            test/test.js on lines 1382..1386
            test/test.js on lines 1883..1887

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 7 locations. Consider refactoring.
            Open

                    it( 'undefined if no .\d in line', function() {
                        assert.equal( undefined, zeroTest( 'margin auto' ) )
                        assert.equal( undefined, zeroTest( '.className' ) )
                        assert.equal( undefined, zeroTest( '.class.other-class' ) )
                    } )
            Severity: Major
            Found in test/test.js and 6 other locations - About 1 hr to fix
            test/test.js on lines 708..712
            test/test.js on lines 1335..1339
            test/test.js on lines 1341..1345
            test/test.js on lines 1369..1373
            test/test.js on lines 1382..1386
            test/test.js on lines 1883..1887

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language