cloudfoundry/stratos

View on GitHub
src/jetstream/plugins/kubernetes/helm/release.go

Summary

Maintainability
C
1 day
Test Coverage

Method HelmRelease.parseManifest has a Cognitive Complexity of 31 (exceeds 8 allowed). Consider refactoring.
Open

func (r *HelmRelease) parseManifest() {
    r.ManifestErrors = false
    reader := bytes.NewReader([]byte(r.Manifest))
    buffer := bufio.NewReader(reader)
    var bufr strings.Builder
Severity: Minor
Found in src/jetstream/plugins/kubernetes/helm/release.go - About 4 hrs 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 HelmRelease.processJsonResource has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring.
Open

func (r *HelmRelease) processJsonResource(obj interface{}) {
    data, err := json.Marshal(obj)
    if err == nil {
        var t KubeResource
        if err := json.Unmarshal(data, &t); err == nil {
Severity: Minor
Found in src/jetstream/plugins/kubernetes/helm/release.go - About 2 hrs 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 HelmRelease.UpdateResources has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

func (r *HelmRelease) UpdateResources(jetstream interfaces.PortalProxy) {
    // This will be an array of resources
    runner := NewKubeAPIJob(jetstream, r.Jobs)
    res := runner.Run()
    for _, j := range res {
Severity: Minor
Found in src/jetstream/plugins/kubernetes/helm/release.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

Avoid deeply nested control flow statements.
Open

                    if strings.HasPrefix(err.Error(), "no kind") {
                        var t interface{}
                        if err := yaml.Unmarshal(data, &t); err == nil {
                            r.processYamlResource(t, data)
                        } else {
Severity: Major
Found in src/jetstream/plugins/kubernetes/helm/release.go - About 45 mins to fix

    Method HelmRelease.UpdatePods has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
    Open

    func (r *HelmRelease) UpdatePods(jetstream interfaces.PortalProxy) {
        var jobs []KubeResourceJob
        for _, job := range r.PodJobs {
            jobs = append(jobs, job)
        }
    Severity: Minor
    Found in src/jetstream/plugins/kubernetes/helm/release.go - About 45 mins 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

    TODO found
    Open

            // TODO: If the resource was a job, process the selector again

    There are no issues that match your filters.

    Category
    Status