Showing 1,088 of 2,665 total issues
Function urlopen
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def urlopen(self, method, url, body=None, headers=None, retries=3,
Function __new__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __new__(cls, scheme=None, auth=None, host=None, port=None, path=None,
Function set_cert
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def set_cert(self, key_file=None, cert_file=None,
Function request_encode_body
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def request_encode_body(self, method, url, fields=None, headers=None,
Function urlopen
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def urlopen(self, method, url, body=None, headers=None,
Method Manager.dyncfgConfigTest
has 8 return statements (exceeds 4 allowed). Open
Open
func (m *Manager) dyncfgConfigTest(fn functions.Function) {
id := fn.Args[0]
mn, ok := extractModuleName(id)
if !ok {
m.Warningf("dyncfg: test: could not extract module and job from id (%s)", id)
Method PgBouncer.collect
has 8 return statements (exceeds 4 allowed). Open
Open
func (p *PgBouncer) collect() (map[string]int64, error) {
if p.db == nil {
if err := p.openConnection(); err != nil {
return nil, err
}
Method Vnodes.readConfDir
has 8 return statements (exceeds 4 allowed). Open
Open
func (vn *Vnodes) readConfDir() {
_ = filepath.WalkDir(vn.confDir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
vn.Warning(err)
return nil
Method CouchDB.initCharts
has 8 return statements (exceeds 4 allowed). Open
Open
func (cdb *CouchDB) initCharts() (*Charts, error) {
charts := module.Charts{}
if err := charts.Add(*dbActivityCharts.Copy()...); err != nil {
return nil, err
Function matchChunk
has 8 return statements (exceeds 4 allowed). Open
Open
func matchChunk(chunk, s string) (rest string, ok bool, err error) {
for len(chunk) > 0 {
if len(s) == 0 {
return
}
Method prometheus.fetch
has 8 return statements (exceeds 4 allowed). Open
Open
func (p *prometheus) fetch(w io.Writer) error {
// TODO: should be a separate text file prom client
if p.filepath != "" {
f, err := os.Open(p.filepath)
if err != nil {
Function Exec
has 8 return statements (exceeds 4 allowed). Open
Open
func Exec(ctx context.Context, container string, cmd string, args ...string) ([]byte, error) {
// based on https://github.com/moby/moby/blob/8e610b2b55bfd1bfa9436ab110d311f5e8a74dcb/integration/internal/container/exec.go#L38
addr := docker.DefaultDockerHost
if v := FromEnv(); v != "" {
Function userConfigFromPayload
has 7 return statements (exceeds 4 allowed). Open
Open
func userConfigFromPayload(cfg any, jobName string, fn functions.Function) ([]byte, error) {
if v := reflect.ValueOf(cfg); v.Kind() != reflect.Ptr || v.IsNil() {
return nil, fmt.Errorf("invalid config: expected a pointer to a struct, got a %s", v.Type())
}
Method Manager.dyncfgConfigEnable
has 7 return statements (exceeds 4 allowed). Open
Open
func (m *Manager) dyncfgConfigEnable(fn functions.Function) {
id := fn.Args[0]
mn, jn, ok := extractModuleJobName(id)
if !ok {
m.Warningf("dyncfg: enable: could not extract module and job from id (%s)", id)
Function readICMPResponse
has 7 return statements (exceeds 4 allowed). Open
Open
func readICMPResponse(icmpConn *icmp.PacketConn, udpConn *net.UDPConn, icmpProto int, timeout time.Duration) (bool, error) {
buff := make([]byte, 1500)
if err := icmpConn.SetReadDeadline(time.Now().Add(timeout)); err != nil {
return false, fmt.Errorf("failed to set read deadline on ICMP connection: %w", err)
Method socketClient.getStatus
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *socketClient) getStatus() (*status, error) {
socket, err := fcgiclient.DialTimeout("unix", c.socket, c.timeout)
if err != nil {
return nil, fmt.Errorf("error on connecting to socket '%s': %v", c.socket, err)
}
Function validateClassifyConfig
has 7 return statements (exceeds 4 allowed). Open
Open
func validateClassifyConfig(rules []ClassifyRuleConfig) error {
if len(rules) == 0 {
return errors.New("empty config, need least 1 rule")
}
for i, rule := range rules {
Method Cassandra.processMetric
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (c *Cassandra) processMetric(mx map[string]int64) {
c.mx.clientReqTotalLatencyReads.write(mx, "client_request_total_latency_reads")
c.mx.clientReqTotalLatencyWrites.write(mx, "client_request_total_latency_writes")
c.mx.clientReqLatencyReads.write(mx, "client_request_latency_reads")
c.mx.clientReqLatencyWrites.write(mx, "client_request_latency_writes")
- 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 Ceph.authCheck
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *Ceph) authCheck() (bool, error) {
// https://docs.ceph.com/en/reef/mgr/ceph_api/#post--api-auth-check
if c.token == "" {
return false, nil
}
Method ClickHouse.collect
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *ClickHouse) collect() (map[string]int64, error) {
mx := make(map[string]int64)
if err := c.collectSystemEvents(mx); err != nil {
return nil, err