partkeepr/PartKeepr

View on GitHub
src/PartKeepr/FrontendBundle/Resources/public/js/Util/FileSaver.js

Summary

Maintainability
D
3 days
Test Coverage

Function saveAs has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

var saveAs = saveAs || (function(view) {
    "use strict";
    // IE <10 is explicitly unsupported
    if (typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
        return;
Severity: Minor
Found in src/PartKeepr/FrontendBundle/Resources/public/js/Util/FileSaver.js - About 1 day 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 saveAs has 214 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var saveAs = saveAs || (function(view) {
    "use strict";
    // IE <10 is explicitly unsupported
    if (typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
        return;
Severity: Major
Found in src/PartKeepr/FrontendBundle/Resources/public/js/Util/FileSaver.js - About 1 day to fix

    Function FileSaver has 123 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            , FileSaver = function(blob, name, no_auto_bom) {
                if (!no_auto_bom) {
                    blob = auto_bom(blob);
                }
                // First try a.download, then web filesystem, then object URLs
    Severity: Major
    Found in src/PartKeepr/FrontendBundle/Resources/public/js/Util/FileSaver.js - About 4 hrs to fix

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

                      , fs_error = function() {
                          if (target_view && is_safari && typeof FileReader !== "undefined") {
                              // Safari doesn't allow downloading of blob urls
                              var reader = new FileReader();
                              reader.onloadend = function() {
      Severity: Minor
      Found in src/PartKeepr/FrontendBundle/Resources/public/js/Util/FileSaver.js - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status