codenothing/CSSCompressor

View on GitHub

Showing 254 of 254 total issues

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

        if ( imports.length ) {
            imports.forEach(function( branch ) {
                CSSCompressor.removeItem( branches, branch );
                branches.splice( pos, 0, branch );
                compressor.log( 'Moving import to the top', branch.position );
Severity: Major
Found in lib/rules/Order Atrules.js and 1 other location - About 1 hr to fix
lib/rules/Order Atrules.js on lines 67..73

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

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

Consider simplifying this complex logical expression.
Open

            if ( match[1] === "nth" ) {
                // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
                var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
                    match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
                    !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
Severity: Critical
Found in demo/rules/js/jquery.js - About 1 hr to fix

    Function callback has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        callback: function( value, position, compressor ) {
            var m = rhsl.exec( value ),
                str = '#',
                h, s, l,
                p, q;
    Severity: Minor
    Found in lib/rules/HSL to Hex.js - About 1 hr to fix

      Function callback has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          callback: function( value, position, compressor ) {
              var m = rrgb.exec( value ),
                  str = '#', values;
      
              if ( m ) {
      Severity: Minor
      Found in lib/rules/RGB to Hex.js - About 1 hr to fix

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

                    if ( branch.branches || branch.rules ) {
        
                        // Add selector
                        css += indent + selector + " {";
        
        
        Severity: Major
        Found in lib/formats/Max.js and 1 other location - About 1 hr to fix
        lib/formats/Medium.js on lines 95..149

        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

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

                    if ( branch.branches || branch.rules ) {
                        css += indent + selector + " {" + ( branch.rules.length ? "\n\t" + indent : '' );
        
                        // Add rules
                        branch.rules.forEach(function( rule, i ) {
        Severity: Major
        Found in lib/formats/Medium.js and 1 other location - About 1 hr to fix
        lib/formats/Max.js on lines 92..144

        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

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

            rule: function( options, type, callback ) {
                var rules = CSSCompressor._rules;
        
                // Passing no arguments returns the entire list
                if ( options === undefined ) {
        Severity: Minor
        Found in lib/Rules.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 data has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            data: function( elem, name, data ) {
                if ( !jQuery.acceptData( elem ) ) {
                    return;
                }
        
        
        Severity: Minor
        Found in demo/rules/js/jquery.js - About 1 hr to fix

          Function each has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              each: function( object, callback, args ) {
                  var name, i = 0,
                      length = object.length,
                      isObj = length === undefined || jQuery.isFunction(object);
          
          
          Severity: Minor
          Found in demo/rules/js/jquery.js - About 1 hr to fix

            Function textSelection has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            jQuery.fn.textSelection = function( start, end ) {
                return this.each(function( i, element ) {
                    var textarea = jQuery( element ),
                        height = textarea.height(),
                        current, caret, ypos, range;
            Severity: Minor
            Found in demo/js/home.js - About 1 hr to fix

              Function removeData has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  removeData: function( elem, name ) {
                      if ( !jQuery.acceptData( elem ) ) {
                          return;
                      }
              
              
              Severity: Minor
              Found in demo/rules/js/jquery.js - About 1 hr to fix

                Function dirCheck has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
                    for ( var i = 0, l = checkSet.length; i < l; i++ ) {
                        var elem = checkSet[i];
                
                        if ( elem ) {
                Severity: Minor
                Found in demo/rules/js/jquery.js - About 1 hr to fix

                  Function callback has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      callback: function( branches, compressor ) {
                          var imports = [], charsets = [], pos = -1;
                  
                          // Find all import and charset declarations (after the first rule filled branch)
                          branches.forEach(function( branch, i ) {
                  Severity: Minor
                  Found in lib/rules/Order Atrules.js - About 1 hr to fix

                    Function callback has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        callback: function( branch, compressor ) {
                            if ( ! branch.selector || ! branch.parts || ! branch.parts.length ) {
                                return;
                            }
                    
                    
                    Severity: Minor
                    Found in lib/rules/Trim Selector Attribute Quotes.js - About 1 hr to fix

                      Function _blocks has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          _blocks: function( branches ) {
                              var self = this,
                                  rules = CSSCompressor.rule( CSSCompressor.RULE_TYPE_RULE ),
                                  blocks = CSSCompressor.rule( CSSCompressor.RULE_TYPE_BLOCK );
                      
                      
                      Severity: Minor
                      Found in lib/CSSCompressor.js - About 1 hr to fix

                        Function setOffset has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            setOffset: function( elem, options, i ) {
                                var position = jQuery.css( elem, "position" );
                        
                                // set position first, in-case top/left are set even on static elem
                                if ( position === "static" ) {
                        Severity: Minor
                        Found in demo/rules/js/jquery.js - About 1 hr to fix

                          Function offset has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              jQuery.fn.offset = function( options ) {
                                  var elem = this[0], box;
                          
                                  if ( options ) { 
                                      return this.each(function( i ) {
                          Severity: Minor
                          Found in demo/rules/js/jquery.js - About 1 hr to fix

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

                                    ATTR: function( elem, match ) {
                                        var name = match[1],
                                            result = Expr.attrHandle[ name ] ?
                                                Expr.attrHandle[ name ]( elem ) :
                                                elem[ name ] != null ?
                            Severity: Minor
                            Found in demo/rules/js/jquery.js - About 1 hr to fix

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

                                  callback: function( branch, compressor ) {
                                      if ( ! branch.selector || ! branch.parts || ! branch.parts.length ) {
                                          return;
                                      }
                              
                              
                              Severity: Minor
                              Found in lib/rules/ID Attribute to Selector.js - About 1 hr to fix

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

                                    callback: function( branch, compressor ) {
                                        if ( ! branch.selector || ! branch.parts || ! branch.parts.length ) {
                                            return;
                                        }
                                
                                
                                Severity: Minor
                                Found in lib/rules/Lowercase Selectors.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language