myems-admin/js/plugins/oclazyload/ocLazyLoad.js

Summary

Maintainability
F
1 wk
Test Coverage

File ocLazyLoad.js has 987 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * oclazyload - Load modules on demand (lazy load) with angularJS
 * @version v1.0.10
 * @link https://github.com/ocombe/ocLazyLoad
 * @license MIT
Severity: Major
Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 2 days to fix

    Function $get has 237 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            this.$get = ["$log", "$rootElement", "$rootScope", "$cacheFactory", "$q", function ($log, $rootElement, $rootScope, $cacheFactory, $q) {
                var instanceInjector,
                    filesCache = $cacheFactory('ocLazyLoad');
    
                if (!debug) {
    Severity: Major
    Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 1 day to fix

      Function filesLoader has 104 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  $delegate.filesLoader = function filesLoader(config) {
                      var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
      
                      var cssFiles = [],
                          templatesFiles = [],
      Severity: Major
      Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 4 hrs to fix

        Function buildElement has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    $delegate.buildElement = function buildElement(type, path, params) {
                        var deferred = $q.defer(),
                            el,
                            loaded,
                            filesCache = $delegate._getFilesCache(),
        Severity: Major
        Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 3 hrs to fix

          Function _loadDependencies has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                          _loadDependencies: function _loadDependencies(moduleName, localParams) {
                              var loadedModule,
                                  requires,
                                  diff,
                                  promisesList = [],
          Severity: Major
          Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 2 hrs to fix

            Function load has 67 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        $delegate.load = function (originalModule) {
                            var originalParams = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
            
                            var self = this,
                                config = null,
            Severity: Major
            Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 2 hrs to fix

              Function _registerInvokeList has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      function _registerInvokeList(args, moduleName) {
                          var invokeList = args[2][0],
                              type = args[1],
                              newInvoke = false;
                          if (angular.isUndefined(regInvokes[moduleName])) {
              Severity: Major
              Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 2 hrs to fix

                Function indexOf has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                        Array.prototype.indexOf = function (searchElement, fromIndex) {
                                var k;
                
                                // 1. Let O be the result of calling ToObject passing
                                //    the this value as the argument.
                Severity: Minor
                Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 2 hrs 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 _init has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        this._init = function _init(element) {
                            // this is probably useless now because we override angular.bootstrap
                            if (modulesToLoad.length === 0) {
                                var elements = [element],
                                    names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'],
                Severity: Minor
                Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 2 hrs to fix

                  Function inject has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                                  inject: function inject(moduleName) {
                                      var localParams = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
                                      var real = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
                  
                                      var self = this,
                  Severity: Minor
                  Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 1 hr to fix

                    Function _invokeQueue has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            function _invokeQueue(providers, queue, moduleName, reconfig) {
                                if (!queue) {
                                    return;
                                }
                    
                    
                    Severity: Minor
                    Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 1 hr to fix

                      Function _register has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              function _register(providers, registerModules, params) {
                                  if (registerModules) {
                                      var k,
                                          moduleName,
                                          moduleFn,
                      Severity: Minor
                      Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 1 hr to fix

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

                                        var pushFile = function pushFile(path) {
                                            var file_type = null,
                                                m;
                                            if (angular.isObject(path)) {
                                                file_type = path.type;
                        Severity: Minor
                        Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 1 hr to fix

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

                                      $delegate.templatesLoader = function (paths, callback, params) {
                                          var promises = [],
                                              filesCache = $delegate._getFilesCache();
                          
                                          angular.forEach(paths, function (url) {
                          Severity: Minor
                          Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 1 hr to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                            if (invoked === -1) {
                                                                regConfigs.push(moduleName + '-' + fct);
                                                            }
                            Severity: Major
                            Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                              if (angular.isDefined(provider)) {
                                                                  provider[args[1]].apply(provider, args[2]);
                                                              }
                              Severity: Major
                              Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                            for (var j = 0, jlen = args[2][0].length; j < jlen; j++) {
                                                                if (angular.isFunction(args[2][0][j])) {
                                                                    callInvoke(args[2][0][j]);
                                                                }
                                                            }
                                Severity: Major
                                Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 45 mins to fix

                                  Function $get has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                          this.$get = ["$log", "$rootElement", "$rootScope", "$cacheFactory", "$q", function ($log, $rootElement, $rootScope, $cacheFactory, $q) {
                                  Severity: Minor
                                  Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js - About 35 mins to fix

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

                                    if (!Array.prototype.indexOf) {
                                            Array.prototype.indexOf = function (searchElement, fromIndex) {
                                                    var k;
                                    
                                                    // 1. Let O be the result of calling ToObject passing
                                    Severity: Major
                                    Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js and 1 other location - About 1 day to fix
                                    myems-admin/js/plugins/jvectormap/jquery-jvectormap-2.0.2.min.js on lines 367..429

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

                                    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

                                    (function (angular) {
                                        'use strict';
                                    
                                        angular.module('oc.lazyLoad').config(["$provide", function ($provide) {
                                            $provide.decorator('$ocLazyLoad', ["$delegate", "$q", function ($delegate, $q) {
                                    Severity: Major
                                    Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js and 1 other location - About 7 hrs to fix
                                    myems-admin/js/plugins/oclazyload/ocLazyLoad.js on lines 1183..1212

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

                                    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

                                    (function (angular) {
                                        'use strict';
                                    
                                        angular.module('oc.lazyLoad').config(["$provide", function ($provide) {
                                            $provide.decorator('$ocLazyLoad', ["$delegate", "$q", function ($delegate, $q) {
                                    Severity: Major
                                    Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js and 1 other location - About 7 hrs to fix
                                    myems-admin/js/plugins/oclazyload/ocLazyLoad.js on lines 1213..1242

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

                                    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 (templatesFiles.length > 0) {
                                                        var templatesDeferred = $q.defer();
                                                        $delegate.templatesLoader(templatesFiles, function (err) {
                                                            if (angular.isDefined(err) && $delegate.templatesLoader.hasOwnProperty('ocLazyLoadLoader')) {
                                                                $delegate._$log.error(err);
                                    Severity: Major
                                    Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js and 1 other location - About 4 hrs to fix
                                    myems-admin/js/plugins/oclazyload/ocLazyLoad.js on lines 1026..1037

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

                                    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 (cssFiles.length > 0) {
                                                        var cssDeferred = $q.defer();
                                                        $delegate.cssLoader(cssFiles, function (err) {
                                                            if (angular.isDefined(err) && $delegate.cssLoader.hasOwnProperty('ocLazyLoadLoader')) {
                                                                $delegate._$log.error(err);
                                    Severity: Major
                                    Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js and 1 other location - About 4 hrs to fix
                                    myems-admin/js/plugins/oclazyload/ocLazyLoad.js on lines 1039..1050

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

                                    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

                                                                if (angular.isDefined(self.filesLoader)) {
                                                                    // if a files loader is defined
                                                                    promisesList.push(self.filesLoader(requireEntry, localParams).then(function () {
                                                                        return self._loadDependencies(requireEntry);
                                                                    }));
                                    Severity: Minor
                                    Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js and 1 other location - About 45 mins to fix
                                    myems-admin/js/plugins/oclazyload/ocLazyLoad.js on lines 601..608

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

                                    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

                                                                if (angular.isDefined(self.filesLoader)) {
                                                                    // if a files loader is defined
                                                                    promisesList.push(self.filesLoader(requireEntry, localParams).then(function () {
                                                                        return self._loadDependencies(requireEntry);
                                                                    }));
                                    Severity: Minor
                                    Found in myems-admin/js/plugins/oclazyload/ocLazyLoad.js and 1 other location - About 45 mins to fix
                                    myems-admin/js/plugins/oclazyload/ocLazyLoad.js on lines 566..573

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

                                    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