src/go/plugin/go.d/agent/module/job.go
File job.go
has 541 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
// SPDX-License-Identifier: GPL-3.0-or-later
package module
import (
Job
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Job struct {
pluginName string
name string
moduleName string
fullName string
Method Job.createChart
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (j *Job) createChart(chart *Chart) {
defer func() { chart.created = true }()
if chart.ignore {
return
}
Method Job.processMetrics
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
func (j *Job) processMetrics(metrics map[string]int64, startTime time.Time, sinceLastRun int) bool {
if !j.vnodeCreated {
if j.vnodeGUID == "" {
if v := j.module.VirtualNode(); v != nil && v.GUID != "" && v.Hostname != "" {
j.vnodeGUID = v.GUID
- 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 Job.updateChart
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (j *Job) updateChart(chart *Chart, collected map[string]int64, sinceLastRun int) bool {
if chart.ignore {
dims := chart.Dims[:0]
for _, dim := range chart.Dims {
if !dim.remove {
- 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"