mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
(maint) Fix rubocop offenses
This commit updates VM Pooler to fix any existing rubocop offenses and also fixes any offenses in the lib/vmpooler.rb file. This commit also regenerates the Todo file.
This commit is contained in:
parent
850919f5db
commit
c14403682a
4 changed files with 22 additions and 41 deletions
|
|
@ -29,13 +29,15 @@ Metrics/PerceivedComplexity:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
# - Long Methods, Classes and blocks
|
# - Long Methods, Classes, Blocks, and Modules
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Metrics/BlockLength:
|
Metrics/BlockLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
Metrics/ModuleLength:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
|
||||||
# Either sytnax for regex is ok
|
# Either sytnax for regex is ok
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# This configuration was generated by
|
# This configuration was generated by
|
||||||
# `rubocop --auto-gen-config`
|
# `rubocop --auto-gen-config`
|
||||||
# on 2017-02-10 13:29:15 -0800 using RuboCop version 0.47.1.
|
# on 2017-03-02 20:16:29 -0800 using RuboCop version 0.47.1.
|
||||||
# The point is for the user to remove these configuration records
|
# The point is for the user to remove these configuration records
|
||||||
# one by one as the offenses are removed from the code base.
|
# one by one as the offenses are removed from the code base.
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
|
|
@ -51,11 +51,6 @@ Lint/UselessAssignment:
|
||||||
Metrics/BlockNesting:
|
Metrics/BlockNesting:
|
||||||
Max: 5
|
Max: 5
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Configuration parameters: CountComments.
|
|
||||||
Metrics/ModuleLength:
|
|
||||||
Max: 289
|
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
# Configuration parameters: CountKeywordArgs.
|
# Configuration parameters: CountKeywordArgs.
|
||||||
Metrics/ParameterLists:
|
Metrics/ParameterLists:
|
||||||
|
|
@ -68,12 +63,6 @@ Performance/RedundantMatch:
|
||||||
- 'lib/vmpooler/api/v1.rb'
|
- 'lib/vmpooler/api/v1.rb'
|
||||||
- 'lib/vmpooler/vsphere_helper.rb'
|
- 'lib/vmpooler/vsphere_helper.rb'
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Security/YAMLLoad:
|
|
||||||
Exclude:
|
|
||||||
- 'lib/vmpooler.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
||||||
|
|
@ -115,7 +104,7 @@ Style/CaseEquality:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/vmpooler/api/helpers.rb'
|
- 'lib/vmpooler/api/helpers.rb'
|
||||||
|
|
||||||
# Offense count: 12
|
# Offense count: 13
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth.
|
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth.
|
||||||
# SupportedStyles: case, end
|
# SupportedStyles: case, end
|
||||||
|
|
@ -125,14 +114,6 @@ Style/CaseIndentation:
|
||||||
- 'lib/vmpooler/api/v1.rb'
|
- 'lib/vmpooler/api/v1.rb'
|
||||||
- 'lib/vmpooler/vsphere_helper.rb'
|
- 'lib/vmpooler/vsphere_helper.rb'
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: is_a?, kind_of?
|
|
||||||
Style/ClassCheck:
|
|
||||||
Exclude:
|
|
||||||
- 'lib/vmpooler.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Style/ClosingParenthesisIndentation:
|
Style/ClosingParenthesisIndentation:
|
||||||
|
|
@ -415,13 +396,12 @@ Style/SpaceAfterNot:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/vmpooler/pool_manager.rb'
|
- 'lib/vmpooler/pool_manager.rb'
|
||||||
|
|
||||||
# Offense count: 9
|
# Offense count: 7
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||||
# SupportedStyles: space, no_space
|
# SupportedStyles: space, no_space
|
||||||
Style/SpaceAroundEqualsInParameterDefault:
|
Style/SpaceAroundEqualsInParameterDefault:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/vmpooler.rb'
|
|
||||||
- 'lib/vmpooler/api/helpers.rb'
|
- 'lib/vmpooler/api/helpers.rb'
|
||||||
- 'lib/vmpooler/pool_manager.rb'
|
- 'lib/vmpooler/pool_manager.rb'
|
||||||
- 'lib/vmpooler/vsphere_helper.rb'
|
- 'lib/vmpooler/vsphere_helper.rb'
|
||||||
|
|
@ -462,11 +442,10 @@ Style/SpaceInsideParens:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/vmpooler/api/v1.rb'
|
- 'lib/vmpooler/api/v1.rb'
|
||||||
|
|
||||||
# Offense count: 4
|
# Offense count: 2
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Style/SpaceInsidePercentLiteralDelimiters:
|
Style/SpaceInsidePercentLiteralDelimiters:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/vmpooler.rb'
|
|
||||||
- 'lib/vmpooler/api.rb'
|
- 'lib/vmpooler/api.rb'
|
||||||
|
|
||||||
# Offense count: 47
|
# Offense count: 47
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ module Vmpooler
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'set'
|
require 'set'
|
||||||
|
|
||||||
%w( api graphite logger pool_manager vsphere_helper statsd dummy_statsd ).each do |lib|
|
%w(api graphite logger pool_manager vsphere_helper statsd dummy_statsd).each do |lib|
|
||||||
begin
|
begin
|
||||||
require "vmpooler/#{lib}"
|
require "vmpooler/#{lib}"
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
|
|
@ -20,12 +20,12 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.config(filepath='vmpooler.yaml')
|
def self.config(filepath = 'vmpooler.yaml')
|
||||||
parsed_config = {}
|
parsed_config = {}
|
||||||
|
|
||||||
if ENV['VMPOOLER_CONFIG']
|
if ENV['VMPOOLER_CONFIG']
|
||||||
# Load configuration from ENV
|
# Load configuration from ENV
|
||||||
parsed_config = YAML.load(ENV['VMPOOLER_CONFIG'])
|
parsed_config = YAML.safe_load(ENV['VMPOOLER_CONFIG'])
|
||||||
else
|
else
|
||||||
# Load the configuration file from disk
|
# Load the configuration file from disk
|
||||||
config_file = File.expand_path(filepath)
|
config_file = File.expand_path(filepath)
|
||||||
|
|
@ -37,8 +37,8 @@ module Vmpooler
|
||||||
if parsed_config[:auth]['provider'] == 'dummy'
|
if parsed_config[:auth]['provider'] == 'dummy'
|
||||||
unless ENV['VMPOOLER_DEBUG']
|
unless ENV['VMPOOLER_DEBUG']
|
||||||
warning = [
|
warning = [
|
||||||
"Dummy authentication should not be used outside of debug mode",
|
'Dummy authentication should not be used outside of debug mode',
|
||||||
"please set environment variable VMPOOLER_DEBUG to 'true' if you want to use dummy authentication",
|
'please set environment variable VMPOOLER_DEBUG to \'true\' if you want to use dummy authentication'
|
||||||
]
|
]
|
||||||
|
|
||||||
raise warning.join(";\s")
|
raise warning.join(";\s")
|
||||||
|
|
@ -60,13 +60,13 @@ module Vmpooler
|
||||||
parsed_config[:pools].each do |pool|
|
parsed_config[:pools].each do |pool|
|
||||||
parsed_config[:pool_names] << pool['name']
|
parsed_config[:pool_names] << pool['name']
|
||||||
if pool['alias']
|
if pool['alias']
|
||||||
if pool['alias'].kind_of?(Array)
|
if pool['alias'].is_a?(Array)
|
||||||
pool['alias'].each do |a|
|
pool['alias'].each do |a|
|
||||||
parsed_config[:alias] ||= {}
|
parsed_config[:alias] ||= {}
|
||||||
parsed_config[:alias][a] = pool['name']
|
parsed_config[:alias][a] = pool['name']
|
||||||
parsed_config[:pool_names] << a
|
parsed_config[:pool_names] << a
|
||||||
end
|
end
|
||||||
elsif pool['alias'].kind_of?(String)
|
elsif pool['alias'].is_a?(String)
|
||||||
parsed_config[:alias][pool['alias']] = pool['name']
|
parsed_config[:alias][pool['alias']] = pool['name']
|
||||||
parsed_config[:pool_names] << pool['alias']
|
parsed_config[:pool_names] << pool['alias']
|
||||||
end
|
end
|
||||||
|
|
@ -83,7 +83,7 @@ module Vmpooler
|
||||||
parsed_config
|
parsed_config
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.new_redis(host='localhost')
|
def self.new_redis(host = 'localhost')
|
||||||
Redis.new(host: host)
|
Redis.new(host: host)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -436,7 +436,7 @@ module Vmpooler
|
||||||
|
|
||||||
unless maxloop.zero?
|
unless maxloop.zero?
|
||||||
break if loop_count >= maxloop
|
break if loop_count >= maxloop
|
||||||
loop_count = loop_count + 1
|
loop_count += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -468,7 +468,7 @@ module Vmpooler
|
||||||
|
|
||||||
unless maxloop.zero?
|
unless maxloop.zero?
|
||||||
break if loop_count >= maxloop
|
break if loop_count >= maxloop
|
||||||
loop_count = loop_count + 1
|
loop_count += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -569,7 +569,7 @@ module Vmpooler
|
||||||
finish
|
finish
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_pool(pool,maxloop = 0, loop_delay = 5)
|
def check_pool(pool, maxloop = 0, loop_delay = 5)
|
||||||
$logger.log('d', "[*] [#{pool['name']}] starting worker thread")
|
$logger.log('d', "[*] [#{pool['name']}] starting worker thread")
|
||||||
|
|
||||||
$vsphere[pool['name']] ||= Vmpooler::VsphereHelper.new $config, $metrics
|
$vsphere[pool['name']] ||= Vmpooler::VsphereHelper.new $config, $metrics
|
||||||
|
|
@ -582,7 +582,7 @@ module Vmpooler
|
||||||
|
|
||||||
unless maxloop.zero?
|
unless maxloop.zero?
|
||||||
break if loop_count >= maxloop
|
break if loop_count >= maxloop
|
||||||
loop_count = loop_count + 1
|
loop_count += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -722,7 +722,7 @@ module Vmpooler
|
||||||
if $redis.get('vmpooler__tasks__clone').to_i < $config[:config]['task_limit'].to_i
|
if $redis.get('vmpooler__tasks__clone').to_i < $config[:config]['task_limit'].to_i
|
||||||
begin
|
begin
|
||||||
$redis.incr('vmpooler__tasks__clone')
|
$redis.incr('vmpooler__tasks__clone')
|
||||||
clone_vm(pool,vsphere)
|
clone_vm(pool, vsphere)
|
||||||
rescue => err
|
rescue => err
|
||||||
$logger.log('s', "[!] [#{pool['name']}] clone failed during check_pool with an error: #{err}")
|
$logger.log('s', "[!] [#{pool['name']}] clone failed during check_pool with an error: #{err}")
|
||||||
$redis.decr('vmpooler__tasks__clone')
|
$redis.decr('vmpooler__tasks__clone')
|
||||||
|
|
@ -736,7 +736,7 @@ module Vmpooler
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute!(maxloop = 0, loop_delay = 1)
|
def execute!(maxloop = 0, loop_delay = 1)
|
||||||
$logger.log('d', 'starting vmpooler')
|
$logger.log('d', 'starting vmpooler')
|
||||||
|
|
||||||
# Clear out the tasks manager, as we don't know about any tasks at this point
|
# Clear out the tasks manager, as we don't know about any tasks at this point
|
||||||
|
|
@ -773,7 +773,7 @@ module Vmpooler
|
||||||
|
|
||||||
unless maxloop.zero?
|
unless maxloop.zero?
|
||||||
break if loop_count >= maxloop
|
break if loop_count >= maxloop
|
||||||
loop_count = loop_count + 1
|
loop_count += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue