patternfly/angular-patternfly

View on GitHub
src/wizard/wizard.component.js

Summary

Maintainability
F
6 days
Test Coverage

Function controller has a Cognitive Complexity of 120 (exceeds 5 allowed). Consider refactoring.
Open

  controller: function ($timeout, $scope) {
    'use strict';
    var ctrl = this,
      firstRun;

Severity: Minor
Found in src/wizard/wizard.component.js - About 2 days 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 controller has 282 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  controller: function ($timeout, $scope) {
    'use strict';
    var ctrl = this,
      firstRun;

Severity: Major
Found in src/wizard/wizard.component.js - About 1 day to fix

    File wizard.component.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    angular.module('patternfly.wizard').component('pfWizard', {
      transclude: true,
      bindings: {
        title: '@',
        wizardTitle: '@',
    Severity: Minor
    Found in src/wizard/wizard.component.js - About 3 hrs to fix

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

          ctrl.goTo = function (step, resetStepNav) {
            var focusElement = null;
      
            if (ctrl.wizardDone || (ctrl.selectedStep && !ctrl.selectedStep.okToNavAway) || step === ctrl.selectedStep) {
              return;
      Severity: Minor
      Found in src/wizard/wizard.component.js - About 1 hr to fix

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

            ctrl.$onInit = function () {
              firstRun = true;
              ctrl.steps = [];
              ctrl.context = {};
              ctrl.hideHeader = ctrl.hideHeader === 'true';
        Severity: Minor
        Found in src/wizard/wizard.component.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                if (step.allowClickNav &&
                  ctrl.selectedStep &&
                  !ctrl.wizardDone &&
                  ctrl.selectedStep.okToNavAway &&
                  (ctrl.selectedStep.nextEnabled || (step.stepPriority < ctrl.selectedStep.stepPriority)) &&
          Severity: Critical
          Found in src/wizard/wizard.component.js - About 1 hr to fix

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

                ctrl.next = function (callback) {
                  var enabledSteps = ctrl.getEnabledSteps();
            
                  // Save the step  you were on when next() was invoked
                  var index = stepIdx(ctrl.selectedStep);
            Severity: Minor
            Found in src/wizard/wizard.component.js - About 1 hr to fix

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

                        $timeout(function () {
                          if (step.focusSelectors) {
                            _.find(step.focusSelectors, function (selector) {
                              return focusElement = document.querySelector(selector);
                            });
              Severity: Major
              Found in src/wizard/wizard.component.js and 1 other location - About 5 hrs to fix
              src/wizard/wizard-step.component.js on lines 240..260

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

              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

                  var stepIdx = function (step) {
                    var idx = 0;
                    var res = -1;
                    angular.forEach(ctrl.getEnabledSteps(), function (currStep) {
                      if (currStep === step) {
              Severity: Major
              Found in src/wizard/wizard.component.js and 1 other location - About 2 hrs to fix
              src/wizard/wizard-step.component.js on lines 57..67

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

              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

                  var stepByTitle = function (titleToFind) {
                    var foundStep = null;
                    angular.forEach(ctrl.getEnabledSteps(), function (step) {
                      if (step.title === titleToFind) {
                        foundStep = step;
              Severity: Major
              Found in src/wizard/wizard.component.js and 1 other location - About 1 hr to fix
              src/wizard/wizard-step.component.js on lines 78..86

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

              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

                  var unselectAll = function () {
                    //traverse steps array and set each "selected" property to false
                    angular.forEach(ctrl.getEnabledSteps(), function (step) {
                      step.selected = false;
                    });
              Severity: Major
              Found in src/wizard/wizard.component.js and 1 other location - About 1 hr to fix
              src/wizard/wizard-step.component.js on lines 69..76

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

              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 (insertBefore) {
                      ctrl.steps.splice(ctrl.steps.indexOf(insertBefore), 0, step);
                    } else {
                      ctrl.steps.push(step);
                    }
              Severity: Major
              Found in src/wizard/wizard.component.js and 1 other location - About 1 hr to fix
              src/wizard/wizard-step.component.js on lines 281..285

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

              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

                  ctrl.finish = function () {
                    if (ctrl.onFinish) {
                      if (ctrl.onFinish() !== false) {
                        ctrl.reset();
                      }
              Severity: Minor
              Found in src/wizard/wizard.component.js and 1 other location - About 55 mins to fix
              src/wizard/wizard.component.js on lines 384..390

              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

                  ctrl.cancel = function () {
                    if (ctrl.onCancel) {
                      if (ctrl.onCancel() !== false) {
                        ctrl.reset();
                      }
              Severity: Minor
              Found in src/wizard/wizard.component.js and 1 other location - About 55 mins to fix
              src/wizard/wizard.component.js on lines 376..382

              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

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

                  ctrl.getEnabledSteps = function () {
                    return ctrl.steps.filter(function (step) {
                      return step.disabled !== 'true';
                    });
                  };
              Severity: Minor
              Found in src/wizard/wizard.component.js and 1 other location - About 40 mins to fix
              src/wizard/wizard-step.component.js on lines 164..168

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

              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