concord-consortium/rigse

View on GitHub
rails/react-components/src/library/components/search/pagination.tsx

Summary

Maintainability
D
1 day
Test Coverage

Function componentDidMount has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  componentDidMount () {
    if (this.props.info.total_pages < 2) {
      // don't display pagination if there's only 1 page
      return;
    }
Severity: Minor
Found in rails/react-components/src/library/components/search/pagination.tsx - 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 componentDidMount has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  componentDidMount () {
    if (this.props.info.total_pages < 2) {
      // don't display pagination if there's only 1 page
      return;
    }
Severity: Major
Found in rails/react-components/src/library/components/search/pagination.tsx - About 2 hrs to fix

    Function onFormat has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          onFormat (type: any) {
            switch (type) {
              case "block":
                if (!this.active) {
                  return `<span class='disabled'>${this.value}</span>`;
    Severity: Minor
    Found in rails/react-components/src/library/components/search/pagination.tsx - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

                  return '<span class="disabled">&gt;|</span>';
      Severity: Major
      Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    if (this.active) { return "   "; } else { return ""; }
        Severity: Major
        Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                        return "<a href='#' class='last'>&gt;|</a>";
          Severity: Major
          Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        if (this.active) { return "..."; } else { return ""; }
            Severity: Major
            Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                            return "<a href='#' class='first'>|&lt;</a>";
              Severity: Major
              Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            if (this.active) { return "..."; } else { return ""; }
                Severity: Major
                Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                return "<a href='#' class='prev'>← Previous</a>";
                  Severity: Major
                  Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return '<span class="disabled">Next →</span>';
                    Severity: Major
                    Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return '<span class="disabled">← Previous</span>';
                      Severity: Major
                      Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return '<span class="disabled">|&lt;</span>';
                        Severity: Major
                        Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      if (this.active) { return "   "; } else { return ""; }
                          Severity: Major
                          Found in rails/react-components/src/library/components/search/pagination.tsx - About 30 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status