firehol/netdata

View on GitHub

Showing 1,088 of 2,665 total issues

Function getIntlNumberFormat has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    getIntlNumberFormat: function (min, max) {
        let key = max;
        if (min === max) {
            if (typeof this.formattersFixed[key] === 'undefined') {
                this.formattersFixed[key] = new Intl.NumberFormat(undefined, {
Severity: Minor
Found in src/web/gui/v1/dashboard.js - About 1 hr to fix

    Function delete has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        delete: function (delete_url, callback) {
            // send DELETE to a netdata registry:
            $.ajax({
                url: NETDATA.registry.server + '/api/v1/registry?action=delete&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault) + '&delete_url=' + encodeURIComponent(delete_url),
                async: true,
    Severity: Minor
    Found in src/web/gui/v1/dashboard.js - About 1 hr to fix

      Function search has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          search: function (machine_guid, callback) {
              // SEARCH for the URLs of a machine:
              $.ajax({
                  url: NETDATA.registry.server + '/api/v1/registry?action=search&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault) + '&for=' + machine_guid,
                  async: true,
      Severity: Minor
      Found in src/web/gui/v1/dashboard.js - About 1 hr to fix

        Function switch has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            switch: function (new_person_guid, callback) {
                // impersonate
                $.ajax({
                    url: NETDATA.registry.server + '/api/v1/registry?action=switch&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault) + '&to=' + new_person_guid,
                    async: true,
        Severity: Minor
        Found in src/web/gui/v1/dashboard.js - About 1 hr to fix

          Function mergeAgents has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function mergeAgents(cloud, local) {
              let dirty = false;
          
              const union = new Map();
          
          
          Severity: Minor
          Found in src/web/gui/main.js - About 1 hr to fix

            Function netdataPrepCallback has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            var netdataPrepCallback = function () {
                NETDATA.requiredCSS.push({
                    url: NETDATA.serverStatic + 'css/bootstrap-toggle-2.2.2.min.css',
                    isAlreadyLoaded: function () {
                        return false;
            Severity: Minor
            Found in src/web/gui/main.js - About 1 hr to fix

              Function getGCSLatestVersion has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function getGCSLatestVersion(callback) {
                  versionLog('Downloading latest version id from GCS...');
                  $.ajax({
                      url: "https://www.googleapis.com/storage/v1/b/netdata-nightlies/o/latest-version.txt",
                      async: true,
              Severity: Minor
              Found in src/web/gui/main.js - About 1 hr to fix

                Function syncAgents has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function syncAgents(callback) {
                    const json = localStorage.getItem("cloud.sync");
                    const sync = json ? JSON.parse(json) : {};
                
                    const currentAgent = {
                Severity: Minor
                Found in src/web/gui/main.js - About 1 hr to fix

                  Function emit has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def emit(events, stream=None, Dumper=Dumper,
                  Severity: Major
                  Found in src/collectors/python.d.plugin/python_modules/pyyaml3/__init__.py - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                if not double and ch == '\'' and self.peek(1) == '\'':
                                    chunks.append('\'')
                                    self.forward(2)
                                elif (double and ch == '\'') or (not double and ch in '\"\\'):
                                    chunks.append(ch)
                    Severity: Major
                    Found in src/collectors/python.d.plugin/python_modules/pyyaml3/scanner.py - About 1 hr to fix

                      Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def __init__(self, scalar, empty, multiline,
                      Severity: Major
                      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                                    if (not (self.simple_key_context and
                                            (self.analysis.empty or self.analysis.multiline))
                                        and (self.flow_level and self.analysis.allow_flow_plain
                                            or (not self.flow_level and self.analysis.allow_block_plain))):
                                        return ''
                        Severity: Major
                        Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 1 hr to fix

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

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

                            Function handshake has 8 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def handshake(self,

                              Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def __init__(self, host, port=None, key_file=None, cert_file=None,
                              Severity: Major
                              Found in src/collectors/python.d.plugin/python_modules/urllib3/connection.py - About 1 hr to fix

                                Method Manager.dyncfgConfigUpdate has 9 return statements (exceeds 4 allowed).
                                Open

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

                                  Method Discoverer.parseLocalListeners has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  func (d *Discoverer) parseLocalListeners(bs []byte) ([]model.Target, error) {
                                      const (
                                          local4 = "127.0.0.1"
                                          local6 = "::1"
                                      )

                                  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 readICMPResponse has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                                  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: Minor
                                  Found in src/go/plugin/go.d/modules/portcheck/check_udp_port.go - About 55 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 checkChart has 9 return statements (exceeds 4 allowed).
                                  Open

                                  func checkChart(chart *Chart) error {
                                      if chart.ID == "" {
                                          return errors.New("empty ID")
                                      }
                                  
                                  
                                  Severity: Major
                                  Found in src/go/plugin/go.d/agent/module/charts.go - About 55 mins to fix

                                    Method SNMP.collectNetworkInterfaces has 9 return statements (exceeds 4 allowed).
                                    Open

                                    func (s *SNMP) collectNetworkInterfaces(mx map[string]int64) error {
                                        if s.checkMaxReps {
                                            ok, err := s.adjustMaxRepetitions()
                                            if err != nil {
                                                return err
                                    Severity: Major
                                    Found in src/go/plugin/go.d/modules/snmp/collect_if_mib.go - About 55 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language