cloudfoundry/korifi

View on GitHub

Showing 20 of 27 total issues

Function main has 339 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func main() {
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
 
 
Severity: Major
Found in controllers/main.go - About 1 day to fix

    Function main has a Cognitive Complexity of 87 (exceeds 20 allowed). Consider refactoring.
    Open

    func main() {
    var metricsAddr string
    var enableLeaderElection bool
    var probeAddr string
     
     
    Severity: Minor
    Found in controllers/main.go - About 1 day to fix

    App has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type App struct {
    serverURL url.URL
    appRepo CFAppRepository
    dropletRepo CFDropletRepository
    processRepo CFProcessRepository
    Severity: Minor
    Found in api/handlers/app.go - About 3 hrs to fix

      Method ProcessStats.FetchStats has 70 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (a *ProcessStats) FetchStats(ctx context.Context, authInfo authorization.Info, processGUID string) ([]PodStatsRecord, error) {
      processRecord, err := a.processRepo.GetProcess(ctx, authInfo, processGUID)
      if err != nil {
      return nil, err
      }
      Severity: Minor
      Found in api/actions/process_stats.go - About 1 hr to fix

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

        func ForApp(responseApp repositories.AppRecord, baseURL url.URL, includes ...include.Resource) AppResponse {
        return AppResponse{
        Name: responseApp.Name,
        GUID: responseApp.GUID,
        State: string(responseApp.State),
        Severity: Minor
        Found in api/presenter/app.go - About 1 hr to fix

          Method ServicePlanRepo.planToRecord has 62 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (r *ServicePlanRepo) planToRecord(ctx context.Context, authInfo authorization.Info, plan korifiv1alpha1.CFServicePlan) (ServicePlanRecord, error) {
          organizations := []VisibilityOrganization{}
          if plan.Spec.Visibility.Type == korifiv1alpha1.OrganizationServicePlanVisibilityType {
          var err error
          organizations, err = r.toVisibilityOrganizations(ctx, authInfo, plan.Spec.Visibility.Organizations)
          Severity: Minor
          Found in api/repositories/service_plan_repository.go - About 1 hr to fix

            Function NewApp has 12 arguments (exceeds 5 allowed). Consider refactoring.
            Open

            serverURL url.URL,
            appRepo CFAppRepository,
            dropletRepo CFDropletRepository,
            processRepo CFProcessRepository,
            routeRepo CFRouteRepository,
            Severity: Major
            Found in api/handlers/app.go - About 1 hr to fix

              Function SetupIndexWithManager has 59 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func SetupIndexWithManager(mgr manager.Manager) error {
              err := mgr.GetFieldIndexer().IndexField(context.Background(), new(korifiv1alpha1.CFRoute), IndexRouteDestinationAppName, routeDestinationAppNameIndexFn)
              if err != nil {
              return err
              }
              Severity: Minor
              Found in controllers/controllers/shared/index.go - About 1 hr to fix

                Method DuplicateValidator.ValidateUpdate has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (v DuplicateValidator) ValidateUpdate(ctx context.Context, logger logr.Logger, namespace string, oldObj, obj webhooks.UniqueClientObject) error {
                if oldObj.UniqueName() == obj.UniqueName() {
                return nil
                }
                 
                 
                Severity: Minor
                Found in controllers/webhooks/validation/duplicate_validator.go - About 1 hr to fix

                  Function ForRoot has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func ForRoot(baseURL url.URL, uaaConfig config.UAA, logCacheURL url.URL) RootResponse {
                  rootResponse := RootResponse{
                  Links: map[string]*APILink{
                  "self": {
                  Link: Link{
                  Severity: Minor
                  Found in api/presenter/root.go - About 1 hr to fix

                    Function main has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func main() {
                    var (
                    metricsAddr string
                    enableLeaderElection bool
                    probeAddr string
                    Severity: Minor
                    Found in kpack-image-builder/main.go - About 1 hr to fix

                      Method Client.Push has 12 return statements (exceeds 8 allowed).
                      Open

                      func (c Client) Push(ctx context.Context, creds Creds, repoRef string, zipReader io.Reader, tags ...string) (string, error) {
                      tmpFile, err := os.CreateTemp(os.TempDir(), "sourceimg-%s")
                      if err != nil {
                      return "", fmt.Errorf("failed to create a temp file for image: %w", err)
                      }
                      Severity: Major
                      Found in tools/image/client.go - About 50 mins to fix

                        Method ManagedBindingsReconciler.ReconcileResource has 12 return statements (exceeds 8 allowed).
                        Open

                        func (r *ManagedBindingsReconciler) ReconcileResource(ctx context.Context, cfServiceBinding *korifiv1alpha1.CFServiceBinding) (ctrl.Result, error) {
                        log := logr.FromContextOrDiscard(ctx).WithName("reconcile-managed-service-binding")
                         
                        assets, err := r.assets.GetServiceBindingAssets(ctx, cfServiceBinding)
                        if err != nil {
                        Severity: Major
                        Found in controllers/controllers/services/bindings/managed/controller.go - About 50 mins to fix

                          Function NewPackage has 7 arguments (exceeds 5 allowed). Consider refactoring.
                          Open

                          serverURL url.URL,
                          packageRepo CFPackageRepository,
                          appRepo CFAppRepository,
                          dropletRepo CFDropletRepository,
                          imageRepo ImageRepository,
                          Severity: Major
                          Found in api/handlers/package.go - About 45 mins to fix

                            Method KpackBuildController.Reconcile has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                            Open

                            func (c *KpackBuildController) Reconcile(ctx context.Context, req reconcile.Request) (ctrl.Result, error) {
                            log := c.log.WithName("KpackBuild").
                            WithValues("namespace", req.Namespace).
                            WithValues("name", req.Name).
                            WithValues("logID", uuid.NewString())
                            Severity: Minor
                            Found in kpack-image-builder/controllers/kpack_build_controller.go - About 45 mins to fix

                            Function NewProcess has 6 arguments (exceeds 5 allowed). Consider refactoring.
                            Open

                            serverURL url.URL,
                            processRepo CFProcessRepository,
                            requestValidator RequestValidator,
                            podRepo PodRepository,
                            gaugesCollector GaugesCollector,
                            Severity: Minor
                            Found in api/handlers/process.go - About 35 mins to fix

                              Function NewRoute has 6 arguments (exceeds 5 allowed). Consider refactoring.
                              Open

                              serverURL url.URL,
                              routeRepo CFRouteRepository,
                              domainRepo CFDomainRepository,
                              appRepo CFAppRepository,
                              spaceRepo CFSpaceRepository,
                              Severity: Minor
                              Found in api/handlers/route.go - About 35 mins to fix

                                Method ImageRepository.UploadSourceImage has 6 arguments (exceeds 5 allowed). Consider refactoring.
                                Open

                                func (r *ImageRepository) UploadSourceImage(ctx context.Context, authInfo authorization.Info, imageRef string, srcReader io.Reader, spaceGUID string, tags ...string) (string, error) {
                                Severity: Minor
                                Found in api/repositories/image_repository.go - About 35 mins to fix

                                  Function NewOrg has 6 arguments (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  func NewOrg(apiBaseURL url.URL, orgRepo CFOrgRepository, domainRepo CFDomainRepository, requestValidator RequestValidator, userCertificateExpirationWarningDuration time.Duration, defaultDomainName string) *Org {
                                  Severity: Minor
                                  Found in api/handlers/org.go - About 35 mins to fix

                                    Method Validator.ValidateUpdate has 9 return statements (exceeds 8 allowed).
                                    Open

                                    func (v *Validator) ValidateUpdate(ctx context.Context, oldObj, obj runtime.Object) (admission.Warnings, error) {
                                    route, ok := obj.(*korifiv1alpha1.CFRoute)
                                    if !ok {
                                    return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a CFRoute but got a %T", obj))
                                    }
                                    Severity: Major
                                    Found in controllers/webhooks/networking/routes/validator.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language