tombuildsstuff/sensu-plugins-azurerm

View on GitHub

Showing 7 of 25 total issues

File check-azurerm-monitor-metric.rb has 352 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'ms_rest_azure'
require 'erb'

require 'sensu-plugin/check/cli'
require 'sensu-plugins-azurerm'
Severity: Minor
Found in bin/check-azurerm-monitor-metric.rb - About 4 hrs to fix

    Method run has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        check_missing_resource_info
    
        if !config[:critical_over] && !config[:warning_over] && !config[:critical_under] && !config[:warning_under]
          unknown 'At least one threshold must be provided.'
    Severity: Minor
    Found in bin/check-azurerm-monitor-metric.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 metric_response has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def metric_response
        auth_header = if config[:use_assigned_identity]
                        uri = URI.parse("http://localhost:#{config[:local_auth_port]}/oauth2/token?resource=#{config[:assigned_identity_resource]}")
    
                        res = Net::HTTP.start(uri.host, uri.port, use_ssl: false) do |http|
    Severity: Minor
    Found in bin/check-azurerm-monitor-metric.rb - About 1 hr to fix

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

        def run
          check_missing_resource_info
      
          if !config[:critical_over] && !config[:warning_over] && !config[:critical_under] && !config[:warning_under]
            unknown 'At least one threshold must be provided.'
      Severity: Minor
      Found in bin/check-azurerm-monitor-metric.rb - About 1 hr to fix

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

          def find_last_metric_values
            values = []
            metric_response[:value].each do |metric_resp_value|
              name = metric_resp_value[:name] ? metric_resp_value[:name][:value] : ''
        
        
        Severity: Minor
        Found in bin/check-azurerm-monitor-metric.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 extract_request_values has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def extract_request_values
            values = []
            metric_response[:value].each do |metric_resp_value|
              name = metric_resp_value[:name] ? metric_resp_value[:name][:value] : ''
        
        
        Severity: Minor
        Found in bin/check-azurerm-monitor-metric.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def run
            tenant_id = config[:tenant_id]
            client_id = config[:client_id]
            client_secret = config[:client_secret]
            subscription_id = config[:subscription_id]
        Severity: Minor
        Found in bin/check-azurerm-virtual-network-gateway-failure-connected.rb - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language