cloudfoundry-incubator/stratos

View on GitHub

Showing 1,111 of 1,370 total issues

Method portalProxy.apiKeyMiddleware has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
Open

func (p *portalProxy) apiKeyMiddleware(h echo.HandlerFunc) echo.HandlerFunc {
    return func(c echo.Context) error {
        log.Debug("apiKeyMiddleware")

        // skipping thise middleware if API keys are disabled
Severity: Minor
Found in src/jetstream/middleware.go - About 2 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

Method portalProxy.OAuthHandlerFunc has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
Open

func (p *portalProxy) OAuthHandlerFunc(cnsiRequest *interfaces.CNSIRequest, req *http.Request, refreshOAuthTokenFunc interfaces.RefreshOAuthTokenFunc) interfaces.AuthHandlerFunc {

    return func(tokenRec interfaces.TokenRecord, cnsi interfaces.CNSIRecord) (*http.Response, error) {

        got401 := false
Severity: Minor
Found in src/jetstream/oauth_requests.go - About 2 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 buildJSONResponse has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
Open

func buildJSONResponse(cnsiList []string, responses map[string]*interfaces.CNSIRequest) map[string]*json.RawMessage {
    log.Debug("buildJSONResponse")
    jsonResponse := make(map[string]*json.RawMessage)
    for _, guid := range cnsiList {
        var response []byte
Severity: Minor
Found in src/jetstream/passthrough.go - About 2 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 init has a Cognitive Complexity of 19 (exceeds 8 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 2 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 start has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
Open

  public start() {
    if (this.isStarted()) {
      return;
    }

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

  module.exports.install = function (jasmine) {
    const global = jasmine.getGlobal();
    const _super = {
      describe: global.describe,
      fdescribe: global.fdescribe,
Severity: Major
Found in src/test-e2e/skip-plugin.js - About 2 hrs to fix

    Function sub has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        this.sub = messages.subscribe(jsonString => {
          const messageObj = JSON.parse(jsonString);
          if (messageObj) {
            if (messageObj.kind === 'ReleasePrefix') {
              prefix = messageObj.data;

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

        constructor(
          activatedRoute: ActivatedRoute,
        ) {
          this.editEndpoint = new FormGroup({
            name: new FormControl('', [Validators.required as any]),

        File kubernetes-endpoint.service.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { Injectable } from '@angular/core';
        import { Store } from '@ngrx/store';
        import { combineLatest, Observable, of } from 'rxjs';
        import { filter, first, map, shareReplay, startWith, switchMap } from 'rxjs/operators';
        
        

          File cf-role-checkbox.component.ts has 252 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { Component, Input, OnDestroy, OnInit, Output } from '@angular/core';
          import { Store } from '@ngrx/store';
          import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';
          import { combineLatest as combineLatestOp, filter, first, map } from 'rxjs/operators';
          
          

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

              constructor() {
                const definition: StratosEndpointExtensionDefinition = {
                  type: GIT_ENDPOINT_TYPE,
                  label: 'Git',
                  labelPlural: 'Git',
            Severity: Major
            Found in src/frontend/packages/git/src/store/git-entity-generator.ts - About 2 hrs to fix

              Function getColumns has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private getColumns(definition: KubeResourceEntityDefinition): ITableColumn<KubeAPIResource>[] {
                  const component = this.uiConfigService.previewComponent.get(definition.type);
                  let columns: Array<ITableColumn<KubeAPIResource>> = [
                    // Name
                    {

                Method PgsqlTokenRepository.FindAllCNSITokenBackup has 75 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (p *PgsqlTokenRepository) FindAllCNSITokenBackup(cnsiGUID string, encryptionKey []byte) ([]interfaces.BackupTokenRecord, error) {
                    log.Debug("FindAllCNSITokenBackup")
                    if cnsiGUID == "" {
                        msg := "Unable to find CNSI Token without a valid CNSI GUID."
                        log.Debug(msg)
                Severity: Minor
                Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 2 hrs to fix

                  Function createCredential has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    createCredential() {
                      this.creating.next(true);
                      let action: UpdateAppAutoscalerCredentialAction;
                      if (this.editCredentialForm.controls.actype.value) {
                        action = new UpdateAppAutoscalerCredentialAction(this.applicationService.appGuid, this.applicationService.cfGuid);

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

                      public parse(config: string): Observable<string> {
                        let doc: KubeConfigFile;
                    
                        const clusters: { [name: string]: KubeConfigFileCluster, } = {};
                    
                    

                      Method CFPushApp.Init has 74 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (c *CFPushApp) Init(appDir string, manifestPath string, overrides CFPushAppOverrides) error {
                      
                          // App name
                          if len(overrides.Name) > 0 {
                              c.pushCommand.OptionalArgs = flag.OptionalAppName{
                      Severity: Minor
                      Found in src/jetstream/plugins/cfapppush/pushapp.go - About 1 hr to fix

                        Function scan has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          public scan(packageJson: any) {
                            this.pkgReadMap = new Map<string, PackageInfo>();
                        
                            if (packageJson.peerDependencies) {
                              Object.keys(packageJson.peerDependencies).forEach(dep => {
                        Severity: Minor
                        Found in src/frontend/packages/devkit/src/lib/packages.ts - About 1 hr to fix

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

                            constructor(
                              public sessionService: SessionService,
                              public currentUserPermissionsService: CurrentUserPermissionsService,
                              public userProfileService: UserProfileService
                            ) {

                            Method CFAppPush.getGitSCMSource has a Cognitive Complexity of 18 (exceeds 8 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

                            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 KubeDashboardProxy has a Cognitive Complexity of 18 (exceeds 8 allowed). Consider refactoring.
                            Open

                            func KubeDashboardProxy(c echo.Context, p interfaces.PortalProxy, config *rest.Config) error {
                                log.Debugf("KubeDashboardProxy request for: %s", c.Request().RequestURI)
                            
                                cnsiGUID := c.Param("guid")
                                prefix := "/pp/v1/apps/kubedash/ui/" + cnsiGUID + "/"
                            Severity: Minor
                            Found in src/jetstream/plugins/kubernetes/dashboard/proxy.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