src/jetstream/plugins/monocular/cache.go
Function extractArchiveFiles
has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring. Open
Open
func extractArchiveFiles(archivePath, chartName, downloadFolder string, filenames []string) error {
// Map the filenames array into a map of path to destination file
requiredFiles := make(map[string]string)
requiredCount := len(filenames)
for _, name := range filenames {
- 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.cleanCacheFiles
has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring. Open
Open
func (m *Monocular) cleanCacheFiles(endpointID string, allCharts []store.ChartStoreRecord) error {
// Build map of the valid chart folder names
validFiles := make(map[string]bool)
for _, chart := range allCharts {
- 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
Function extractArchiveFiles
has 6 return statements (exceeds 4 allowed). Open
Open
func extractArchiveFiles(archivePath, chartName, downloadFolder string, filenames []string) error {
// Map the filenames array into a map of path to destination file
requiredFiles := make(map[string]string)
requiredCount := len(filenames)
for _, name := range filenames {
Method Monocular.cacheChartFromURL
has 6 return statements (exceeds 4 allowed). Open
Open
func (m *Monocular) cacheChartFromURL(chartCachePath, digest, name, chartURL string) error {
// Check to see if we have the same digest
if ok := hasDigestFile(chartCachePath, digest); ok {
log.Debug("Skipping download - already have archive with the same digest")
return nil