appuio/appuio-cloud-agent

View on GitHub
controllers/groupsync_controller.go

Summary

Maintainability
B
4 hrs
Test Coverage
D
62%

Method GroupSyncReconciler.Reconcile has 72 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (r *GroupSyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
    l := log.FromContext(ctx)
    l.Info("Reconciling Group")

    finalizerName := UpstreamFinalizerPrefix + r.ControlAPIFinalizerZoneName
Severity: Minor
Found in controllers/groupsync_controller.go - About 1 hr to fix

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

    func (r *GroupSyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
        l := log.FromContext(ctx)
        l.Info("Reconciling Group")
    
        finalizerName := UpstreamFinalizerPrefix + r.ControlAPIFinalizerZoneName
    Severity: Minor
    Found in controllers/groupsync_controller.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 GroupSyncReconciler.Reconcile has 11 return statements (exceeds 8 allowed).
    Open

    func (r *GroupSyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
        l := log.FromContext(ctx)
        l.Info("Reconciling Group")
    
        finalizerName := UpstreamFinalizerPrefix + r.ControlAPIFinalizerZoneName
    Severity: Major
    Found in controllers/groupsync_controller.go - About 45 mins to fix

      exported const UpstreamFinalizerPrefix should have comment or be unexported
      Open

      const UpstreamFinalizerPrefix = "agent.appuio.io/group-zone-"
      Severity: Minor
      Found in controllers/groupsync_controller.go by golint

      comment on exported method GroupSyncReconciler.SetupWithManagerAndForeignCluster should be of the form "SetupWithManagerAndForeignCluster ..."
      Open

      // SetupWithManager sets up the controller with the Manager.
      Severity: Minor
      Found in controllers/groupsync_controller.go by golint

      There are no issues that match your filters.

      Category
      Status