Method Monocular.artifactHubGetIcon
has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring. Open
func (m *Monocular) artifactHubGetIcon(c echo.Context) error {
endpoint := c.Param("guid")
repo := c.Param("repo")
chartName := c.Param("name")
version := c.Param("version")
- Read upRead up
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 Monocular.artifactHubGetPackageInfo
has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring. Open
func (m *Monocular) artifactHubGetPackageInfo(endpointID, repo, name, version string) (*ahInfo, error) {
// Make sure we handle an empty version correctly
var cacheName string
var versionPart = ""
if len(version) > 0 {
- Read upRead up
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 Monocular.getChartURL
has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring. Open
func (m *Monocular) getChartURL(repoURL, name, version string) (string, error) {
httpClient := m.portalProxy.GetHttpClient(true)
helmIndexURL := joinURL(repoURL, "index.yaml")
resp, err := httpClient.Get(helmIndexURL)
- Read upRead up
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 Monocular.fetchChartsFromArtifactHub
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *Monocular) fetchChartsFromArtifactHub(c echo.Context, endpointID string) error {
cacheFolder := path.Join(m.CacheFolder, endpointID)
indexFile := path.Join(cacheFolder, "hub_index.json")
if ok := useCachedFile(indexFile); ok {
// Just send the cached file
Method Monocular.artifactHubGetIcon
has 8 return statements (exceeds 4 allowed). Open
func (m *Monocular) artifactHubGetIcon(c echo.Context) error {
endpoint := c.Param("guid")
repo := c.Param("repo")
chartName := c.Param("name")
version := c.Param("version")
Method Monocular.artifactHubCacheChartFiles
has 5 return statements (exceeds 4 allowed). Open
func (m *Monocular) artifactHubCacheChartFiles(endpointID, repoName, repoURL, name, version, digest string) (string, error) {
// First look to see if there is a digest file
cacheFolder := path.Join(m.CacheFolder, endpointID, fmt.Sprintf("%s_%s_%s", repoName, name, version))
if hasDigestFile(cacheFolder, digest) {
Method Monocular.getChartURL
has 5 return statements (exceeds 4 allowed). Open
func (m *Monocular) getChartURL(repoURL, name, version string) (string, error) {
httpClient := m.portalProxy.GetHttpClient(true)
helmIndexURL := joinURL(repoURL, "index.yaml")
resp, err := httpClient.Get(helmIndexURL)
Method Monocular.fetchChartsFromArtifactHub
has 5 return statements (exceeds 4 allowed). Open
func (m *Monocular) fetchChartsFromArtifactHub(c echo.Context, endpointID string) error {
cacheFolder := path.Join(m.CacheFolder, endpointID)
indexFile := path.Join(cacheFolder, "hub_index.json")
if ok := useCachedFile(indexFile); ok {
// Just send the cached file