mangroveorg/datawinners

View on GitHub
datawinners/media/javascript/jquery.sprintf.js

Summary

Maintainability
F
1 wk
Test Coverage

Function jQuery_vsprintf has a Cognitive Complexity of 191 (exceeds 5 allowed). Consider refactoring.
Open

jQuery.vsprintf = function jQuery_vsprintf( format, args ) {
    if( format == null ) {
        throw "Not enough arguments for vsprintf";
    }
    if( args == null ) {
Severity: Minor
Found in datawinners/media/javascript/jquery.sprintf.js - About 3 days 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 jQuery_vsprintf has 345 lines of code (exceeds 25 allowed). Consider refactoring.
Open

jQuery.vsprintf = function jQuery_vsprintf( format, args ) {
    if( format == null ) {
        throw "Not enough arguments for vsprintf";
    }
    if( args == null ) {
Severity: Major
Found in datawinners/media/javascript/jquery.sprintf.js - About 1 day to fix

    File jquery.sprintf.js has 414 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * jQuery sprintf - perl based functionallity for sprintf and friends.
     *
     * Copyright © 2008 Carl Fürstenberg
     *
    Severity: Minor
    Found in datawinners/media/javascript/jquery.sprintf.js - About 5 hrs to fix

      Function _sprintf_format has 145 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function _sprintf_format( type, value, flags ) {
      
              // Similar to how perl printf works
              if( value == undefined ) {
                  if( type == 's' ) {
      Severity: Major
      Found in datawinners/media/javascript/jquery.sprintf.js - About 5 hrs to fix

        Avoid deeply nested control flow statements.
        Open

                            if( value >= 4294967295 ) {
                                value = 4294967295;
                            } 
        Severity: Major
        Found in datawinners/media/javascript/jquery.sprintf.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          } else if( precision ) {
                              flags['precision'] = num;
                              precision = false;
                          } else if( bitwidth ) {
                              flags['bitwidth'] = num;
          Severity: Major
          Found in datawinners/media/javascript/jquery.sprintf.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            if( !fixed ) {
                                current_index++;
                            }
            Severity: Major
            Found in datawinners/media/javascript/jquery.sprintf.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if( num < 0 || num > args.length ) {
                                      throw "out of bound";
                                  }
              Severity: Major
              Found in datawinners/media/javascript/jquery.sprintf.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if( value instanceof Array ) {
                                        // if the value is an array, assume to work on it directly
                                        fixed_value = value;
                                    } else if ( typeof(value) == 'string' || value instanceof String ) {
                                        // normal behavour, assume string is a bitmap
                Severity: Major
                Found in datawinners/media/javascript/jquery.sprintf.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                  if( precision ) {
                                      flags['precision'] = args[current_index];
                                      precision = false;
                                  } else if( format.charAt( i + 1 ) == 'v' ) {
                                      vector_delimiter = args[current_index];
                  Severity: Major
                  Found in datawinners/media/javascript/jquery.sprintf.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if( value >= 18446744073709551615 ) {
                                            value = 18446744073709551615;
                                        } 
                    Severity: Major
                    Found in datawinners/media/javascript/jquery.sprintf.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if( relative ) {
                                              if( precision ) {
                                                  flags['precision'] = args[num - 1];
                                                  precision = false;
                                              } else if( format.charAt( i + 2 ) == 'v' ) {
                      Severity: Major
                      Found in datawinners/media/javascript/jquery.sprintf.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if( value >= 2147483647 ) {
                                                value = 2147483647;
                                            } else if( value <= -2147483647-1 ) {
                                                value = -2147483647-1;
                                            }
                        Severity: Major
                        Found in datawinners/media/javascript/jquery.sprintf.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if( value >= 9223372036854775807 ) {
                                                  value = 9223372036854775807;
                                              } else if( value <= -9223372036854775807-1 ) {
                                                  value = -9223372036854775807-1;
                                              }
                          Severity: Major
                          Found in datawinners/media/javascript/jquery.sprintf.js - About 45 mins to fix

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

                                    case 'G':
                                        var digits = flags['precision'] ? flags['precision'] : 6;
                                        result = (new Number( value ) ).toPrecision( digits ).toString().toUpperCase();
                                        break;
                            Severity: Major
                            Found in datawinners/media/javascript/jquery.sprintf.js and 1 other location - About 1 hr to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 208..211

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

                            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 2 locations. Consider refactoring.
                            Open

                                    case 'E':
                                        var digits = flags['precision'] ? flags['precision'] : 6;
                                        result = (new Number( value ) ).toExponential( digits ).toString().toUpperCase();
                                        break;
                            Severity: Major
                            Found in datawinners/media/javascript/jquery.sprintf.js and 1 other location - About 1 hr to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 212..215

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

                            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 2 locations. Consider refactoring.
                            Open

                                    if(flags['+'] && parseFloat( value ) > 0 && ['d','e','f','g','E','G'].indexOf(type) != -1 ) {
                                        prefix = '+';
                                    }
                            Severity: Major
                            Found in datawinners/media/javascript/jquery.sprintf.js and 1 other location - About 1 hr to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 222..224

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

                            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 2 locations. Consider refactoring.
                            Open

                                    if(flags[' '] && parseFloat( value ) > 0 && ['d','e','f','g','E','G'].indexOf(type) != -1 ) {
                                        prefix = ' ';
                                    }
                            Severity: Major
                            Found in datawinners/media/javascript/jquery.sprintf.js and 1 other location - About 1 hr to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 218..220

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

                            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

                                return this.each( function() { 
                                        self = jQuery(this);
                                        self.html(  jQuery.vsprintf( self.html(), args ) )
                                    }
                                ); 
                            Severity: Minor
                            Found in datawinners/media/javascript/jquery.sprintf.js and 1 other location - About 55 mins to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 551..555

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

                            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

                                return this.each( function() { 
                                        self = jQuery(this);
                                        self.html(  jQuery.vsprintf( self.html(), args ) )
                                    }
                                ); 
                            Severity: Minor
                            Found in datawinners/media/javascript/jquery.sprintf.js and 1 other location - About 55 mins to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 575..579

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

                            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 2 locations. Consider refactoring.
                            Open

                                            if( flags['short'] ) {
                                                if( value >= 32767 ) {
                                                    value = 32767;
                                                } else if( value <= -32767-1 ) {
                                                    value = -32767-1;
                            Severity: Minor
                            Found in datawinners/media/javascript/jquery.sprintf.js and 1 other location - About 55 mins to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 128..140

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

                            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 2 locations. Consider refactoring.
                            Open

                                            } else if ( flags['long'] ) {
                                                if( value >= 2147483647 ) {
                                                    value = 2147483647;
                                                } else if( value <= -2147483647-1 ) {
                                                    value = -2147483647-1;
                            Severity: Minor
                            Found in datawinners/media/javascript/jquery.sprintf.js and 1 other location - About 55 mins to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 122..140

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

                            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

                                    case 'e':
                                        var digits = flags['precision'] ? flags['precision'] : 6;
                                        result = (new Number( value ) ).toExponential( digits ).toString();
                                        break;
                            Severity: Major
                            Found in datawinners/media/javascript/jquery.sprintf.js and 2 other locations - About 50 mins to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 197..200
                            datawinners/media/javascript/jquery.sprintf.js on lines 201..204

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

                            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

                                    case 'g':
                                        var digits = flags['precision'] ? flags['precision'] : 6;
                                        result = (new Number( value ) ).toPrecision( digits ).toString();
                                        break;
                            Severity: Major
                            Found in datawinners/media/javascript/jquery.sprintf.js and 2 other locations - About 50 mins to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 193..196
                            datawinners/media/javascript/jquery.sprintf.js on lines 197..200

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

                            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

                                    case 'f':
                                        var digits = flags['precision'] ? flags['precision'] : 6;
                                        result = (new Number( value ) ).toFixed( digits ).toString();
                                        break;
                            Severity: Major
                            Found in datawinners/media/javascript/jquery.sprintf.js and 2 other locations - About 50 mins to fix
                            datawinners/media/javascript/jquery.sprintf.js on lines 193..196
                            datawinners/media/javascript/jquery.sprintf.js on lines 201..204

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

                            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

                            There are no issues that match your filters.

                            Category
                            Status