express42-cookbooks/zabbix_lwrp

View on GitHub

Showing 27 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                        #{db_connect_string} -f /usr/share/zabbix-server-pgsql/images.sql; \
                        #{db_connect_string} -f /usr/share/zabbix-server-pgsql/data.sql;"
        end
      elsif db_vendor == 'mysql'
        db_connect_string = "mysql -h #{db_host} -P #{db_port} -u #{db_user} -p#{db_pass} -D #{db_name}"
    Severity: Major
    Found in providers/database.rb and 1 other location - About 3 hrs to fix
    providers/database.rb on lines 89..102

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 109.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        db_connect_string = "PGPASSWORD=#{db_pass} psql -q -t -h #{db_host} -p #{db_port} -U #{db_user} -d #{db_name}"
    
        if node['zabbix']['version'].to_f.between?(3.0, 4.0) && node['platform_family'] == 'rhel'
          db_command = "gunzip -c /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | #{db_connect_string}"
    
    
    Severity: Major
    Found in providers/database.rb and 1 other location - About 3 hrs to fix
    providers/database.rb on lines 104..117

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 109.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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_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_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_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_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_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_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

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      if values['snmp_enabled']
                        interfaces.push(
                          type: 2,
                          main: 1,
                          ip: values['ip_address'] || '',
                  Severity: Minor
                  Found in providers/connect.rb and 2 other locations - About 35 mins to fix
                  providers/connect.rb on lines 114..122
                  providers/connect.rb on lines 125..133

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 34.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      if values['jmx_enabled']
                        interfaces.push(
                          type: 4,
                          main: 1,
                          ip: values['ip_address'] || '',
                  Severity: Minor
                  Found in providers/connect.rb and 2 other locations - About 35 mins to fix
                  providers/connect.rb on lines 103..111
                  providers/connect.rb on lines 114..122

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 34.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      if values['ipmi_enabled']
                        interfaces.push(
                          type: 3,
                          main: 1,
                          ip: values['ip_address'] || '',
                  Severity: Minor
                  Found in providers/connect.rb and 2 other locations - About 35 mins to fix
                  providers/connect.rb on lines 103..111
                  providers/connect.rb on lines 125..133

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 34.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      server_name: node['zabbix']['server']['web']['server_name'],
                      fastcgi_listen: node['zabbix']['server']['web']['listen'],
                      fastcgi_port: node['zabbix']['server']['web']['port']
                    )
                  Severity: Minor
                  Found in recipes/web.rb and 1 other location - About 25 mins to fix
                  attributes/server.rb on lines 41..44

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 31.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language