cloudfoundry/stratos

View on GitHub
src/frontend/packages/core/src/shared/components/stepper/steppers/steppers.component.ts

Summary

Maintainability
C
1 day
Test Coverage

Function setActive has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
Open

  setActive(index: number) {
    if (this.basePreviousRedirect && index < 0) {
      this.dispatchRedirect(this.basePreviousRedirect);
    }
    if (!this.canGoto(index)) {

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 steppers.component.ts has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  AfterContentInit,
  Component,
  ContentChildren,
  Input,

    Function goNext has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      goNext() {
        // Close previous error snackbar if there was one
        if (this.snackBarRef) {
          this.snackBar.dismiss();
        }

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

        setActive(index: number) {
          if (this.basePreviousRedirect && index < 0) {
            this.dispatchRedirect(this.basePreviousRedirect);
          }
          if (!this.canGoto(index)) {

        Avoid deeply nested control flow statements.
        Open

                      if (this.allSteps[index].onEnter) {
                        this.allSteps[index].onEnter(this.enterData);
                      }

          Function canGoto has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
          Open

            canGoto(index: number): boolean {
              if (index < 0 && this.basePreviousRedirect) {
                return true;
              }
              const step = this.steps[this.currentIndex];

          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

          Avoid too many return statements within this function.
          Open

                return false;

            Avoid too many return statements within this function.
            Open

                  return false;

              Avoid too many return statements within this function.
              Open

                    return true;

                Avoid too many return statements within this function.
                Open

                      return true;

                  There are no issues that match your filters.

                  Category
                  Status