fabmation-gmbh/helm-whatup

View on GitHub
main.go

Summary

Maintainability
D
2 days
Test Coverage

Function searchChart has a Cognitive Complexity of 63 (exceeds 20 allowed). Consider refactoring.
Open

func searchChart(r []*search.Result, release *release.Release, devel bool) (searchResult, bool, error) {
    ret := searchResult{}

    // trackedRepos keeps information about a repository we already tracked.
    type trackedRepos struct {
Severity: Minor
Found in main.go - About 7 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

File main.go has 612 lines of code (exceeds 500 allowed). Consider refactoring.
Open

/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Severity: Minor
Found in main.go - About 4 hrs to fix

Function searchChart has 140 lines of code (exceeds 50 allowed). Consider refactoring.
Wontfix

func searchChart(r []*search.Result, release *release.Release, devel bool) (searchResult, bool, error) {
    ret := searchResult{}

    // trackedRepos keeps information about a repository we already tracked.
    type trackedRepos struct {
Severity: Major
Found in main.go - About 4 hrs to fix

Function newOutdatedListWriter has 66 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func newOutdatedListWriter(releases []*release.Release, cfg *action.Configuration, out io.Writer, devel bool) *outdatedListWriter {
    var err error

    outdated := make([]outdatedElement, 0, len(releases))
    dups := make([]repoDuplicate, 0, len(releases))
Severity: Minor
Found in main.go - About 1 hr to fix

Function newOutdatedCmd has 56 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func newOutdatedCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
    client := action.NewList(cfg)
    var outfmt output.Format

    cmd := &cobra.Command{
Severity: Minor
Found in main.go - About 1 hr to fix

Function searchChart has 9 return statements (exceeds 4 allowed).
Open

func searchChart(r []*search.Result, release *release.Release, devel bool) (searchResult, bool, error) {
    ret := searchResult{}

    // trackedRepos keeps information about a repository we already tracked.
    type trackedRepos struct {
Severity: Major
Found in main.go - About 55 mins to fix

Function newOutdatedListWriter has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
Open

func newOutdatedListWriter(releases []*release.Release, cfg *action.Configuration, out io.Writer, devel bool) *outdatedListWriter {
    var err error

    outdated := make([]outdatedElement, 0, len(releases))
    dups := make([]repoDuplicate, 0, len(releases))
Severity: Minor
Found in main.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

Function newOutdatedCmd has 7 return statements (exceeds 4 allowed).
Open

func newOutdatedCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
    client := action.NewList(cfg)
    var outfmt output.Format

    cmd := &cobra.Command{
Severity: Major
Found in main.go - About 45 mins to fix

2: cannot find package "github.com/Masterminds/semver/v3" in any of:
Open

    "github.com/Masterminds/semver/v3"
Severity: Minor
Found in main.go by govet

BUG found
Open

                // the repo is tracked if not then we have BUG.
Severity: Minor
Found in main.go by fixme

TODO found
Open

    // TODO(l0nax): Correct me
Severity: Minor
Found in main.go by fixme

TODO found
Open

        // TODO: Find a better way to exit
Severity: Minor
Found in main.go by fixme

TODO found
Open

        // // TODO(l0nax): refactor me ==> @duplicate append MUST be moved out of this if-block! */
Severity: Minor
Found in main.go by fixme

TODO found
Open

            // TODO: should print to stderr
Severity: Minor
Found in main.go by fixme

TODO found
Open

    // TODO: implement a better search algorithm. Because this is an linear search algorithm so it takes O(len(r)) steps in the
Severity: Minor
Found in main.go by fixme

TODO found
Open

// TODO(l0nax): Implement me
Severity: Minor
Found in main.go by fixme

Your code does not pass gofmt in 2 places. Go fmt your code!
Open

/*
Severity: Minor
Found in main.go by gofmt

exported const CHART should have comment (or a comment on this block) or be unexported
Open

    CHART searchType = iota + 1 // CHART search results do contain only one repository which has been found
Severity: Minor
Found in main.go by golint

There are no issues that match your filters.

Category
Status