Completed
Push — master ( f4255b...0c6fc8 )
by Xu
706:28 queued 666:46
created

resources/assets/yuncms-user/dist/js/cropper.min.js   A

Complexity

Total Complexity 23
Complexity/F 3.83

Size

Lines of Code 1
Function Count 6

Duplication

Duplicated Lines 1
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1536
dl 1
loc 1
rs 10
wmc 23
mnd 4
bc 12
fnc 6
bpm 2
cpm 3.8333
noi 6

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
jQuery(function(){"use strict";var e=jQuery("#image"),r=jQuery("#x"),o=jQuery("#y"),t=jQuery("#height"),a=jQuery("#width"),i={viewMode:1,dragMode:"move",autoCropArea:1,restore:!1,highlight:!1,cropBoxMovable:!1,cropBoxResizable:!1,aspectRatio:1,preview:".img-preview",crop:function(e){r.val(Math.round(e.x)),o.val(Math.round(e.y)),t.val(Math.round(e.height)),a.val(Math.round(e.width)),jQuery("#inputImage").val()||(jQuery(".btn-group button").attr("disabled",!0),jQuery(".cropper-view-box").hide(),jQuery(".cropper-wrap-box").hide())}};e.cropper(i),jQuery(".docs-buttons").on("click","[data-method]",function(){var r,o,t=jQuery(this),a=t.data();if(!t.prop("disabled")&&!t.hasClass("disabled")){if(e.data("cropper")&&a.method){if(void 0!==(a=jQuery.extend({},a)).target&&(r=jQuery(a.target),void 0===a.option))try{a.option=JSON.parse(r.val())}catch(e){console.log(e.message)}if(o=e.cropper(a.method,a.option,a.secondOption),$.isPlainObject(o)&&r)try{r.val(JSON.stringify(o))}catch(e){console.log(e.message)}}return!1}}),jQuery(document.body).on("keydown",function(r){if(e.data("cropper")&&!(this.scrollTop>300))switch(r.which){case 37:r.preventDefault(),e.cropper("move",-1,0);break;case 38:r.preventDefault(),e.cropper("move",0,-1);break;case 39:r.preventDefault(),e.cropper("move",1,0);break;case 40:r.preventDefault(),e.cropper("move",0,1)}});var p,c=jQuery("#inputImage"),n=window.URL||window.webkitURL;n?c.change(function(){var r,o=this.files;e.data("cropper")&&(o&&o.length&&(r=o[0],/^image\/\w+$/.test(r.type)?(p=n.createObjectURL(r),e.one("built.cropper",function(){n.revokeObjectURL(p)}).cropper("reset").cropper("replace",p)):window.alert("Please choose an image file.")),jQuery(".btn-group button").removeAttr("disabled"))}):c.prop("disabled",!0).parent().addClass("disabled")});
0 ignored issues
show
Bug introduced by
The variable e seems to be never initialized.
Loading history...
Bug introduced by
The variable r does not seem to be initialized in case void(0) !== a = jQuery.e...), void(0) === a.option on line 1 is false. Are you sure this can never be the case?
Loading history...
Complexity Best Practice introduced by
There is no return statement if !t.prop("disabled") && !t.hasClass("disabled") is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
Coding Style introduced by
As per coding-style, switch statements should have a default case.
Loading history...
Bug introduced by
The variable e does not seem to be initialized in case void(0) !== a = jQuery.e...), void(0) === a.option on line 1 is false. Are you sure this can never be the case?
Loading history...
2
//# sourceMappingURL=cropper.min.js.map