Skip to content

Commit

Permalink
Enable gocyclo static check
Browse files Browse the repository at this point in the history
Signed-off-by: RainbowMango <[email protected]>
  • Loading branch information
RainbowMango committed Jun 22, 2021
1 parent dba61fa commit a81c714
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ linters:
- unused
- varcheck
# other linters supported by golangci-lint.
- gocyclo
- gosec
- whitespace

linters-settings:
goimports:
local-prefixes: github.com/karmada-io/karmada
gocyclo:
# minimal cyclomatic complexity to report
min-complexity: 15

issues:
# The list of ids of default excludes to include or disable. By default it's empty.
Expand Down
2 changes: 2 additions & 0 deletions pkg/karmadactl/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ func (j *CommandJoinOption) AddFlags(flags *pflag.FlagSet) {
}

// RunJoin is the implementation of the 'join' command.
//nolint:gocyclo
// Note: ignore the cyclomatic complexity issue to get gocyclo on board. Tracked by: https://github.com/karmada-io/karmada/issues/460
func RunJoin(cmdOut io.Writer, karmadaConfig KarmadaConfig, opts CommandJoinOption) error {
klog.V(1).Infof("joining cluster. cluster name: %s", opts.ClusterName)
klog.V(1).Infof("joining cluster. cluster namespace: %s", opts.ClusterNamespace)
Expand Down
2 changes: 2 additions & 0 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ func (s *Scheduler) getPlacement(resourceBinding *workv1alpha1.ResourceBinding)
return placement, string(placementBytes), nil
}

//nolint:gocyclo
// Note: ignore the cyclomatic complexity issue to get gocyclo on board. Tracked by: https://github.com/karmada-io/karmada/issues/460
func (s *Scheduler) getScheduleType(key string) ScheduleType {
ns, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/helper/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ func FetchWorkload(dynamicClient dynamic.Interface, restMapper meta.RESTMapper,
}

// EnsureWork ensure Work to be created or updated.
//nolint:gocyclo
// Note: ignore the cyclomatic complexity issue to get gocyclo on board. Tracked by: https://github.com/karmada-io/karmada/issues/460
func EnsureWork(c client.Client, workload *unstructured.Unstructured, clusterNames []string, overrideManager overridemanager.OverrideManager,
binding metav1.Object, scope apiextensionsv1.ResourceScope) error {
referenceRSP, desireReplicaInfos, err := calculateReplicasIfNeeded(c, workload, clusterNames)
Expand Down
3 changes: 3 additions & 0 deletions pkg/util/objectwatcher/retain.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func retainPodFields(desiredObj, clusterObj *unstructured.Unstructured) error {
return nil
}

// retainServiceFields updates the desired service object with values retained from the cluster object.
//nolint:gocyclo
// Note: ignore the cyclomatic complexity issue to get gocyclo on board. Tracked by: https://github.com/karmada-io/karmada/issues/460
func retainServiceFields(desiredObj, clusterObj *unstructured.Unstructured) error {
// healthCheckNodePort is allocated by APIServer and unchangeable, so it should be retained while updating
healthCheckNodePort, ok, err := unstructured.NestedInt64(clusterObj.Object, "spec", "healthCheckNodePort")
Expand Down

0 comments on commit a81c714

Please sign in to comment.