firehol/netdata

View on GitHub

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 {
Severity: Major
Found in src/go/plugin/go.d/modules/beanstalk/client.go - About 35 mins to fix

    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
    Severity: Major
    Found in src/go/plugin/go.d/modules/upsd/client.go - About 35 mins to fix

      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 {
      Severity: Minor
      Found in src/go/plugin/go.d/agent/setup.go - About 35 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

      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)
      Severity: Major
      Found in src/go/plugin/go.d/modules/snmp/charts.go - About 35 mins to fix

        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)
        Severity: Major
        Found in src/go/plugin/go.d/modules/scaleio/client/server.go - About 35 mins to fix

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

            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)
            Severity: Major
            Found in src/go/plugin/go.d/modules/oracledb/collect.go - About 35 mins to fix

              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 {
              Severity: Major
              Found in src/go/plugin/go.d/modules/postgres/do_query_databases.go - About 35 mins to fix

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

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

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

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

                        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
                        Severity: Minor
                        Found in src/go/plugin/go.d/modules/unbound/charts.go - About 35 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 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
                            }
                        Severity: Major
                        Found in src/go/plugin/go.d/modules/unbound/init.go - About 35 mins to fix

                          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)
                          Severity: Major
                          Found in src/go/plugin/go.d/modules/weblog/charts.go - About 35 mins to fix

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

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

                                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] {
                                Severity: Minor
                                Found in src/go/plugin/go.d/modules/unbound/config/parse.go - About 35 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 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
                                Severity: Major
                                Found in src/go/plugin/go.d/modules/docker/collect.go - About 35 mins to fix

                                  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
                                  Severity: Major
                                  Found in src/go/plugin/go.d/modules/ipfs/collect.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language