mose/zabbix-ruby-client

View on GitHub

Showing 20 of 20 total issues

Method getlines has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def getlines(file, pattern=false)
      lines = []
      if File.readable? file
        File.open(file,'r') do |f|
          f.each do |l|
Severity: Minor
Found in lib/zabbix-ruby-client/plugin_base.rb - About 2 hrs 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 getline has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def getline(file, pattern=false)
      if File.readable? file
        File.open(file,'r') do |f|
          f.each do |l|
            line = l.strip
Severity: Minor
Found in lib/zabbix-ruby-client/plugin_base.rb - About 1 hr 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 get_info has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def get_info
        case os
        when :linux
          info = meminfo
          if info
Severity: Minor
Found in lib/zabbix-ruby-client/plugins/memory.rb - About 1 hr to fix

    Method upload has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def upload
          file = @store.record(@data.merge)
          command = "#{@config['zabbix']['sender']} -z #{@config['zabbix']['host']} -p #{@config['zabbix']['port']} -T -i #{file}"
          ZabbixRubyClient::Log.debug command
          begin
    Severity: Minor
    Found in lib/zabbix-ruby-client/runner.rb - About 1 hr to fix

      Method get_info has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def get_info
              ret = {}
              case os
              when :linux
                info = getline("/proc/stat", "^cpu ")
      Severity: Minor
      Found in lib/zabbix-ruby-client/plugins/cpu.rb - About 1 hr to fix

        Method get_info has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def get_info(interface)
                back = {}
                case os
                when :linux
                  data = getline("/proc/net/dev", "#{interface}:")
        Severity: Minor
        Found in lib/zabbix-ruby-client/plugins/network.rb - About 1 hr to fix

          Method collect has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def collect(*args)
                  host = args[0]
                  psqlargs = args[1]
                  dbname = args[2]
                  # be sure to have this in the config file
          Severity: Minor
          Found in lib/zabbix-ruby-client/plugins/postgres.rb - About 1 hr to fix

            Method collect has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def collect(*args)
                    host = args[0]
                    mysqlargs = args[1]
                    mysqlstatus = `mysqladmin #{mysqlargs} extended-status`
                    if $?.to_i == 0
            Severity: Minor
            Found in lib/zabbix-ruby-client/plugins/mysql.rb - About 1 hr to fix

              Method get_info has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def get_info(disk, device)
                      info = diskinfo(device)
                      if info
                        back = info.split(/\s+/)
                        case os
              Severity: Minor
              Found in lib/zabbix-ruby-client/plugins/disk.rb - About 1 hr to fix

                Method get_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                      def get_info
                        case os
                        when :linux
                          info = meminfo
                          if info
                Severity: Minor
                Found in lib/zabbix-ruby-client/plugins/memory.rb - About 1 hr 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 collect has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def collect(*args)
                        host = args.shift
                        app = args.shift
                        mysqldb = args.shift
                        mysqlargs = args.shift
                Severity: Minor
                Found in lib/zabbix-ruby-client/plugins/mysqlcommand.rb - About 1 hr to fix

                  Method collect has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def collect(*args)
                          host = args[0]
                          ret = get_status
                          ret['Score'] = get_scores(ret["Scoreboard"])
                          ret.delete "Scoreboard"
                  Severity: Minor
                  Found in lib/zabbix-ruby-client/plugins/apache.rb - About 1 hr to fix

                    Method run_plugin has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def run_plugin(plugin, args = nil)
                          Plugins.load(plugin) || ZabbixRubyClient::Log.error( "Plugin #{plugin} not found.")
                          if Plugins.loaded[plugin]
                            begin
                              if Plugins.loaded[plugin].respond_to?(:collect)
                    Severity: Minor
                    Found in lib/zabbix-ruby-client/data.rb - 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

                    Method get_status has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def get_status
                            ret = {}
                            open "http://127.0.0.1:8090/nginx_status" do |f|
                              f.each_line do |line|
                                ret[:total] = $1 if line =~ /^Active connections:\s+(\d+)/
                    Severity: Minor
                    Found in lib/zabbix-ruby-client/plugins/nginx.rb - 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

                    Method get_info has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def get_info
                            ret = {}
                            case os
                            when :linux
                              info = getline("/proc/stat", "^cpu ")
                    Severity: Minor
                    Found in lib/zabbix-ruby-client/plugins/cpu.rb - 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

                    Method collect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def collect(*args)
                            host = args.shift
                            app = args.shift
                            mysqldb = args.shift
                            mysqlargs = args.shift
                    Severity: Minor
                    Found in lib/zabbix-ruby-client/plugins/mysqlcommand.rb - 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 upload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def upload
                          file = @store.record(@data.merge)
                          command = "#{@config['zabbix']['sender']} -z #{@config['zabbix']['host']} -p #{@config['zabbix']['port']} -T -i #{file}"
                          ZabbixRubyClient::Log.debug command
                          begin
                    Severity: Minor
                    Found in lib/zabbix-ruby-client/runner.rb - 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 get_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def get_info(interface)
                            back = {}
                            case os
                            when :linux
                              data = getline("/proc/net/dev", "#{interface}:")
                    Severity: Minor
                    Found in lib/zabbix-ruby-client/plugins/network.rb - 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 get_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def get_info(disk, device)
                            info = diskinfo(device)
                            if info
                              back = info.split(/\s+/)
                              case os
                    Severity: Minor
                    Found in lib/zabbix-ruby-client/plugins/disk.rb - 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 collect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def collect(*args)
                            host = args[0]
                            psqlargs = args[1]
                            dbname = args[2]
                            # be sure to have this in the config file
                    Severity: Minor
                    Found in lib/zabbix-ruby-client/plugins/postgres.rb - About 25 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

                    Severity
                    Category
                    Status
                    Source
                    Language