Commit ccaa17a7a1b21eea7eb0757368d3a5083f595479

Authored by Heitor
1 parent 0ba7d15a

Remove unnecessary checking for metric collector

It will never return nil. At most, it will raise a
ActiveRecord::RecordNotFound

Signed off by: Diego Araújo <diegoamc90@gmail.com>
app/controllers/base_metric_configurations_controller.rb
... ... @@ -116,18 +116,16 @@ class BaseMetricConfigurationsController &lt; ApplicationController
116 116  
117 117 def set_metric!
118 118 collector = KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name(params[:metric_collector_name])
119   - unless collector.nil?
120   - # FIXME: Some view pass metric code as a parameter instead of metric name
121   - if params.key?(:metric_code)
122   - metric = collector.find_metric_by_code(params[:metric_code])
123   - else
124   - metric = collector.find_metric_by_name(params[:metric_name])
125   - end
  119 + # FIXME: Some view pass metric code as a parameter instead of metric name
  120 + if params.key?(:metric_code)
  121 + metric = collector.find_metric_by_code(params[:metric_code])
  122 + else
  123 + metric = collector.find_metric_by_name(params[:metric_name])
  124 + end
126 125  
127   - if !metric.nil? && metric.type == metric_type
128   - @metric_configuration.metric = metric
129   - return
130   - end
  126 + if !metric.nil? && metric.type == metric_type
  127 + @metric_configuration.metric = metric
  128 + return
131 129 end
132 130  
133 131 respond_to do |format|
... ...