angular/angular.js

View on GitHub
src/ng/directive/form.js

Summary

Maintainability
D
2 days
Test Coverage

Function addSetValidityMethod has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

function addSetValidityMethod(context) {
  var clazz = context.clazz,
      set = context.set,
      unset = context.unset;

Severity: Minor
Found in src/ng/directive/form.js - About 4 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 formDirectiveFactory has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

var formDirectiveFactory = function(isNgForm) {
  return ['$timeout', '$parse', function($timeout, $parse) {
    var formDirective = {
      name: 'form',
      restrict: isNgForm ? 'EAC' : 'E',
Severity: Minor
Found in src/ng/directive/form.js - About 3 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

File form.js has 291 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

/* global -nullFormCtrl, -PENDING_CLASS, -SUBMITTED_CLASS
 */
var nullFormCtrl = {
Severity: Minor
Found in src/ng/directive/form.js - About 3 hrs to fix

    Function addSetValidityMethod has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function addSetValidityMethod(context) {
      var clazz = context.clazz,
          set = context.set,
          unset = context.unset;
    
    
    Severity: Major
    Found in src/ng/directive/form.js - About 2 hrs to fix

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

      var formDirectiveFactory = function(isNgForm) {
        return ['$timeout', '$parse', function($timeout, $parse) {
          var formDirective = {
            name: 'form',
            restrict: isNgForm ? 'EAC' : 'E',
      Severity: Major
      Found in src/ng/directive/form.js - About 2 hrs to fix

        Function ngFormCompile has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              compile: function ngFormCompile(formElement, attr) {
                // Setup initial state of the control
                formElement.addClass(PRISTINE_CLASS).addClass(VALID_CLASS);
        
                var nameAttr = attr.name ? 'name' : (isNgForm && attr.ngForm ? 'ngForm' : false);
        Severity: Minor
        Found in src/ng/directive/form.js - About 1 hr to fix

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

            clazz.prototype.$setValidity = function(validationErrorKey, state, controller) {
              if (isUndefined(state)) {
                createAndSet(this, '$pending', validationErrorKey, controller);
              } else {
                unsetAndCleanup(this, '$pending', validationErrorKey, controller);
          Severity: Minor
          Found in src/ng/directive/form.js - About 1 hr to fix

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

                      pre: function ngFormPreLink(scope, formElement, attr, ctrls) {
                        var controller = ctrls[0];
            
                        // if `action` attr is not present on the form, prevent the default action (submission)
                        if (!('action' in attr)) {
            Severity: Minor
            Found in src/ng/directive/form.js - About 1 hr to fix

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

              function FormController($element, $attrs, $scope, $animate, $interpolate) {
              Severity: Minor
              Found in src/ng/directive/form.js - About 35 mins to fix

                Function isObjectEmpty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function isObjectEmpty(obj) {
                  if (obj) {
                    for (var prop in obj) {
                      if (obj.hasOwnProperty(prop)) {
                        return false;
                Severity: Minor
                Found in src/ng/directive/form.js - About 25 mins 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

                There are no issues that match your filters.

                Category
                Status