cloudfoundry-incubator/stratos

View on GitHub

Showing 1,111 of 1,370 total issues

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

  ngOnInit() {
    this.endpointId = this.activatedRoute.snapshot.params && this.activatedRoute.snapshot.params.endpointId ?
      this.activatedRoute.snapshot.params.endpointId : null;
    if (!this.endpointIds$ && this.endpointId) {
      this.endpointIds$ = observableOf([this.endpointId]);

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 init has 64 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func init() {
    RegisterMigration(20170818120003, "InitialSchema", func(txn *sql.Tx, conf *goose.DBConf) error {
        binaryDataType := "BYTEA"
        if strings.Contains(conf.Driver.Name, "mysql") {
            binaryDataType = "BLOB"
Severity: Minor
Found in src/jetstream/datastore/20170818120003_InitialSchema.go - About 1 hr to fix

    Function initServiceObservables has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private initServiceObservables() {
        this.serviceEntityService = cfEntityCatalog.service.store.getEntityService(this.serviceGuid, this.cfGuid, {});
        this.service$ = this.serviceEntityService.waitForEntity$.pipe(
          filter(o => !!o && !!o.entity),
          map(o => o.entity),

      Function succeedRequest has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function succeedRequest(state: BaseRequestState, action: ISuccessRequestAction) {
        if (!isNullOrUndefined(action.apiAction.guid)) {
          const apiAction = action.apiAction as BaseEntityRequestAction;
          const successAction = action as WrapperRequestActionSuccess;
          const requestSuccessState = getEntityRequestState(state, apiAction);

        Function processObject has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function processObject(object: any, output?: any, nested?: boolean) {
          if (nested && output) {
            output = { properties: output };
          } else {
            output = output || {};

          Function map has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public map() {
              if (!this.report.report || !this.report.report.popeye) {
                return;
              }
          
          

            Function setupObservables has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private setupObservables() {
                this.metricsEndpoints$ = this.endpointsMonitor.currentPage$.pipe(
                  map((endpoints: any) => {
                    const result: MetricsEndpointProvider[] = [];
                    const metrics = endpoints.filter(e => e.cnsi_type === 'metrics');

              Function newPortalProxy has 63 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func newPortalProxy(pc interfaces.PortalConfig, dcp *sql.DB, ss HttpSessionStore, sessionStoreOptions *sessions.Options, env *env.VarSet) *portalProxy {
                  log.Debug("newPortalProxy")
              
                  // Generate cookie name - avoids issues if the cookie domain is changed
                  cookieName := jetstreamSessionName
              Severity: Minor
              Found in src/jetstream/main.go - About 1 hr to fix

                Function createCoreStore has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static createCoreStore<Y, ABC extends OrchestratedActionBuilders>(
                    actionOrchestrator: ActionOrchestrator<ABC>,
                    entityKey: string,
                    getSchema: (schema: string) => EntitySchema
                  ): CoreEntityCatalogEntityStore<Y, ABC> {

                  Function graph has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      ).subscribe(([g, report]) => {
                        const newNodes: CustomHelmReleaseGraphNode[] = [];
                        Object.values(g.nodes).forEach((node: HelmReleaseGraphNode) => {
                          const colors = this.getColor(node.data.status);
                          const icon = getIcon(node.data.kind);

                    Function start has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func start(config interfaces.PortalConfig, p *portalProxy, needSetupMiddleware bool, isUpgrade bool, envLookup *env.VarSet) error {
                        log.Debug("start")
                        e := echo.New()
                        e.HideBanner = true
                        e.HidePort = true
                    Severity: Minor
                    Found in src/jetstream/main.go - About 1 hr to fix

                      Function apply has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        public apply(webpackConfig: any, config: StratosConfig, options: any) {
                      
                          // Generate the module file to import the appropriate extensions
                          const dir = path.join(config.rootDir, path.dirname(options.main));
                          const overrideFile = path.resolve(path.join(dir, './_custom-import.module.ts'));
                      Severity: Minor
                      Found in src/frontend/packages/devkit/src/build/extensions.ts - About 1 hr to fix

                        Function deleteOrgWarn has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          deleteOrgWarn() {
                            this.cfOrgService.org$.pipe(
                              map(org => org.entity.entity.name),
                              first()
                            ).subscribe(name => {

                          Function initialiseObservables has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            private initialiseObservables() {
                              this.org$ = this.cfUserService.isConnectedUserAdmin(this.cfGuid).pipe(
                                switchMap(isAdmin => {
                                  const relations = [
                                    createEntityRelationKey(organizationEntityType, spaceEntityType),

                            Function ngOnInit has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              ngOnInit() {
                                this.endpointId = this.activatedRoute.snapshot.params && this.activatedRoute.snapshot.params.endpointId ?
                                  this.activatedRoute.snapshot.params.endpointId : null;
                                if (!this.endpointIds$ && this.endpointId) {
                                  this.endpointIds$ = observableOf([this.endpointId]);

                              Function constructor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                constructor(
                                  catalogEntity: StratosBaseCatalogEntity,
                                  store: Store<any>
                                ) {
                                  super();

                                Function updateUserMissingRoles has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function updateUserMissingRoles(users: IRequestEntityTypeState<APIResource<CfUser>>, action: APISuccessOrFailedAction<NormalizedResponse>) {
                                  // At this point in the flow the request flow (APISuccessOrFailedAction), the users may or may not be in the store yet
                                  // (via WrapperRequestActionSuccess). Therefore in order to avoid partial entities we need to stick the whole user set into the store
                                  // including `missingRoles`.
                                  const usersInResponse: IRequestEntityTypeState<APIResource<CfUser>> = action.response.entities[cfUserEntityType];

                                  Function mapPods has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    private mapPods(pods: KubernetesPod[]): HelmReleaseChartData {
                                      const podPhases: { [phase: string]: number, } = {};
                                      const containers = {
                                        ready: {
                                          name: 'Ready',

                                    Function installChart has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      installChart(): Observable<StepOnNextResult> {
                                        const endpoint = getMonocularEndpoint(this.route, null, null);
                                        // Build the request body
                                        const values: HelmInstallValues = {
                                          ...this.details.value,

                                      Function constructor has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        constructor(
                                          public kubeEndpointService: KubernetesEndpointService,
                                          public activatedRoute: ActivatedRoute,
                                          public store: Store<AppState>,
                                          private snackbarService: SnackBarService
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language