express42/zabbix_lwrp

View on GitHub

Showing 16 of 27 total issues

File connect.rb has 500 lines of code (exceeds 250 allowed). Consider refactoring.
Open

use_inline_resources

provides :zabbix_connect if defined? provides

action :make do
Severity: Minor
Found in providers/connect.rb - About 1 day to fix

    Method create_hosts has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_hosts
      get_hosts do |host|
        fqdn, values = host['zabbix']['hosts'].to_a.first
        next unless values
    
    
    Severity: Minor
    Found in providers/connect.rb - About 4 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 create_actions has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_actions
      get_hosts do |host|
        _, values = host['zabbix']['hosts'].to_a.first
        (values['actions'] || []).each do |name, data|
          filter = data['filter'].to_hash
    Severity: Minor
    Found in providers/connect.rb - About 3 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 create_applications has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def create_applications
      get_hosts do |host|
        fqdn, values = host['zabbix']['hosts'].to_a.first
        tmp = @@zbx.query(
          method: 'host.get',
    Severity: Major
    Found in providers/connect.rb - About 3 hrs to fix

      Method create_hosts has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def create_hosts
        get_hosts do |host|
          fqdn, values = host['zabbix']['hosts'].to_a.first
          next unless values
      
      
      Severity: Major
      Found in providers/connect.rb - About 2 hrs to fix

        Method create_screens has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def create_screens
          get_hosts do |host|
            fqdn, values = host['zabbix']['hosts'].to_a.first
            host_id = @@zbx.query(
              method: 'host.get',
        Severity: Major
        Found in providers/connect.rb - About 2 hrs to fix

          Method create_import_templates has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def create_import_templates
            get_hosts do |host|
              _, values = host['zabbix']['hosts'].to_a.first if host['zabbix']['hosts']
          
              values ||= Hash.new([])
          Severity: Major
          Found in providers/connect.rb - About 2 hrs to fix

            Method create_actions has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def create_actions
              get_hosts do |host|
                _, values = host['zabbix']['hosts'].to_a.first
                (values['actions'] || []).each do |name, data|
                  filter = data['filter'].to_hash
            Severity: Minor
            Found in providers/connect.rb - About 2 hrs to fix

              Method create_screens has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              def create_screens
                get_hosts do |host|
                  fqdn, values = host['zabbix']['hosts'].to_a.first
                  host_id = @@zbx.query(
                    method: 'host.get',
              Severity: Minor
              Found in providers/connect.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 create_applications has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              def create_applications
                get_hosts do |host|
                  fqdn, values = host['zabbix']['hosts'].to_a.first
                  tmp = @@zbx.query(
                    method: 'host.get',
              Severity: Minor
              Found in providers/connect.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 create_graphs has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def create_graphs
                get_hosts do |host|
                  fqdn, values = host['zabbix']['hosts'].to_a.first
                  host_id = @@zbx.query(
                    method: 'host.get',
              Severity: Minor
              Found in providers/connect.rb - About 1 hr to fix

                Method create_user_macros has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def create_user_macros
                  get_hosts do |host|
                    _, values = host['zabbix']['hosts'].to_a.first
                    host_id = @@zbx.query(
                      method: 'host.get',
                Severity: Minor
                Found in providers/connect.rb - About 1 hr to fix

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

                    def to_hash
                      case @type
                      when :trigger, :host_group
                        value = @value
                      when :trigger_value
                  Severity: Minor
                  Found in resources/action.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_hosts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def get_hosts
                    if Chef::Config[:solo] || ENV['TEST_KITCHEN']
                      yield node
                    else
                      search(:node, 'hosts:*').each do |host|
                  Severity: Minor
                  Found in providers/connect.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 create_templates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def create_templates
                    get_hosts do |host|
                      _, values = host['zabbix']['hosts'].to_a.first
                  
                      (values['templates'] || []).each do |template, hostname|
                  Severity: Minor
                  Found in providers/connect.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

                  Method check_zabbix_db has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def check_zabbix_db(db_connect_string)
                    db_vendor = new_resource.db_vendor
                    cmd_key = db_vendor == 'mysql' ? '-N -B -e' : '-c'
                    check_db_flag = false
                    # Check connect to database
                  Severity: Minor
                  Found in providers/database.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