cloudfoundry/stratos

View on GitHub
src/frontend/packages/cloud-foundry/src/shared/data-services/cf-user.service.ts

Summary

Maintainability
C
1 day
Test Coverage

File cf-user.service.ts has 391 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { combineLatest, Observable, of as observableOf, of, ReplaySubject } from 'rxjs';
import { filter, first, map, multicast, publishReplay, refCount, startWith, switchMap } from 'rxjs/operators';

    CfUserService has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Injectable()
    export class CfUserService {
      private allUsers$: Observable<PaginationObservables<APIResource<CfUser>>>;
    
      users: { [guid: string]: Observable<APIResource<CfUser>>; } = {};

      Function getAllUsers has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private getAllUsers(endpointGuid: string): Observable<PaginationObservables<APIResource<CfUser>>> {
          if (!this.allUsers$) {
            this.allUsers$ = waitForCFPermissions(this.store, endpointGuid).pipe(
              switchMap(cf => {
                const isAdmin = cf.global.isAdmin;

        Function createPaginationAction has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

          public createPaginationAction(isAdmin: boolean, cfGuid: string, orgGuid?: string, spaceGuid?: string): Observable<PaginatedAction> {
            if (isAdmin) {
              const allCfUsersAction = this.createCfGetAllUsersAction(cfGuid);
        
              if (!orgGuid) {

          Function allUsers$ has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  switchMap(cf => {
                    const isAdmin = cf.global.isAdmin;
                    // Note - This service is used at cf, org and space level of the cf pages.
                    // We shouldn't attempt to fetch all users if at the cf level
                    if (

            Consider simplifying this complex logical expression.
            Wontfix

                if (isAdmin) {
                  const allCfUsersAction = this.createCfGetAllUsersAction(cfGuid);
            
                  if (!orgGuid) {
                    return observableOf(allCfUsersAction);

              Function createPaginationAction has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
              Wontfix

                public createPaginationAction(isAdmin: boolean, cfGuid: string, orgGuid?: string, spaceGuid?: string): Observable<PaginatedAction> {
                  if (isAdmin) {
                    const allCfUsersAction = this.createCfGetAllUsersAction(cfGuid);
              
                    if (!orgGuid) {

              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