firehol/netdata

View on GitHub

Showing 1,088 of 2,665 total issues

Function increment has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def increment(self, method=None, url=None, response=None, error=None,
Severity: Minor
Found in src/collectors/python.d.plugin/python_modules/urllib3/util/retry.py - About 45 mins to fix

    Function add_metaclass has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_metaclass(metaclass):
        """Class decorator for creating a class with a metaclass."""
        def wrapper(cls):
            orig_vars = cls.__dict__.copy()
            slots = orig_vars.get('__slots__')
    Severity: Minor
    Found in src/collectors/python.d.plugin/python_modules/urllib3/packages/six.py - 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

    Function _make_request has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _make_request(self, conn, method, url, timeout=_Default, chunked=False,
    Severity: Minor
    Found in src/collectors/python.d.plugin/python_modules/urllib3/connectionpool.py - About 45 mins to fix

      Function _cert_array_from_pem has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def _cert_array_from_pem(pem_bundle):
          """
          Given a bundle of certs in PEM format, turns them into a CFArray of certs
          that can be used to validate a cert chain.
          """

      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 create_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def create_data(self, df_allmetrics):
              """Use x, mean, stddev to generate z scores and 3stddev flags via some pandas manipulation.
              Returning two dictionaries of dimensions and measures, one for each chart.
      
              :param df_allmetrics <pd.DataFrame>: pandas dataframe with latest data from api/v1/allmetrics.
      Severity: Minor
      Found in src/collectors/python.d.plugin/zscores/zscores.chart.py - 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

      Function get_data_per_code_family has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_data_per_code_family(self, raw_data):
              data = defaultdict(int)
              for code, value in raw_data['total_status_code_count'].items():
                  code_prefix = code[0]
                  if code_prefix == '1':
      Severity: Minor
      Found in src/collectors/python.d.plugin/traefik/traefik.chart.py - 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

      Function write_to_file has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def write_to_file(path, md, meta_yaml, sidebar_label, community, mode='default'):
      Severity: Minor
      Found in integrations/gen_docs_integrations.py - About 45 mins to fix

        Method SNMP.Init has 6 return statements (exceeds 4 allowed).
        Open

        func (s *SNMP) Init() error {
            err := s.validateConfig()
            if err != nil {
                s.Errorf("config validation failed: %v", err)
                return err
        Severity: Major
        Found in src/go/plugin/go.d/modules/snmp/snmp.go - About 40 mins to fix

          Function parseWhoisInfoExpirationDate has 6 return statements (exceeds 4 allowed).
          Open

          func parseWhoisInfoExpirationDate(info *whoisparser.WhoisInfo) (float64, error) {
              if info == nil || info.Domain == nil {
                  return 0, errors.New("nil Whois Info")
              }
          
          
          Severity: Major
          Found in src/go/plugin/go.d/modules/whoisquery/provider.go - About 40 mins to fix

            Method torControlClient.getInfo has 6 return statements (exceeds 4 allowed).
            Open

            func (c *torControlClient) getInfo(keywords ...string) ([]byte, error) {
                // https://spec.torproject.org/control-spec/commands.html#getinfo
            
                if len(keywords) == 0 {
                    return nil, errors.New("no keywords specified")
            Severity: Major
            Found in src/go/plugin/go.d/modules/tor/client.go - About 40 mins to fix

              Method Manager.dyncfgConfigRestart has 6 return statements (exceeds 4 allowed).
              Open

              func (m *Manager) dyncfgConfigRestart(fn functions.Function) {
                  id := fn.Args[0]
                  mn, jn, ok := extractModuleJobName(id)
                  if !ok {
                      m.Warningf("dyncfg: restart: could not extract module from id (%s)", id)
              Severity: Major
              Found in src/go/plugin/go.d/agent/jobmgr/dyncfg.go - About 40 mins to fix

                Function doMetaGKEHTTPReq has 6 return statements (exceeds 4 allowed).
                Open

                func doMetaGKEHTTPReq(client *http.Client, url string) (string, error) {
                    req, err := http.NewRequest(http.MethodGet, url, nil)
                    if err != nil {
                        return "", err
                    }
                Severity: Major
                Found in src/go/plugin/go.d/modules/k8s_state/cluster_meta.go - About 40 mins to fix

                  Method tcpClient.getStatus has 6 return statements (exceeds 4 allowed).
                  Open

                  func (c *tcpClient) getStatus() (*status, error) {
                      client, err := fcgiclient.DialTimeout("tcp", c.address, c.timeout)
                      if err != nil {
                          return nil, fmt.Errorf("error on connecting to address '%s': %v", c.address, err)
                      }
                  Severity: Major
                  Found in src/go/plugin/go.d/modules/phpfpm/client.go - About 40 mins to fix

                    Method Consul.collect has 6 return statements (exceeds 4 allowed).
                    Open

                    func (c *Consul) collect() (map[string]int64, error) {
                        if c.cfg == nil {
                            if err := c.collectConfiguration(); err != nil {
                                return nil, err
                            }
                    Severity: Major
                    Found in src/go/plugin/go.d/modules/consul/collect.go - About 40 mins to fix

                      Method OracleDB.collect has 6 return statements (exceeds 4 allowed).
                      Open

                      func (o *OracleDB) collect() (map[string]int64, error) {
                          if o.db == nil {
                              if err := o.openConnection(); err != nil {
                                  return nil, fmt.Errorf("failed to open connection: %v", err)
                              }
                      Severity: Major
                      Found in src/go/plugin/go.d/modules/oracledb/collect.go - About 40 mins to fix

                        Function validateComposeConfig has 6 return statements (exceeds 4 allowed).
                        Open

                        func validateComposeConfig(rules []ComposeRuleConfig) 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 40 mins to fix

                          Function parsePostqueueOutput has 6 return statements (exceeds 4 allowed).
                          Open

                          func parsePostqueueOutput(bs []byte) (*postqueueStats, error) {
                              if len(bs) == 0 {
                                  return nil, errors.New("empty postqueue output")
                              }
                          
                          
                          Severity: Major
                          Found in src/go/plugin/go.d/modules/postfix/collect.go - About 40 mins to fix

                            Method Manager.dyncfgConfigAdd has 6 return statements (exceeds 4 allowed).
                            Open

                            func (m *Manager) dyncfgConfigAdd(fn functions.Function) {
                                if len(fn.Args) < 3 {
                                    m.Warningf("dyncfg: add: missing required arguments, want 3 got %d", len(fn.Args))
                                    m.dyncfgRespf(fn, 400, "Missing required arguments. Need at least 3, but got %d.", len(fn.Args))
                                    return
                            Severity: Major
                            Found in src/go/plugin/go.d/agent/jobmgr/dyncfg.go - About 40 mins to fix

                              Method Client.get has 6 return statements (exceeds 4 allowed).
                              Open

                              func (c *Client) get(command string, stopRead stopReadFunc) (output []string, err error) {
                                  var num int
                                  var maxLinesErr error
                                  err = c.Command(command, func(bytes []byte) bool {
                                      line := string(bytes)
                              Severity: Major
                              Found in src/go/plugin/go.d/modules/openvpn/client/client.go - About 40 mins to fix

                                Method beanstalkClient.query has 6 return statements (exceeds 4 allowed).
                                Open

                                func (c *beanstalkClient) query(command string) (string, []byte, error) {
                                    var resp string
                                    var length int
                                    var body []byte
                                    var err error
                                Severity: Major
                                Found in src/go/plugin/go.d/modules/beanstalk/client.go - About 40 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language