]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix CodeClimate issues
authorWilliam Entriken <github.com@phor.net>
Mon, 16 Mar 2015 23:14:36 +0000 (19:14 -0400)
committerWilliam Entriken <github.com@phor.net>
Mon, 16 Mar 2015 23:14:36 +0000 (19:14 -0400)
gulpfile.js
src/Chart.Core.js

index e8fe1c7115949d270e577b7604933744147fb9f4..0610135c914f611c3c7dd70cf992c5f4884d97fd 100644 (file)
@@ -24,11 +24,11 @@ var srcDir = './src/';
 gulp.task('build', function(){
 
        // Default to all of the chart types, with Chart.Core first
-       var srcFiles = [FileName('Core')],
+       var srcFiles = [new FileName('Core')],
                isCustom = !!(util.env.types),
                outputDir = (isCustom) ? 'custom' : '.';
        if (isCustom){
-               util.env.types.split(',').forEach(function(type){ return srcFiles.push(FileName(type))});
+               util.env.types.split(',').forEach(function(type){ return srcFiles.push(new FileName(type));});
        }
        else{
                // Seems gulp-concat remove duplicates - nice!
@@ -46,7 +46,7 @@ gulp.task('build', function(){
 
        function FileName(moduleName){
                return srcDir+'Chart.'+moduleName+'.js';
-       };
+       }
 });
 
 /*
@@ -109,7 +109,7 @@ gulp.task('module-sizes', function(){
        .pipe(size({
                showFiles: true,
                gzip: true
-       }))
+       }));
 });
 
 gulp.task('watch', function(){
index 6fa0af7629824c3a8aaccbaafa1bcab69ed1e9c9..86a4e3b90ca6c88c233b7b4fd3fb2e8517e197cf 100755 (executable)
@@ -35,7 +35,7 @@
                        {
                                return document.defaultView.getComputedStyle(element).getPropertyValue(dimension);
                        }
-               }
+               };
 
                var width = this.width = computeDimension(context.canvas,'Width') || context.canvas.width;
                var height = this.height = computeDimension(context.canvas,'Height') || context.canvas.height;
@@ -44,8 +44,8 @@
                context.canvas.width  = width;
                context.canvas.height = height;
 
-               var width = this.width = context.canvas.width;
-               var height = this.height = context.canvas.height;
+               width = this.width = context.canvas.width;
+               height = this.height = context.canvas.height;
                this.aspectRatio = this.width / this.height;
                //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale.
                helpers.retinaScale(this);
                clone = helpers.clone = function(obj){
                        var objClone = {};
                        each(obj,function(value,key){
-                               if (obj.hasOwnProperty(key)) objClone[key] = value;
+                               if (obj.hasOwnProperty(key)){
+                                       objClone[key] = value;
+                               }
                        });
                        return objClone;
                },
                extend = helpers.extend = function(base){
                        each(Array.prototype.slice.call(arguments,1), function(extensionObject) {
                                each(extensionObject,function(value,key){
-                                       if (extensionObject.hasOwnProperty(key)) base[key] = value;
+                                       if (extensionObject.hasOwnProperty(key)){
+                                               base[key] = value;
+                                       }
                                });
                        });
                        return base;
                })(),
                warn = helpers.warn = function(str){
                        //Method for warning of errors
-                       if (window.console && typeof window.console.warn == "function") console.warn(str);
+                       if (window.console && typeof window.console.warn === "function") console.warn(str);
                },
-               amd = helpers.amd = (typeof define == 'function' && define.amd),
+               amd = helpers.amd = (typeof define === 'function' && define.amd),
                //-- Math methods
                isNumber = helpers.isNumber = function(n){
                        return !isNaN(parseFloat(n)) && isFinite(n);
                                return -1 * t * (t - 2);
                        },
                        easeInOutQuad: function (t) {
-                               if ((t /= 1 / 2) < 1) return 1 / 2 * t * t;
+                               if ((t /= 1 / 2) < 1){
+                                       return 1 / 2 * t * t;
+                               }
                                return -1 / 2 * ((--t) * (t - 2) - 1);
                        },
                        easeInCubic: function (t) {
                                return 1 * ((t = t / 1 - 1) * t * t + 1);
                        },
                        easeInOutCubic: function (t) {
-                               if ((t /= 1 / 2) < 1) return 1 / 2 * t * t * t;
+                               if ((t /= 1 / 2) < 1){
+                                       return 1 / 2 * t * t * t;
+                               }
                                return 1 / 2 * ((t -= 2) * t * t + 2);
                        },
                        easeInQuart: function (t) {
                                return -1 * ((t = t / 1 - 1) * t * t * t - 1);
                        },
                        easeInOutQuart: function (t) {
-                               if ((t /= 1 / 2) < 1) return 1 / 2 * t * t * t * t;
+                               if ((t /= 1 / 2) < 1){
+                                       return 1 / 2 * t * t * t * t;
+                               }
                                return -1 / 2 * ((t -= 2) * t * t * t - 2);
                        },
                        easeInQuint: function (t) {
                                return 1 * ((t = t / 1 - 1) * t * t * t * t + 1);
                        },
                        easeInOutQuint: function (t) {
-                               if ((t /= 1 / 2) < 1) return 1 / 2 * t * t * t * t * t;
+                               if ((t /= 1 / 2) < 1){
+                                       return 1 / 2 * t * t * t * t * t;
+                               }
                                return 1 / 2 * ((t -= 2) * t * t * t * t + 2);
                        },
                        easeInSine: function (t) {
                                return (t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1);
                        },
                        easeInOutExpo: function (t) {
-                               if (t === 0) return 0;
-                               if (t === 1) return 1;
-                               if ((t /= 1 / 2) < 1) return 1 / 2 * Math.pow(2, 10 * (t - 1));
+                               if (t === 0){
+                                       return 0;
+                               }
+                               if (t === 1){
+                                       return 1;
+                               }
+                               if ((t /= 1 / 2) < 1){
+                                       return 1 / 2 * Math.pow(2, 10 * (t - 1));
+                               }
                                return 1 / 2 * (-Math.pow(2, -10 * --t) + 2);
                        },
                        easeInCirc: function (t) {
-                               if (t >= 1) return t;
+                               if (t >= 1){
+                                       return t;
+                               }
                                return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1);
                        },
                        easeOutCirc: function (t) {
                                return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t);
                        },
                        easeInOutCirc: function (t) {
-                               if ((t /= 1 / 2) < 1) return -1 / 2 * (Math.sqrt(1 - t * t) - 1);
+                               if ((t /= 1 / 2) < 1){
+                                       return -1 / 2 * (Math.sqrt(1 - t * t) - 1);
+                               }
                                return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1);
                        },
                        easeInElastic: function (t) {
                                var s = 1.70158;
                                var p = 0;
                                var a = 1;
-                               if (t === 0) return 0;
-                               if ((t /= 1) == 1) return 1;
-                               if (!p) p = 1 * 0.3;
+                               if (t === 0){
+                                       return 0;
+                               }
+                               if ((t /= 1) == 1){
+                                       return 1;
+                               }
+                               if (!p){
+                                       p = 1 * 0.3;
+                               }
                                if (a < Math.abs(1)) {
                                        a = 1;
                                        s = p / 4;
-                               } else s = p / (2 * Math.PI) * Math.asin(1 / a);
+                               } else{
+                                       s = p / (2 * Math.PI) * Math.asin(1 / a);
+                               }
                                return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p));
                        },
                        easeOutElastic: function (t) {
                                var s = 1.70158;
                                var p = 0;
                                var a = 1;
-                               if (t === 0) return 0;
-                               if ((t /= 1) == 1) return 1;
-                               if (!p) p = 1 * 0.3;
+                               if (t === 0){
+                                       return 0;
+                               }
+                               if ((t /= 1) == 1){
+                                       return 1;
+                               }
+                               if (!p){
+                                       p = 1 * 0.3;
+                               }
                                if (a < Math.abs(1)) {
                                        a = 1;
                                        s = p / 4;
-                               } else s = p / (2 * Math.PI) * Math.asin(1 / a);
+                               } else{
+                                       s = p / (2 * Math.PI) * Math.asin(1 / a);
+                               }
                                return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1;
                        },
                        easeInOutElastic: function (t) {
                                var s = 1.70158;
                                var p = 0;
                                var a = 1;
-                               if (t === 0) return 0;
-                               if ((t /= 1 / 2) == 2) return 1;
-                               if (!p) p = 1 * (0.3 * 1.5);
+                               if (t === 0){
+                                       return 0;
+                               }
+                               if ((t /= 1 / 2) == 2){
+                                       return 1;
+                               }
+                               if (!p){
+                                       p = 1 * (0.3 * 1.5);
+                               }
                                if (a < Math.abs(1)) {
                                        a = 1;
                                        s = p / 4;
-                               } else s = p / (2 * Math.PI) * Math.asin(1 / a);
-                               if (t < 1) return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p));
+                               } else {
+                                       s = p / (2 * Math.PI) * Math.asin(1 / a);
+                               }
+                               if (t < 1){
+                                       return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p));}
                                return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1;
                        },
                        easeInBack: function (t) {
                        },
                        easeInOutBack: function (t) {
                                var s = 1.70158;
-                               if ((t /= 1 / 2) < 1) return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s));
+                               if ((t /= 1 / 2) < 1){
+                                       return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s));
+                               }
                                return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2);
                        },
                        easeInBounce: function (t) {
                                }
                        },
                        easeInOutBounce: function (t) {
-                               if (t < 1 / 2) return easingEffects.easeInBounce(t * 2) * 0.5;
+                               if (t < 1 / 2){
+                                       return easingEffects.easeInBounce(t * 2) * 0.5;
+                               }
                                return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5;
                        }
                },