cloudfoundry-incubator/stratos

View on GitHub

Showing 1,111 of 1,370 total issues

Function ConfigInit has a Cognitive Complexity of 18 (exceeds 8 allowed). Consider refactoring.
Open

func ConfigInit(envLookup *env.VarSet, jetstreamConfig *interfaces.PortalConfig) {

    // Check we are deployed in Cloud Foundry
    if !envLookup.IsSet(VCapApplication) {
        return
Severity: Minor
Found in src/jetstream/plugins/cloudfoundryhosting/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

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

    this.onRunComplete = (browser, result) => {

      if (fs.existsSync(this.file)) {
        fs.unlinkSync(this.file);
      }
Severity: Minor
Found in build/karma.test.reporter.js - About 1 hr to fix

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

    function doCreateWindow(url) {
    
      let mainWindowState = windowStateKeeper({
        defaultWidth: 1024,
        defaultHeight: 768
    Severity: Minor
    Found in electron/index.js - About 1 hr to fix

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

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

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

          private doEndpointAction(
            apiAction: EntityRequestAction | PaginatedAction,
            url: string,
            params: HttpParams,
            apiActionType: ApiRequestTypes = 'update',
        Severity: Minor
        Found in src/frontend/packages/store/src/effects/endpoint.effects.ts - About 1 hr to fix

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

            private parseKeyValue(key: any, value: any): Segment {
              const segment: Segment = {
                key,
                value,
                type: undefined,

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

              ngOnInit() {
                this.hasFavEntities = this.userFavoriteManager.endpointHasEntitiesThatCanFavorite(this.endpoint.cnsi_type);
                // Favorites for this endpoint
                this.favorites$ = this.userFavoriteManager.getFavoritesForEndpoint(this.endpoint.guid);
                this.entity = entityCatalog.getEndpoint(this.endpoint.cnsi_type, this.endpoint.sub_type);

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

                ngOnInit() {
                  const chartConfigBuilder = getMetricsChartConfigBuilder<IMetricApplication>(
                    result => {
                      const metric = result.metric;
                      if (!!metric.pod && !!metric.namespace) {

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

                  constructor(
                    public cfEndpointService: CloudFoundryEndpointService,
                    private currentUserPermissionsService: CurrentUserPermissionsService,
                    endpointsService: EndpointsService,
                    userFavoriteManager: UserFavoriteManager

                  Function paginate has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function paginate(action, state: PaginationState = {}, updatePagination) {
                    if (action.type === ApiActionTypes.API_REQUEST_START) {
                      return state;
                    }
                  
                  

                    Function resource$ has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          map((item: (KubeAPIResource | KubeStatus)) => {
                            const resource: KubernetesResourceViewerResource = {} as KubernetesResourceViewerResource;
                            const newItem = {} as any;
                    
                            resource.raw = item;

                      Function processSingleItemAction has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        private processSingleItemAction<T extends BasicKubeAPIResource>(
                          action: KubeAction,
                          url: string,
                          body?: any) {
                          const requestType: ApiRequestTypes = body ? 'create' : 'fetch';

                        Function mapMetricsData has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function mapMetricsData(ep: MetricsEndpointProvider): MetricsEndpointInfo[] {
                          const data: MetricsEndpointInfo[] = [];
                        
                          // Add all of the known endpoints first
                          ep.endpoints.forEach(endpoint => {
                        Severity: Minor
                        Found in src/frontend/packages/core/src/features/metrics/metrics.helpers.ts - About 1 hr to fix

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

                            ngOnInit() {
                              this.committedAction = this.metricsConfig.metricsAction;
                              this.metricsMonitor = this.entityMonitorFactory.create<IMetrics>(
                                this.metricsConfig.metricsAction.guid,
                                this.committedAction

                            Method HelmReleaseGraph.ParseManifest has 69 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (r *HelmReleaseGraph) ParseManifest(release *HelmRelease) {
                                for _, item := range release.Resources {
                                    node := ReleaseNode{
                                        ID:    fmt.Sprintf("%s-%s", item.Kind, item.Metadata.Name),
                                        Label: item.Metadata.Name,
                            Severity: Minor
                            Found in src/jetstream/plugins/kubernetes/helm/graph.go - About 1 hr to fix

                              Method KubernetesSpecification.GetReleaseStatus has 69 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (c *KubernetesSpecification) GetReleaseStatus(ec echo.Context) error {
                              
                                  // Need to get a config object for the target endpoint
                                  endpointGUID := ec.Param("endpoint")
                                  release := ec.Param("name")
                              Severity: Minor
                              Found in src/jetstream/plugins/kubernetes/get_release.go - About 1 hr to fix

                                Function cleanUpServiceInstances has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  cleanUpServiceInstances(serviceInstanceNames: string[], userProvided = false): promise.Promise<any> {
                                    // Sleeping because the service instance may not be listed in the `get services` request
                                    browser.sleep(1000);
                                    if (serviceInstanceNames.length === 0) {
                                      return promise.fullyResolved(createEmptyCfResponse());
                                Severity: Minor
                                Found in src/test-e2e/marketplace/services-helper-e2e.ts - About 1 hr to fix

                                  Function types$ has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                        map(endpoints => {
                                          const newTypes: SourceType[] = [];
                                  
                                          // Add all the base types... also update git types if the user has provided credentials for it
                                          this.baseTypes.forEach(t => {

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

                                      constructor(
                                        private store: Store<AppState>,
                                        private activeRouteCfOrgSpace: ActiveRouteCfOrgSpace,
                                        private cfUserService: CfUserService,
                                        private cfRolesService: CfRolesService,

                                      Function default has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      export default function (options: ThemeOptionsSchema): Rule {
                                        return async (host: Tree, context: SchematicContext) => {
                                          if (!options.name) {
                                            throw new SchematicsException(`Invalid options, "name" is required.`);
                                          }
                                      Severity: Minor
                                      Found in src/frontend/packages/devkit/src/schematics/theme/index.ts - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language