cloudfoundry-incubator/stratos

View on GitHub

Showing 1,111 of 1,370 total issues

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

  private createLocalPageObservable(
    pagination$: Observable<PaginationEntityState>,
    schema: normalizrSchema.Entity,
    fetching$: Observable<boolean>
  ) {
Severity: Minor
Found in src/frontend/packages/store/src/monitors/pagination-monitor.ts - About 1 hr to fix

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

      ngOnInit() {
        this.isOrgRole = !this.spaceGuid;
        const users$ = this.store.select(selectCfUsersRolesPicked);
        // If setting an org role user must be admin or org manager.
        // If setting a space role user must be admin, org manager or space manager

      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 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'

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

                constructor(
                  private store: Store<AppState>,
                  paginationMonitorFactory: PaginationMonitorFactory,
                  entityMonitorFactory: EntityMonitorFactory,
                  internalEventMonitorFactory: InternalEventMonitorFactory,

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                describe('KubernetesGKEAuthFormComponent', () => {
                  let component: KubernetesGKEAuthFormComponent;
                  let fixture: ComponentFixture<KubernetesGKEAuthFormComponent>;
                
                  beforeEach(async(() => {
                src/frontend/packages/kubernetes/src/kubernetes/auth-forms/kubernetes-config-auth-form/kubernetes-config-auth-form.component.spec.ts on lines 8..39

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 222.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                describe('KubernetesConfigAuthFormComponent', () => {
                  let component: KubernetesConfigAuthFormComponent;
                  let fixture: ComponentFixture<KubernetesConfigAuthFormComponent>;
                
                  beforeEach(async(() => {
                src/frontend/packages/kubernetes/src/kubernetes/auth-forms/kubernetes-gke-auth-form/kubernetes-gke-auth-form.component.spec.ts on lines 8..39

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 222.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                func (cfAppPush *CFAppPush) deploy(echoContext echo.Context) error {
                
                    cnsiGUID := echoContext.Param("cnsiGuid")
                    orgGUID := echoContext.Param("orgGuid")
                    spaceGUID := echoContext.Param("spaceGuid")
                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

                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

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

                func (analysis *Analysis) OnEndpointNotification(action interfaces.EndpointAction, endpoint *interfaces.CNSIRecord) {
                    if action == interfaces.EndpointUnregisterAction {
                        // An endpoint was unregistered, so remove all reports
                        dbStore, err := store.NewAnalysisDBStore(analysis.portalProxy.GetDatabaseConnection())
                        if err == nil {
                Severity: Minor
                Found in src/jetstream/plugins/analysis/main.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

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

                func (p *portalProxy) RefreshOidcToken(skipSSLValidation bool, cnsiGUID, userGUID, client, clientSecret, tokenEndpoint string) (t interfaces.TokenRecord, err error) {
                    log.Debug("RefreshOidcToken")
                    userToken, ok := p.GetCNSITokenRecordWithDisconnected(cnsiGUID, userGUID)
                    if !ok {
                        return t, fmt.Errorf("Info could not be found for user with GUID %s", userGUID)
                Severity: Minor
                Found in src/jetstream/oidc_requests.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

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

                func (c *ConsoleConfigRepository) GetConsoleConfig() (*interfaces.ConsoleConfig, error) {
                    log.Debug("Get ConsoleConfig")
                    rows, err := c.db.Query(getConsoleConfig)
                    if err != nil {
                        return nil, fmt.Errorf("Unable to retrieve console config record: %v", err)
                Severity: Minor
                Found in src/jetstream/repository/console_config/psql_console_config.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

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

                func (d *TokenStore) FindCNSIToken(cnsiGUID string, userGUID string, encryptionKey []byte) (interfaces.TokenRecord, error) {
                
                    // Main method that we need to override to get the token for the given endpoint
                    local, err := ListCloudFoundry()
                    if err == nil {
                Severity: Minor
                Found in src/jetstream/plugins/desktop/tokens.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 ApplyMigrations has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring.
                Open

                func ApplyMigrations(conf *goose.DBConf, db *sql.DB) error {
                    current, err := goose.EnsureDBVersion(conf, db)
                    if err != nil {
                        return fmt.Errorf("Failed to get database version: %s", err.Error())
                    }
                Severity: Minor
                Found in src/jetstream/datastore/datastore_migrator.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 MigrateSetupData has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring.
                Open

                func MigrateSetupData(portal interfaces.PortalProxy, configStore Repository) error {
                
                    // Determine if we need to migrate data first
                    _, ok, err := configStore.GetValue(systemGroupName, configSetupNeededMarker)
                    if err != nil {
                Severity: Minor
                Found in src/jetstream/repository/console_config/env_lookup.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

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

                func (k *KubeConfigFile) GetUserForCluster(clusterEndpoint string) (*KubeConfigUser, error) {
                
                    var cluster *KubeConfigCluster
                    var err error
                
                
                Severity: Minor
                Found in src/jetstream/plugins/kubernetes/config/kube_config.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 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 update has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring.
                Open

                  private update() {
                    this.initials = null;
                    this.gravatar = null;
                    const user = this.userInfo;
                
                

                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