cloudfoundry/stratos

View on GitHub
src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.ts

Summary

Maintainability
B
6 hrs
Test Coverage

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

function paginate(action, state: PaginationState = {}, updatePagination) {
  if (action.type === ApiActionTypes.API_REQUEST_START) {
    return state;
  }

    Function paginate has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring.
    Open

    function paginate(action, state: PaginationState = {}, updatePagination) {
      if (action.type === ApiActionTypes.API_REQUEST_START) {
        return state;
      }
    
    

    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 getPaginationUpdater has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const getPaginationUpdater = (types: [string, string, string]) => {
      const [requestType, successType, failureType] = types;
      return (state: PaginationEntityState = getDefaultPaginationEntityState(), action): PaginationEntityState => {
        switch (action.type) {
          case requestType:

      Avoid too many return statements within this function.
      Wontfix

          return paginationIgnoreMaxed(state, action as IgnorePaginationMaxedState);

        Avoid too many return statements within this function.
        Wontfix

            return hydratePagination(state, action as HydratePaginationStateAction);

          Avoid too many return statements within this function.
          Wontfix

              return setPaginationIsList(state, action as SetPaginationIsList);

            Avoid too many return statements within this function.
            Wontfix

                return paginationClearAllTypes(state, [clearEntityType]);

              Avoid too many return statements within this function.
              Open

                  return paginationResetPagination(state, action);

                Avoid too many return statements within this function.
                Open

                    return paginationClearOfEntity(state, action);

                  Avoid too many return statements within this function.
                  Wontfix

                      return resetEndpointEntities(state, action);

                    Avoid too many return statements within this function.
                    Open

                        return paginationMaxReached(state, action as UpdatePaginationMaxedState);

                      Avoid too many return statements within this function.
                      Wontfix

                          return paginationResetPagination(state, action, true);

                        Avoid too many return statements within this function.
                        Wontfix

                            return paginationResetSortAndFilter(state, action as ResetPaginationSortFilter);

                          Avoid too many return statements within this function.
                          Open

                            return enterPaginationReducer(state, action, updatePagination);

                            There are no issues that match your filters.

                            Category
                            Status