codenautas/best-globals

View on GitHub

Showing 37 of 37 total issues

File best-globals.js has 983 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";

(function codenautasModuleDefinition(root, name, factory) {
    /* global define */
    /* istanbul ignore next */
Severity: Major
Found in best-globals.js - About 2 days to fix

    Function TimeInterval has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    bestGlobals.TimeInterval = function TimeInterval(timePack){
        /* istanbul ignore next */
        if(typeof timePack === 'number'){
            timePack={ms:timePack};
            console.log('|-----------------------------|');
    Severity: Major
    Found in best-globals.js - About 3 hrs to fix

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

          var prune = function(what){
              if(str.substr(str.length-what.length)==what){
                  str=str.substr(0,str.length-what.length);
                  return true;
              }
      Severity: Major
      Found in best-globals.js and 1 other location - About 2 hrs to fix
      best-globals.js on lines 483..489

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

      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

          var prune = function(what){
              if(str.substr(str.length-what.length)==what){
                  str=str.substr(0,str.length-what.length);
                  return true;
              }
      Severity: Major
      Found in best-globals.js and 1 other location - About 2 hrs to fix
      best-globals.js on lines 505..511

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

      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 registerJson4All has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      bestGlobals.registerJson4All = function registerJson4All(JSON4all){
          JSON4all.addType(Date, {
              specialTag: function specialTag(value){
                  if(value.isRealDate){
                      return 'date';
      Severity: Major
      Found in best-globals.js - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

            if(h<0 || m<0 || s<0 || ms<0 || h>23 || m>59 || s>59 || ms>999 || micros<0 || micros>999) { return false; }
        Severity: Critical
        Found in best-globals.js - About 2 hrs to fix

          Function has too many statements (102). Maximum allowed is 100.
          Open

          })(/*jshint -W040 */this, 'bestGlobals', function() {
          Severity: Minor
          Found in best-globals.js by eslint

          enforce a maximum number of statements allowed in function blocks (max-statements)

          The max-statements rule allows you to specify the maximum number of statements allowed in a function.

          function foo() {
            var bar = 1; // one statement
            var baz = 2; // two statements
            var qux = 3; // three statements
          }

          Rule Details

          This rule enforces a maximum number of statements allowed in function blocks.

          Options

          This rule has a number or object option:

          • "max" (default 10) enforces a maximum number of statements allows in function blocks

          Deprecated: The object property maximum is deprecated; please use the object property max instead.

          This rule has an object option:

          • "ignoreTopLevelFunctions": true ignores top-level functions

          max

          Examples of incorrect code for this rule with the default { "max": 10 } option:

          /*eslint max-statements: ["error", 10]*/
          /*eslint-env es6*/
          
          function foo() {
            var foo1 = 1;
            var foo2 = 2;
            var foo3 = 3;
            var foo4 = 4;
            var foo5 = 5;
            var foo6 = 6;
            var foo7 = 7;
            var foo8 = 8;
            var foo9 = 9;
            var foo10 = 10;
          
            var foo11 = 11; // Too many.
          }
          
          let foo = () => {
            var foo1 = 1;
            var foo2 = 2;
            var foo3 = 3;
            var foo4 = 4;
            var foo5 = 5;
            var foo6 = 6;
            var foo7 = 7;
            var foo8 = 8;
            var foo9 = 9;
            var foo10 = 10;
          
            var foo11 = 11; // Too many.
          };

          Examples of correct code for this rule with the default { "max": 10 } option:

          /*eslint max-statements: ["error", 10]*/
          /*eslint-env es6*/
          
          function foo() {
            var foo1 = 1;
            var foo2 = 2;
            var foo3 = 3;
            var foo4 = 4;
            var foo5 = 5;
            var foo6 = 6;
            var foo7 = 7;
            var foo8 = 8;
            var foo9 = 9;
            var foo10 = 10;
            return function () {
          
              // The number of statements in the inner function does not count toward the
              // statement maximum.
          
              return 42;
            };
          }
          
          let foo = () => {
            var foo1 = 1;
            var foo2 = 2;
            var foo3 = 3;
            var foo4 = 4;
            var foo5 = 5;
            var foo6 = 6;
            var foo7 = 7;
            var foo8 = 8;
            var foo9 = 9;
            var foo10 = 10;
            return function () {
          
              // The number of statements in the inner function does not count toward the
              // statement maximum.
          
              return 42;
            };
          }

          ignoreTopLevelFunctions

          Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

          /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
          
          function foo() {
            var foo1 = 1;
            var foo2 = 2;
            var foo3 = 3;
            var foo4 = 4;
            var foo5 = 5;
            var foo6 = 6;
            var foo7 = 7;
            var foo8 = 8;
            var foo9 = 9;
            var foo10 = 10;
            var foo11 = 11;
          }

          Related Rules

          • [complexity](complexity.md)
          • [max-depth](max-depth.md)
          • [max-len](max-len.md)
          • [max-nested-callbacks](max-nested-callbacks.md)
          • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

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

                  deserialize: function deserialize(plainValue){
                      var ok = /^\d{4}-\d\d-\d\d \d\d:\d\d(:\d\d(.\d+)?)?$/.test(plainValue);
                      var value = ok && bestGlobals.datetime.iso(plainValue) || null;
                      return {ok, value};
                  },
          Severity: Major
          Found in best-globals.js and 1 other location - About 1 hr to fix
          best-globals.js on lines 894..898

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

          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

                  deserialize: function deserialize(plainValue){
                      var ok = /^\d{4}-\d\d-\d\d$/.test(plainValue);
                      var value = ok && bestGlobals.date.iso(plainValue) || null;
                      return {ok, value};
                  },
          Severity: Major
          Found in best-globals.js and 1 other location - About 1 hr to fix
          best-globals.js on lines 911..915

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

          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

          bestGlobals.coalesce.throwErrorIfUndefined=function throwErrorIfUndefined(message){
              if(this === bestGlobals.coalesce){
                  return new bestGlobals.coalesce.throwErrorIfUndefined(message);
              }else{
                  this.message=message;
          Severity: Major
          Found in best-globals.js and 1 other location - About 1 hr to fix
          best-globals.js on lines 50..56

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

          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

          bestGlobals.coalesce.throwError=function throwError(message){
              if(this === bestGlobals.coalesce){
                  return new bestGlobals.coalesce.throwError(message);
              }else{
                  this.message=message;
          Severity: Major
          Found in best-globals.js and 1 other location - About 1 hr to fix
          best-globals.js on lines 58..64

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

          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 changing has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function changing(original, changes){
              var opts = changing.retreiveOptions(arguments);
              if (changes instanceof ChangingWithSpecial) {
                  return changes.change(original);
              }
          Severity: Minor
          Found in best-globals.js - About 1 hr to fix

            Function forOrder has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            bestGlobals.forOrder = function forOrder(text){
                if(text==null){
                    return 'zzz(null)';
                }
                if(text instanceof Date){
            Severity: Minor
            Found in best-globals.js - About 1 hr to fix

              Function toHms has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  this.toHms = function toHms(omitSeconds, withDays, omitLeftCeros, omitHourCero, omitFirstLeftCero) {
                      var leftCero = omitLeftCeros?'':'0';
                      var tm = this.timeInterval.ms;
                      var prefix = (tm<0?'-':'');
                      var tdiff = [];
              Severity: Minor
              Found in best-globals.js - About 1 hr to fix

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

                module.exports = function(config, preConfig) {
                  config.set({
                
                    // base path that will be used to resolve all patterns (eg. files, exclude)
                    basePath: '',
                Severity: Minor
                Found in karma.conf.js - About 1 hr to fix

                  Function serie has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  bestGlobals.serie = function serie(NorFirstOrObject, NifNoFirst){
                      var last;
                      var first;
                      var step;
                      var n; 
                  Severity: Minor
                  Found in best-globals.js - About 1 hr to fix

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

                    bestGlobals.dateForceIfNecesary = function dateForceIfNecesary(dt, strict) {
                        if(!strict){
                            if(dt==null) return null;
                        }
                        if(dt.ms == null && ! bestGlobals.date.isOK(dt)) { throw new Error('invalid date'); }
                    Severity: Minor
                    Found in best-globals.js - About 1 hr to fix

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

                      bestGlobals.compareForOrder = function compareForOrder(sortColumns){
                          var thisModule = this || bestGlobals;
                          return function forOrderComparator(row1,row2){
                              var column;
                              var i=0;
                      Severity: Minor
                      Found in best-globals.js - About 1 hr to fix

                        Function ymdHmsMm has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        bestGlobals.datetime.ymdHmsMm = function ymdHmsMm(year, month, day, hour, minutes, seconds, ms, micros){
                        Severity: Major
                        Found in best-globals.js - About 1 hr to fix

                          Function ymdHmsM has 7 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          bestGlobals.datetime.ymdHmsM = function ymdHmsM(y, m, d, hh, mm, ss, ms) {
                          Severity: Major
                          Found in best-globals.js - About 50 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language