diff --git a/.rubocop.yml b/.rubocop.yml index dc6c678..489ee3f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ inherit_from: AllCops: TargetRubyVersion: 2.2 - TargetRailsVersion: 4.2 + TargetRailsVersion: 5.1 Rails: Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e55f38c..11b0a87 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,3 +1,11 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2018-01-07 04:22:08 +0100 using RuboCop version 0.52.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + # Offense count: 2 Lint/HandleExceptions: Exclude: @@ -8,12 +16,6 @@ Lint/RescueException: Exclude: - 'lib/foreman_xen/vnc_tunnel.rb' -# Offense count: 9 -Lint/RescueWithoutErrorClass: - Exclude: - - 'app/models/foreman_xen/xenserver.rb' - - 'lib/foreman_xen/engine.rb' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. @@ -71,3 +73,12 @@ Metrics/ParameterLists: # Offense count: 4 Metrics/PerceivedComplexity: Max: 13 + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'app/models/foreman_xen/xenserver.rb' + - 'lib/foreman_xen/engine.rb' diff --git a/.travis.yml b/.travis.yml index d187e48..8c3d2f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ rvm: - 2.2.3 - 2.3.1 - 2.4.2 + - 2.5.0 before_install: - gem update --remote bundler install: diff --git a/Gemfile b/Gemfile index 6824aa9..ee415dd 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,4 @@ source 'https://rubygems.org' gemspec -gem 'nokogiri', '< 1.7', require: false if RUBY_VERSION.start_with? '2.0.' -gem 'rubocop', '~> 0.51.0', require: false +gem 'rubocop', '~> 0.52.1', require: false diff --git a/app/controllers/foreman_xen/snapshots_controller.rb b/app/controllers/foreman_xen/snapshots_controller.rb index 030631c..c0ab7d6 100644 --- a/app/controllers/foreman_xen/snapshots_controller.rb +++ b/app/controllers/foreman_xen/snapshots_controller.rb @@ -96,9 +96,7 @@ def new def create id = params[:id] name = params[:name] - if name.nil? || name == '' - process_error(:error_msg => 'You must supply a name.') - end + process_error(:error_msg => 'You must supply a name.') if name.nil? || name == '' @host = get_host_by_id(id) if !@host.nil? @compute_resource = get_compute_resource_by_host_id(id) diff --git a/app/helpers/xen_compute_helper.rb b/app/helpers/xen_compute_helper.rb index 490f575..7d62ad2 100644 --- a/app/helpers/xen_compute_helper.rb +++ b/app/helpers/xen_compute_helper.rb @@ -55,9 +55,7 @@ def compute_resource_controller_attribute_map(params, compute_resource) elsif params && params['host'] && params['host']['compute_profile_id'] compute_attributes = compute_resource.compute_profile_attributes_for(params['host']['compute_profile_id']) end - if compute_attributes - attribute_map = filter_compute_attributes(attribute_map, compute_attributes) - end + attribute_map = filter_compute_attributes(attribute_map, compute_attributes) if compute_attributes attribute_map end @@ -78,9 +76,7 @@ def filter_compute_attributes(attribute_map, compute_attributes) attribute_map[:volume_size] = compute_attributes['VBDs']['physical_size'] attribute_map[:volume_selected] = compute_attributes['VBDs']['sr_uuid'] end - if compute_attributes['VIFs'] - attribute_map[:network_selected] = compute_attributes['VIFs']['print'] - end + attribute_map[:network_selected] = compute_attributes['VIFs']['print'] if compute_attributes['VIFs'] attribute_map[:template_selected_custom] = compute_attributes['custom_template_name'] attribute_map[:template_selected_builtin] = compute_attributes['builtin_template_name'] attribute_map[:cpu_count] = compute_attributes['vcpus_max']