Merge pull request #461 from RainbowMango/pr_enable_gocyclo

Enable gocyclo static check
This commit is contained in:
karmada-bot 2021-06-23 09:41:06 +08:00 committed by GitHub
commit 2a8dd53604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 0 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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 {

View File

@ -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)

View File

@ -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")