sensu-plugins/sensu-plugins-openldap

View on GitHub

Showing 5 of 5 total issues

Method get_csns has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def get_csns(host)
    if config[:user] # rubocop:disable Style/ConditionalAssignment
      ldap = Net::LDAP.new host: host,
                           port: config[:port],
                           auth: {
Severity: Minor
Found in bin/check-syncrepl.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 get_metrics has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_metrics(host)
    ldap = Net::LDAP.new host: host,
                         port: config[:port],
                         auth: {
                           method: :simple,
Severity: Major
Found in bin/metrics-ldap.rb - About 3 hrs to fix

    Method get_csns has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def get_csns(host)
        if config[:user] # rubocop:disable Style/ConditionalAssignment
          ldap = Net::LDAP.new host: host,
                               port: config[:port],
                               auth: {
    Severity: Minor
    Found in bin/check-syncrepl.rb - About 1 hr to fix

      Method get_metrics has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_metrics(host)
          ldap = Net::LDAP.new host: host,
                               port: config[:port],
                               auth: {
                                 method: :simple,
      Severity: Minor
      Found in bin/metrics-ldap.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def run
          unknown 'Cannot compare 1 node (to anything else).' if config[:hosts].length == 1
      
          (config[:retries] + 1).times do
            # Build a list of contextCSNs from each host
      Severity: Minor
      Found in bin/check-syncrepl.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