Showing 1,088 of 2,665 total issues
Method beanstalkClient.queryStatsTube
has 5 return statements (exceeds 4 allowed). Open
func (c *beanstalkClient) queryStatsTube(tubeName string) (*tubeStats, error) {
cmd := fmt.Sprintf("%s %s", cmdStatsTube, tubeName)
resp, data, err := c.query(cmd)
if err != nil {
Method upsdClient.authenticate
has 5 return statements (exceeds 4 allowed). Open
func (c *upsdClient) authenticate(username, password string) error {
cmd := fmt.Sprintf(commandUsername, username)
resp, err := c.sendCommand(cmd)
if err != nil {
return err
Method Agent.buildDiscoveryConf
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (a *Agent) buildDiscoveryConf(enabled module.Registry) discovery.Config {
a.Info("building discovery config")
reg := confgroup.Registry{}
for name, creator := range enabled {
- 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 newUserInputCharts
has 5 return statements (exceeds 4 allowed). Open
func newUserInputCharts(configs []ChartConfig) (*module.Charts, error) {
charts := &module.Charts{}
for _, cfg := range configs {
if len(cfg.IndexRange) == 2 {
cs, err := newUserInputChartsFromIndexRange(cfg)
Method MockScaleIOAPIServer.handleQuerySelectedStatistics
has 5 return statements (exceeds 4 allowed). Open
func (s MockScaleIOAPIServer) handleQuerySelectedStatistics(w http.ResponseWriter, r *http.Request) {
if _, pass, ok := r.BasicAuth(); !ok || pass != s.Token {
w.WriteHeader(http.StatusUnauthorized)
msg := fmt.Sprintf("token got/expected: %s/%s", pass, s.Token)
writeAPIError(w, msg)
Method ActiveMQ.Init
has 5 return statements (exceeds 4 allowed). Open
func (a *ActiveMQ) Init() error {
if err := a.validateConfig(); err != nil {
a.Errorf("config validation: %v", err)
return err
}
Method OracleDB.doQuery
has 5 return statements (exceeds 4 allowed). Open
func (o *OracleDB) doQuery(query string, assign func(column, value string, lineEnd bool) error) error {
ctx, cancel := context.WithTimeout(context.Background(), o.Timeout.Duration())
defer cancel()
rows, err := o.db.QueryContext(ctx, query)
Method Postgres.doQueryDatabasesMetrics
has 5 return statements (exceeds 4 allowed). Open
func (p *Postgres) doQueryDatabasesMetrics() error {
if err := p.doQueryDatabaseStats(); err != nil {
return fmt.Errorf("querying database stats error: %v", err)
}
if err := p.doQueryDatabaseSize(); err != nil {
Method SystemdUnits.collect
has 5 return statements (exceeds 4 allowed). Open
func (s *SystemdUnits) collect() (map[string]int64, error) {
conn, err := s.getConnection()
if err != nil {
return nil, err
}
Function parse
has 5 return statements (exceeds 4 allowed). Open
func parse(path string) ([]clientInfo, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
Method IntelGPU.getGPUSummaryStats
has 5 return statements (exceeds 4 allowed). Open
func (ig *IntelGPU) getGPUSummaryStats() (*gpuSummaryStats, error) {
bs, err := ig.exec.queryGPUSummaryJson()
if err != nil {
return nil, err
}
Method HTTPCheck.Init
has 5 return statements (exceeds 4 allowed). Open
func (hc *HTTPCheck) Init() error {
if err := hc.validateConfig(); err != nil {
hc.Errorf("config validation: %v", err)
return err
}
Method Unbound.updateCharts
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (u *Unbound) updateCharts() {
if len(u.curCache.threads) > 1 {
for v := range u.curCache.threads {
if !u.cache.threads[v] {
u.cache.threads[v] = true
- 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 Unbound.initConfig
has 5 return statements (exceeds 4 allowed). Open
func (u *Unbound) initConfig() (enabled bool) {
if u.ConfPath == "" {
u.Info("'conf_path' not set, skipping parameters auto detection")
return true
}
Function addURLCharts
has 5 return statements (exceeds 4 allowed). Open
func addURLCharts(charts *Charts, patterns []userPattern) error {
if len(patterns) == 0 {
return nil
}
chart, err := newURLPatternChart(patterns)
Method Apache.scrapeStatus
has 5 return statements (exceeds 4 allowed). Open
func (a *Apache) scrapeStatus() (*serverStatus, error) {
req, err := web.NewHTTPRequest(a.RequestConfig)
if err != nil {
return nil, err
}
Method Ceph.authLogout
has 5 return statements (exceeds 4 allowed). Open
func (c *Ceph) authLogout() error {
// https://docs.ceph.com/en/reef/mgr/ceph_api/#post--api-auth-logout
if c.token == "" {
return nil
Function parse
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func parse(filename string, visited map[string]bool) ([]option, error) {
if visited == nil {
visited = make(map[string]bool)
}
if visited[filename] {
- 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 Docker.collect
has 5 return statements (exceeds 4 allowed). Open
func (d *Docker) collect() (map[string]int64, error) {
if d.client == nil {
client, err := d.newClient(d.Config)
if err != nil {
return nil, err
Method IPFS.collect
has 5 return statements (exceeds 4 allowed). Open
func (ip *IPFS) collect() (map[string]int64, error) {
mx := make(map[string]int64)
if err := ip.collectStatsBandwidth(mx); err != nil {
return nil, err