cloudfoundry/stratos

View on GitHub

Showing 718 of 1,370 total issues

Function findFreePort has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
Open

function findFreePort(beg, ...rest){
  const p = rest.slice(0, rest.length - 1), cb = rest[rest.length - 1];
  let [end, ip, cnt] = Array.from(p);
  if (!ip && end && !/^\d+$/.test(end)) { // deal with method 3
    ip = end;
Severity: Minor
Found in electron/freeport.js - About 1 hr 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 get has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  get(summary: any, appInstances: AppStat[]): ApplicationStateData {
    const appState: string = summary ? summary.state : 'UNKNOWN';
    const pkgState = this.getPackageState(appState, summary);
    const wildcard = this.stateMetadata['?'];

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

      ngOnInit() {
        this.sourceType$ = combineLatest(
          this.appDeploySourceTypes.getAutoSelectedType(this.route),
          this.store.select(selectSourceType),
          this.appDeploySourceTypes.types$.pipe(first(), map(st => st[this.INITIAL_SOURCE_TYPE]))

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

        ngOnInit() {
      
          // Listen for the graph
          this.graph = combineLatest(
            this.helper.fetchReleaseGraph(),

        Method CFAppPush.getGitSCMSource has 67 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (cfAppPush *CFAppPush) getGitSCMSource(clientWebSocket *websocket.Conn, tempDir string, msg SocketMessage, userGUID string) (StratosProject, string, error) {
            var (
                err error
            )
        
        
        Severity: Minor
        Found in src/jetstream/plugins/cfapppush/deploy.go - About 1 hr to fix

          Method portalProxy.doRequest has 67 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (p *portalProxy) doRequest(cnsiRequest *interfaces.CNSIRequest, done chan<- *interfaces.CNSIRequest) {
              log.Debugf("doRequest for URL: %s", cnsiRequest.URL.String())
              var body io.Reader
              var res *http.Response
              var req *http.Request
          Severity: Minor
          Found in src/jetstream/passthrough.go - About 1 hr to fix

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

              login(username: string, password: string) {
                // If this is a different user to last time, then logout first
                if (SSOLoginPage.ssoLastUsername && SSOLoginPage.ssoLastUsername !== username) {
                  browser.waitForAngularEnabled(false);
                  this.logoutUAA();
            Severity: Minor
            Found in src/test-e2e/login/sso-login.po.ts - About 1 hr to fix

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

                function createActionTableDate(orgTarget, spaceTarget, stateIcon) {
                  return [{
                    user: userName,
                    action: 'remove_circle\nRemove',
                    role: 'Manager',
              Severity: Minor
              Found in src/test-e2e/cloud-foundry/manage-users-stepper-e2e.spec.ts - About 1 hr to fix

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

                  ngOnInit() {
                
                    const helmLastModifiedRegEx = /seconds:([0-9]*)/;
                
                    this.sessionData$ = this.store.select(s => s.auth).pipe(

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

                      private setupAutoSelectors(initialCf: string, initialOrg: string) {
                        // Clear or automatically select org + space given cf
                        let cfTapped = false;
                        const orgResetSub = this.cf.select.asObservable().pipe(
                          startWith(initialCf),

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

                        constructor(dir: string, options?: any, loggingEnabled = true) {
                          this.angularJsonFile = this.findFileOrFolderInChain(dir, 'angular.json');
                          this.angularJson = JSON.parse(fs.readFileSync(this.angularJsonFile, 'utf8').toString());
                          this.loggingEnabled = loggingEnabled;
                      
                      
                      Severity: Minor
                      Found in src/frontend/packages/devkit/src/lib/stratos.config.ts - About 1 hr to fix

                        Function hasUpgrade has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          public hasUpgrade(returnLatest = false): Observable<InternalHelmUpgrade> {
                            const updates = combineLatest(this.getCharts(), this.release$);
                            return updates.pipe(
                              map(([charts, release]) => {
                                let score = -1;

                          Method MetricsSpecification.getMetricsEndpoints has 65 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (m *MetricsSpecification) getMetricsEndpoints(userGUID string, cnsiList []string) (map[string]EndpointMetricsRelation, error) {
                          
                              metricsProviders := make([]MetricsMetadata, 0)
                              endpointsMap := make(map[string]*interfaces.ConnectedEndpoint)
                              results := make(map[string]EndpointMetricsRelation)
                          Severity: Minor
                          Found in src/jetstream/plugins/metrics/main.go - About 1 hr to fix

                            Function testEntityMissingEntityRequired has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              function testEntityMissingEntityRequired(done: () => void) {
                                const getOrgAction = new GetOrganization(
                                  orgGuid,
                                  cfGuid,
                                  [createEntityRelationKey(organizationEntityType, quotaDefinitionEntityType)],

                              Function handleFileInputSelection has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                handleFileInputSelection(items): Observable<FileScannerInfo> {
                                  const obs$ = new BehaviorSubject<DeployApplicationFSScanner>(undefined);
                                  let scanner = new DeployApplicationFSScanner(CF_DEFAULT_IGNORES);
                                  let cfIgnoreFile;
                                  let manifestFile = false;

                                Function mapMultiEndpointResponses has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export function mapMultiEndpointResponses(
                                  action: EntityRequestAction,
                                  catalogEntity: StratosBaseCatalogEntity,
                                  requestType: ApiRequestTypes,
                                  multiEndpointResponses: HandledMultiEndpointResponse,

                                  Function parse has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    parse(content) {
                                      const prepareRegexes = this.prepareRegexes.bind(this);
                                      return content.split('\n')
                                        .map(line => {
                                          line = line.trim();

                                    Function processSingleItemDeleteAction has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      private processSingleItemDeleteAction<T extends BasicKubeAPIResource>(action: KubeAction, url: string) {
                                        this.store.dispatch(new StartRequestAction(action, 'delete'));
                                        const headers = new HttpHeaders({
                                          'x-cap-cnsi-list': action.kubeGuid,
                                          'x-cap-passthrough': 'true'

                                      Method Analyzer.deleteEndpoint has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring.
                                      Open

                                      func (a *Analyzer) deleteEndpoint(ec echo.Context) error {
                                          log.Debug("delete reports for endpoint")
                                      
                                          endpoint := ec.Param("endpoint")
                                      
                                      
                                      Severity: Minor
                                      Found in src/jetstream/plugins/analysis/container/routes.go - About 1 hr 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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language