src/go/plugin/go.d/modules/k8s_state/collect.go
Method KubeState.collectPodsState
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
Open
func (ks *KubeState) collectPodsState(mx map[string]int64) {
now := time.Now()
for _, ps := range ks.state.pods {
// Skip cronjobs (each of them is a unique container because name contains hash)
// to avoid overwhelming Netdata with high cardinality metrics.
- 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 KubeState.collectPodsState
has 105 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (ks *KubeState) collectPodsState(mx map[string]int64) {
now := time.Now()
for _, ps := range ks.state.pods {
// Skip cronjobs (each of them is a unique container because name contains hash)
// to avoid overwhelming Netdata with high cardinality metrics.
Method KubeState.collectNodesState
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (ks *KubeState) collectNodesState(mx map[string]int64) {
now := time.Now()
for _, ns := range ks.state.nodes {
if ns.deleted {
delete(ks.state.nodes, nodeSource(ns.name))