maestrano/mno-enterprise

View on GitHub
frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js

Summary

Maintainability
F
1 wk
Test Coverage

File xeditable.js has 947 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
angular-xeditable - 0.1.8
Edit-in-place for angular.js
Build date: 2014-01-10 
*/
Severity: Major
Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 2 days to fix

    Function EditableController has 227 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function EditableController($scope, $attrs, $element, $parse, editableThemes, editableOptions, $rootScope, $compile, $q) {
        var valueGetter;
    
        //if control is disabled - it does not participate in waiting process
        var inWaiting;
    Severity: Major
    Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 1 day to fix

      Function compile has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            compile: function() {
              return {
                pre: function(scope, elem, attrs, ctrl) {
                  var form = ctrl[0];
                  var eForm;
      Severity: Major
      Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 2 hrs to fix

        Function link has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              link: function(scope, elem, attrs, ctrl) {
                // editable controller
                var eCtrl = ctrl[0];
        
                // form controller
        Severity: Major
        Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 2 hrs to fix

          Function promiseCollection has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function promiseCollection() {
              return {
                promises: [],
                hasFalse: false,
                hasString: false,
          Severity: Major
          Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 2 hrs to fix

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

                      post: function(scope, elem, attrs, ctrl) {
                        var eForm;
            
                        if(attrs.editableForm && scope[attrs.editableForm] && scope[attrs.editableForm].$show) {
                          eForm = scope[attrs.editableForm];
            Severity: Minor
            Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 1 hr to fix

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

                  self.init = function(single) {
                    self.single = single;
              
                    self.name = $attrs.eName || $attrs[self.directiveName];
                    /*
              Severity: Minor
              Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 1 hr to fix

                Function render has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    self.render = function() {
                      var theme = self.theme;
                
                      //build input
                      self.inputEl = angular.element(self.inputTpl);
                Severity: Minor
                Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 1 hr to fix

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

                        then: function(callbacks) {
                          callbacks = callbacks || {};
                          var onTrue = callbacks.onTrue || angular.noop;
                          var onFalse = callbacks.onFalse || angular.noop;
                          var onString = callbacks.onString || angular.noop;
                  Severity: Minor
                  Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 1 hr to fix

                    Function parser has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function parser(optionsExp) {
                        var match;
                    
                        if (! (match = optionsExp.match(NG_OPTIONS_REGEXP))) {
                          throw 'ng-options parse error';
                    Severity: Minor
                    Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 1 hr to fix

                      Function EditableController has 9 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        function EditableController($scope, $attrs, $element, $parse, editableThemes, editableOptions, $rootScope, $compile, $q) {
                      Severity: Major
                      Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 1 hr to fix

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

                              postrender: function() {
                                //apply `form-control` class to std inputs
                                switch(this.directiveName) {
                                  case 'editableText':
                                  case 'editableSelect':
                        Severity: Minor
                        Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 1 hr to fix

                          Consider simplifying this complex logical expression.
                          Open

                                } else if (noPromise && angular.isObject(result) && result.status &&
                                  (result.status !== 200) && result.data && angular.isString(result.data)) {
                                  this.setError(result.data);
                                  //set result to string: to let form know that there was error
                                  result = result.data;
                          Severity: Major
                          Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js - About 40 mins to fix

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

                                  render: function() {
                                    this.parent.render.call(this);
                                    var parsed = editableNgOptionsParser(this.attrs.eNgOptions);
                                    var html = '<label ng-repeat="'+parsed.ngRepeat+'">'+
                                      '<input type="radio" ng-model="$parent.$data" value="{{'+parsed.locals.valueFn+'}}">'+
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 137..147

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

                            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

                                  render: function() {
                                    this.parent.render.call(this);
                                    var parsed = editableNgOptionsParser(this.attrs.eNgOptions);
                                    var html = '<label ng-repeat="'+parsed.ngRepeat+'">'+
                                      '<input type="checkbox" checklist-model="$parent.$data" checklist-value="'+parsed.locals.valueFn+'">'+
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 196..206

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

                            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

                                  autosubmit: function() {
                                    var self = this;
                                    self.inputEl.bind('change', function() {
                                      setTimeout(function() {
                                        self.scope.$apply(function() {
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 116..125

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

                            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

                                  autosubmit: function() {
                                    var self = this;
                                    self.inputEl.bind('change', function() {
                                      setTimeout(function() {
                                        self.scope.$apply(function() {
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 207..216

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

                            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

                                  pc.then({
                                    onWait: angular.bind(this, this.$setWaiting), 
                                    onTrue: angular.bind(this, this.$hide), 
                                    onFalse: angular.bind(this, this.$hide), 
                                    onString: angular.bind(this, this.$activate)
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 948..953

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

                            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

                                  pc.then({
                                    onWait: angular.bind(this, this.$setWaiting), 
                                    onTrue: angular.bind(this, this.$activate), 
                                    onFalse: angular.bind(this, this.$activate), 
                                    onString: angular.bind(this, this.$activate)
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 1124..1129

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

                            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($attrs.onshow) {
                                    self.onshow = function() {
                                      return self.catchError($parse($attrs.onshow)($scope));
                                    };
                                  }
                            Severity: Minor
                            Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js and 1 other location - About 55 mins to fix
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 412..416

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

                            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 ($attrs.onbeforesave) {
                                    self.onbeforesave = function() {
                                      return self.catchError($parse($attrs.onbeforesave)($scope));
                                    };
                                  }
                            Severity: Minor
                            Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js and 1 other location - About 55 mins to fix
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 375..379

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

                            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(attrs.onaftersave) {
                                            eForm.$onaftersave = function() {
                                              return $parse(attrs.onaftersave)(scope, {$data: eForm.$data});
                                            };
                                          }
                            Severity: Minor
                            Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js and 1 other location - About 35 mins to fix
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 1279..1283

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

                            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($attrs.onhide) {
                                    self.onhide = function() {
                                      return $parse($attrs.onhide)($scope);
                                    };
                                  }
                            Severity: Minor
                            Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js and 1 other location - About 35 mins to fix
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 399..403

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

                            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(attrs.onbeforesave) {
                                            eForm.$onbeforesave = function() {
                                              return $parse(attrs.onbeforesave)(scope, {$data: eForm.$data});
                                            };
                                          }
                            Severity: Minor
                            Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js and 1 other location - About 35 mins to fix
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 1293..1297

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

                            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($attrs.oncancel) {
                                    self.oncancel = function() {
                                      return $parse($attrs.oncancel)($scope);
                                    };
                                  }          
                            Severity: Minor
                            Found in frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js and 1 other location - About 35 mins to fix
                            frontend/app/assets/javascripts/mno_enterprise/lib/xeditable.js on lines 387..391

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

                            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