portainer/portainer

View on GitHub
api/git/service.go

Summary

Maintainability
A
1 hr
Test Coverage

Method Service.ListRefs has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
Open

func (service *Service) ListRefs(repositoryURL, username, password string, hardRefresh bool, tlsSkipVerify bool) ([]string, error) {
    refCacheKey := generateCacheKey(repositoryURL, username, password, strconv.FormatBool(tlsSkipVerify))
    if service.cacheEnabled && hardRefresh {
        // Should remove the cache explicitly, so that the following normal list can show the correct result
        service.repoRefCache.Remove(refCacheKey)
Severity: Minor
Found in api/git/service.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 Service.ListFiles has 5 return statements (exceeds 4 allowed).
Open

func (service *Service) ListFiles(repositoryURL, referenceName, username, password string, dirOnly, hardRefresh bool, includedExts []string, tlsSkipVerify bool) ([]string, error) {
    repoKey := generateCacheKey(repositoryURL, referenceName, username, password, strconv.FormatBool(tlsSkipVerify), strconv.FormatBool(dirOnly))

    if service.cacheEnabled && hardRefresh {
        // Should remove the cache explicitly, so that the following normal list can show the correct result
Severity: Major
Found in api/git/service.go - About 35 mins to fix

    There are no issues that match your filters.

    Category
    Status