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'
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.'
- Read upRead up
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|
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.'
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] : ''
- Read upRead up
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] : ''
- Read upRead up
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"