firehol/netdata

View on GitHub

Showing 1,088 of 2,665 total issues

Function urlopen has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def urlopen(self, method, url, body=None, headers=None, retries=3,

    Function __new__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __new__(cls, scheme=None, auth=None, host=None, port=None, path=None,
    Severity: Major
    Found in src/collectors/python.d.plugin/python_modules/urllib3/util/url.py - About 50 mins to fix

      Function set_cert has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def set_cert(self, key_file=None, cert_file=None,
      Severity: Major
      Found in src/collectors/python.d.plugin/python_modules/urllib3/connection.py - About 50 mins to fix

        Function request_encode_body has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def request_encode_body(self, method, url, fields=None, headers=None,
        Severity: Major
        Found in src/collectors/python.d.plugin/python_modules/urllib3/request.py - About 50 mins to fix

          Function urlopen has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def urlopen(self, method, url, body=None, headers=None,
          Severity: Major
          Found in src/collectors/python.d.plugin/python_modules/urllib3/request.py - About 50 mins to fix

            Method Manager.dyncfgConfigTest has 8 return statements (exceeds 4 allowed).
            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)
            Severity: Major
            Found in src/go/plugin/go.d/agent/jobmgr/dyncfg.go - About 50 mins to fix

              Method PgBouncer.collect has 8 return statements (exceeds 4 allowed).
              Open

              func (p *PgBouncer) collect() (map[string]int64, error) {
                  if p.db == nil {
                      if err := p.openConnection(); err != nil {
                          return nil, err
                      }
              Severity: Major
              Found in src/go/plugin/go.d/modules/pgbouncer/collect.go - About 50 mins to fix

                Method Vnodes.readConfDir has 8 return statements (exceeds 4 allowed).
                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
                Severity: Major
                Found in src/go/plugin/go.d/agent/vnodes/vnodes.go - About 50 mins to fix

                  Method CouchDB.initCharts has 8 return statements (exceeds 4 allowed).
                  Open

                  func (cdb *CouchDB) initCharts() (*Charts, error) {
                      charts := module.Charts{}
                  
                      if err := charts.Add(*dbActivityCharts.Copy()...); err != nil {
                          return nil, err
                  Severity: Major
                  Found in src/go/plugin/go.d/modules/couchdb/init.go - About 50 mins to fix

                    Function matchChunk has 8 return statements (exceeds 4 allowed).
                    Open

                    func matchChunk(chunk, s string) (rest string, ok bool, err error) {
                        for len(chunk) > 0 {
                            if len(s) == 0 {
                                return
                            }
                    Severity: Major
                    Found in src/go/pkg/matcher/glob.go - About 50 mins to fix

                      Method prometheus.fetch has 8 return statements (exceeds 4 allowed).
                      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 {
                      Severity: Major
                      Found in src/go/plugin/go.d/pkg/prometheus/client.go - About 50 mins to fix

                        Function Exec has 8 return statements (exceeds 4 allowed).
                        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 != "" {
                        Severity: Major
                        Found in src/go/plugin/go.d/pkg/dockerhost/dockerhost.go - About 50 mins to fix

                          Function userConfigFromPayload has 7 return statements (exceeds 4 allowed).
                          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())
                              }
                          
                          
                          Severity: Major
                          Found in src/go/plugin/go.d/agent/jobmgr/dyncfg.go - About 45 mins to fix

                            Method Manager.dyncfgConfigEnable has 7 return statements (exceeds 4 allowed).
                            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)
                            Severity: Major
                            Found in src/go/plugin/go.d/agent/jobmgr/dyncfg.go - About 45 mins to fix

                              Function readICMPResponse has 7 return statements (exceeds 4 allowed).
                              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)
                              Severity: Major
                              Found in src/go/plugin/go.d/modules/portcheck/check_udp_port.go - About 45 mins to fix

                                Method socketClient.getStatus has 7 return statements (exceeds 4 allowed).
                                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)
                                    }
                                Severity: Major
                                Found in src/go/plugin/go.d/modules/phpfpm/client.go - About 45 mins to fix

                                  Function validateClassifyConfig has 7 return statements (exceeds 4 allowed).
                                  Open

                                  func validateClassifyConfig(rules []ClassifyRuleConfig) error {
                                      if len(rules) == 0 {
                                          return errors.New("empty config, need least 1 rule")
                                      }
                                      for i, rule := range rules {
                                  Severity: Major
                                  Found in src/go/plugin/go.d/agent/discovery/sd/pipeline/config.go - About 45 mins to fix

                                    Method Cassandra.processMetric has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                                    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")
                                    Severity: Minor
                                    Found in src/go/plugin/go.d/modules/cassandra/collect.go - About 45 mins to fix

                                    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

                                    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
                                        }
                                    Severity: Major
                                    Found in src/go/plugin/go.d/modules/ceph/auth.go - About 45 mins to fix

                                      Method ClickHouse.collect has 7 return statements (exceeds 4 allowed).
                                      Open

                                      func (c *ClickHouse) collect() (map[string]int64, error) {
                                          mx := make(map[string]int64)
                                      
                                          if err := c.collectSystemEvents(mx); err != nil {
                                              return nil, err
                                      Severity: Major
                                      Found in src/go/plugin/go.d/modules/clickhouse/collect.go - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language