sensu-plugins/sensu-plugins-rabbitmq

View on GitHub

Showing 49 of 49 total issues

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

        if config[:regex]
          if config[:queue] && config[:exclude]
            next unless queue['name'] =~ /#{queue_list.first}/ && queue['name'] !~ /#{exclude_list.first}/
          else
            next unless queue['name'] =~ /#{queue_list.first}/
Severity: Major
Found in bin/check-rabbitmq-consumer-utilisation.rb and 1 other location - About 1 hr to fix
bin/check-rabbitmq-consumers.rb on lines 88..98

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 64.

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

  def acquire_rabbitmq_info
    begin
      if config[:ini]
        ini = IniFile.load(config[:ini])
        section = ini['auth']
Severity: Major
Found in bin/check-rabbitmq-messages.rb and 1 other location - About 1 hr to fix
bin/metrics-rabbitmq-overview.rb on lines 89..111

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 62.

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

  def acquire_rabbitmq_info
    begin
      if config[:ini]
        ini = IniFile.load(config[:ini])
        section = ini['auth']
Severity: Major
Found in bin/metrics-rabbitmq-overview.rb and 1 other location - About 1 hr to fix
bin/check-rabbitmq-messages.rb on lines 97..119

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 62.

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 vhost_alive? has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def vhost_alive?
    if config[:ini]
      ini = IniFile.load(config[:ini])
      section = ini['auth']
      username = section['username']
Severity: Minor
Found in bin/check-rabbitmq-stomp-alive.rb - About 1 hr to fix

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

      def vhost_alive?
        host           = config[:host]
        port           = config[:port]
        vhost          = config[:vhost]
        ssl            = config[:ssl]
    Severity: Minor
    Found in bin/check-rabbitmq-amqp-alive.rb - About 1 hr to fix

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

        def return_condition(missing, critical, warning)
          if critical.count > 0 || missing.count > 0
            message = []
            message << "Queues in critical state: #{critical.join(', ')}. " if critical.count > 0
            message << "Queues missing: #{missing.join(', ')}" if missing.count > 0
      Severity: Major
      Found in bin/check-rabbitmq-consumers.rb and 1 other location - About 1 hr to fix
      bin/check-rabbitmq-consumer-utilisation.rb on lines 64..74

      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 56.

      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

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

        def return_condition(missing, critical, warning)
          if critical.count > 0 || missing.count > 0
            message = []
            message << "Queues in critical state: #{critical.join(', ')}. " if critical.count > 0
            message << "Queues missing: #{missing.join(', ')}" if missing.count > 0
      Severity: Major
      Found in bin/check-rabbitmq-consumer-utilisation.rb and 1 other location - About 1 hr to fix
      bin/check-rabbitmq-consumers.rb on lines 59..69

      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 56.

      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 run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run
          queue_list = queue_list_builder(config[:queue])
          exclude_list = queue_list_builder(config[:exclude])
          # create arrays to hold failures
          missing = if config[:regex]
      Severity: Minor
      Found in bin/check-rabbitmq-consumers.rb - About 1 hr to fix

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

          def run
            # create arrays to hold failures
            queue_list = queue_list_builder(config[:queue])
            exclude_list = queue_list_builder(config[:exclude])
            missing = if config[:regex]
        Severity: Minor
        Found in bin/check-rabbitmq-consumer-utilisation.rb - About 1 hr to fix

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

            def assign_alerts(queue_name, total)
              if config[:below]
                @crit << "#{queue_name}:#{total}" if total <= config[:critical].to_i
                @warn << "#{queue_name}:#{total}" if total <= config[:warn].to_i && total > config[:critical].to_i
              else
          Severity: Minor
          Found in bin/check-rabbitmq-queue.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 add_common_options has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def add_common_options
                    option :host,
                           description: 'RabbitMQ management API host',
                           long: '--host HOST',
                           default: 'localhost'
          Severity: Minor
          Found in lib/sensu-plugins-rabbitmq/rabbitmq.rb - About 1 hr to fix

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

              def rabbitmq_management
                if config[:ini]
                  ini = IniFile.load(config[:ini])
                  section = ini['auth']
                  username = section['username']
            Severity: Major
            Found in bin/check-rabbitmq-node-usage.rb and 1 other location - About 1 hr to fix
            bin/check-rabbitmq-network-partitions.rb on lines 80..97

            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 53.

            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

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

              def rabbitmq_management
                if config[:ini]
                  ini = IniFile.load(config[:ini])
                  section = ini['auth']
                  username = section['username']
            Severity: Major
            Found in bin/check-rabbitmq-network-partitions.rb and 1 other location - About 1 hr to fix
            bin/check-rabbitmq-node-usage.rb on lines 302..319

            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 53.

            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 vhost_alive? has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def vhost_alive?
                host       = config[:host]
                port       = config[:port]
                vhost      = config[:vhost]
                ssl        = config[:ssl]
            Severity: Minor
            Found in bin/check-rabbitmq-alive.rb - About 1 hr to fix

              Method acquire_rabbitmq_info has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def acquire_rabbitmq_info(property = nil)
                        begin
                          if config[:ini]
                            ini = IniFile.load(config[:ini])
                            section = ini['auth']
              Severity: Minor
              Found in lib/sensu-plugins-rabbitmq/rabbitmq.rb - About 1 hr to fix

                Method run has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def run #rubocop:disable all
                    timestamp = Time.now.to_i
                
                    rabbitmq = acquire_rabbitmq_info
                    overview = rabbitmq.overview
                Severity: Minor
                Found in bin/metrics-rabbitmq-overview.rb - About 1 hr to fix

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

                    def run
                      rabbitmq = acquire_rabbitmq_info
                  
                      # monitor counts in each queue or monitor the total number of messages in the system
                      if config[:queuelevel]
                  Severity: Minor
                  Found in bin/check-rabbitmq-messages.rb - About 1 hr to fix

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

                      def return_condition(missing, critical, warning)
                        if critical.count > 0 || missing.count > 0
                          message = []
                          message << "Queues in critical state: #{critical.join(', ')}. " if critical.count > 0
                          message << "Queues missing: #{missing.join(', ')}" if missing.count > 0
                    Severity: Minor
                    Found in bin/check-rabbitmq-consumer-utilisation.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 return_condition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def return_condition(missing, critical, warning)
                        if critical.count > 0 || missing.count > 0
                          message = []
                          message << "Queues in critical state: #{critical.join(', ')}. " if critical.count > 0
                          message << "Queues missing: #{missing.join(', ')}" if missing.count > 0
                    Severity: Minor
                    Found in bin/check-rabbitmq-consumers.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

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

                          @crit << "#{queue_name}:#{total}" if total <= config[:critical].to_i
                          @warn << "#{queue_name}:#{total}" if total <= config[:warn].to_i && total > config[:critical].to_i
                        else
                    Severity: Minor
                    Found in bin/check-rabbitmq-queue.rb and 1 other location - About 40 mins to fix
                    bin/check-rabbitmq-queue.rb on lines 102..104

                    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 38.

                    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