Cleanup minor rubocop offenses

Cleaned up all the minor rubocop issues, the ones left relate to
complex logic and what I think is a bug in rubocop for nested
vs compact modules/class definitions.

Change-Id: I5ac6d513c3b1397ba7205dc6f661134a93d17741
This commit is contained in:
Mark Vanderwiel 2015-05-28 14:37:17 -05:00
parent 6a8e987f42
commit 0b94103098
10 changed files with 94 additions and 156 deletions

View File

@ -1,55 +1,21 @@
# This configuration was generated by `rubocop --auto-gen-config` # This configuration was generated by `rubocop --auto-gen-config`
# on 2015-02-27 14:45:01 -0600 using RuboCop version 0.29.1. # on 2015-05-28 14:36:48 -0500 using RuboCop version 0.29.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
# versions of RuboCop, may require this file to be generated again. # versions of RuboCop, may require this file to be generated again.
# Offense count: 1 # Offense count: 1
Metrics/AbcSize: Metrics/AbcSize:
Max: 28 Max: 18
# Offense count: 5 # Offense count: 5
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren: Style/ClassAndModuleChildren:
Enabled: false Enabled: false
# Offense count: 3 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: IgnoredMethods.
Style/EmptyLinesAroundBlockBody: Style/SymbolProc:
Enabled: false Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/FirstParameterIndentation:
Enabled: false
# Offense count: 8
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/FormatString:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MultilineOperationIndentation:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Enabled: false
# Offense count: 13
# Cop supports --auto-correct.
Style/SingleSpaceBeforeFirstArg:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
Style/SymbolProc:
Enabled: false

View File

@ -1,21 +1,21 @@
# encoding: UTF-8 # encoding: UTF-8
name 'openstack-block-storage' name 'openstack-block-storage'
maintainer 'openstack-chef' maintainer 'openstack-chef'
maintainer_email 'opscode-chef-openstack@googlegroups.com' maintainer_email 'opscode-chef-openstack@googlegroups.com'
license 'Apache 2.0' license 'Apache 2.0'
description 'The OpenStack Advanced Volume Management service Cinder.' description 'The OpenStack Advanced Volume Management service Cinder.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '11.1.0' version '11.1.0'
recipe 'openstack-block-storage::api', 'Installs the cinder-api, sets up the cinder database, and cinder service/user/endpoints in keystone' recipe 'openstack-block-storage::api', 'Installs the cinder-api, sets up the cinder database, and cinder service/user/endpoints in keystone'
recipe 'openstack-block-storage::client', 'Install packages required for cinder client' recipe 'openstack-block-storage::client', 'Install packages required for cinder client'
recipe 'openstack-block-storage::common', 'Defines the common pieces of repeated code from the other recipes' recipe 'openstack-block-storage::common', 'Defines the common pieces of repeated code from the other recipes'
recipe 'openstack-block-storage::keystone_registration', 'Registers cinder service/user/endpoints in keystone' recipe 'openstack-block-storage::keystone_registration', 'Registers cinder service/user/endpoints in keystone'
recipe 'openstack-block-storage::scheduler', 'Installs the cinder-scheduler service' recipe 'openstack-block-storage::scheduler', 'Installs the cinder-scheduler service'
recipe 'openstack-block-storage::volume', 'Installs the cinder-volume service and sets up the iscsi helper' recipe 'openstack-block-storage::volume', 'Installs the cinder-volume service and sets up the iscsi helper'
recipe 'openstack-block-storage::backup', 'Installs the cinder-backup service' recipe 'openstack-block-storage::backup', 'Installs the cinder-backup service'
%w{ ubuntu fedora redhat centos suse }.each do |os| %w(ubuntu fedora redhat centos suse).each do |os|
supports os supports os
end end

View File

@ -131,5 +131,5 @@ template '/etc/cinder/rootwrap.conf' do
source 'rootwrap.conf.erb' source 'rootwrap.conf.erb'
owner 'root' owner 'root'
group 'root' group 'root'
mode 00644 mode 00644
end end

View File

@ -22,7 +22,8 @@
# limitations under the License. # limitations under the License.
# #
class ::Chef::Recipe # rubocop:disable Documentation # Chef
class ::Chef::Recipe
include ::Openstack include ::Openstack
end end
@ -257,7 +258,7 @@ end
# RHEL7 doesn't need targets.conf file # RHEL7 doesn't need targets.conf file
template '/etc/tgt/targets.conf' do template '/etc/tgt/targets.conf' do
source 'targets.conf.erb' source 'targets.conf.erb'
mode 00600 mode 00600
notifies :restart, 'service[iscsitarget]', :immediately notifies :restart, 'service[iscsitarget]', :immediately
not_if { node['platform_family'] == 'rhel' && node['platform_version'].to_i == 7 } not_if { node['platform_family'] == 'rhel' && node['platform_version'].to_i == 7 }
end end

View File

@ -39,16 +39,11 @@ describe 'openstack-block-storage::api' do
let(:dir) { chef_run.directory('/var/cache/cinder') } let(:dir) { chef_run.directory('/var/cache/cinder') }
it 'should create the directory' do it 'should create the directory' do
expect(chef_run).to create_directory(dir.name) expect(chef_run).to create_directory(dir.name).with(
end owner: 'cinder',
group: 'cinder',
it 'has proper owner' do mode: 00700
expect(dir.owner).to eq('cinder') )
expect(dir.group).to eq('cinder')
end
it 'has proper modes' do
expect(sprintf('%o', dir.mode)).to eq('700')
end end
end end

View File

@ -75,6 +75,5 @@ describe 'openstack-block-storage::backup' do
expect(chef_run).not_to upgrade_package 'python-mysqldb' expect(chef_run).not_to upgrade_package 'python-mysqldb'
end end
end end
end end
end end

View File

@ -25,16 +25,11 @@ describe 'openstack-block-storage::cinder-common' do
let(:dir) { chef_run.directory('/etc/cinder') } let(:dir) { chef_run.directory('/etc/cinder') }
it 'should create the /etc/cinder directory' do it 'should create the /etc/cinder directory' do
expect(chef_run).to create_directory(dir.name) expect(chef_run).to create_directory(dir.name).with(
end owner: 'cinder',
group: 'cinder',
it 'has proper owner' do mode: 00750
expect(dir.owner).to eq('cinder') )
expect(dir.group).to eq('cinder')
end
it 'has proper modes' do
expect(sprintf('%o', dir.mode)).to eq '750'
end end
end end
@ -48,16 +43,11 @@ describe 'openstack-block-storage::cinder-common' do
end end
it 'should create the cinder.conf template' do it 'should create the cinder.conf template' do
expect(chef_run).to create_template(file.name) expect(chef_run).to create_template(file.name).with(
end owner: 'cinder',
group: 'cinder',
it 'has proper owner' do mode: 00640
expect(file.owner).to eq('cinder') )
expect(file.group).to eq('cinder')
end
it 'has proper modes' do
expect(sprintf('%o', file.mode)).to eq '640'
end end
context 'keystone authtoken attributes with default values' do context 'keystone authtoken attributes with default values' do
@ -124,13 +114,12 @@ describe 'openstack-block-storage::cinder-common' do
end end
context 'endpoint related' do context 'endpoint related' do
it 'has auth_uri' do it 'has auth_uri' do
expect(chef_run).to render_file(file.name).with_content(%r(^auth_uri = http://127.0.0.1:5000/v2.0$)) expect(chef_run).to render_file(file.name).with_content(%r{^auth_uri = http://127.0.0.1:5000/v2.0$})
end end
it 'has identity_uri' do it 'has identity_uri' do
expect(chef_run).to render_file(file.name).with_content(%r(^identity_uri = http://127.0.0.1:35357/$)) expect(chef_run).to render_file(file.name).with_content(%r{^identity_uri = http://127.0.0.1:35357/$})
end end
end end
@ -165,7 +154,6 @@ describe 'openstack-block-storage::cinder-common' do
end end
context 'template contents' do context 'template contents' do
context 'commonly named attributes' do context 'commonly named attributes' do
%w(debug verbose host notification_driver %w(debug verbose host notification_driver
storage_availability_zone quota_volumes quota_gigabytes quota_driver storage_availability_zone quota_volumes quota_gigabytes quota_driver
@ -237,7 +225,7 @@ describe 'openstack-block-storage::cinder-common' do
end end
it 'has a lock_path attribute' do it 'has a lock_path attribute' do
expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r(^lock_path=/var/lib/cinder/lock$)) expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r{^lock_path=/var/lib/cinder/lock$})
end end
it 'does not have unique host id by default' do it 'does not have unique host id by default' do
@ -839,7 +827,7 @@ describe 'openstack-block-storage::cinder-common' do
it 'has wsdl_location line with attribute present' do it 'has wsdl_location line with attribute present' do
node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = 'http://127.0.0.1/wsdl' node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = 'http://127.0.0.1/wsdl'
expect(chef_run).to render_file(file.name).with_content(%r(^vmware_wsdl_location = http://127.0.0.1/wsdl$)) expect(chef_run).to render_file(file.name).with_content(%r{^vmware_wsdl_location = http://127.0.0.1/wsdl$})
end end
end end
@ -1015,7 +1003,6 @@ describe 'openstack-block-storage::cinder-common' do
it 'set gpfs option' do it 'set gpfs option' do
expect(chef_run).to render_file(file.name).with_content(/^gpfs_mount_point_base = multi-gpfs-mnt$/) expect(chef_run).to render_file(file.name).with_content(/^gpfs_mount_point_base = multi-gpfs-mnt$/)
end end
end end
it 'no multiple backends configured' do it 'no multiple backends configured' do
@ -1032,16 +1019,11 @@ describe 'openstack-block-storage::cinder-common' do
let(:dir) { chef_run.directory('/var/lib/cinder/lock') } let(:dir) { chef_run.directory('/var/lib/cinder/lock') }
it 'should create the /var/lib/cinder/lock directory' do it 'should create the /var/lib/cinder/lock directory' do
expect(chef_run).to create_directory(dir.name) expect(chef_run).to create_directory(dir.name).with(
end user: 'cinder',
group: 'cinder',
it 'has proper owner' do mode: 00755
expect(dir.owner).to eq('cinder') )
expect(dir.group).to eq('cinder')
end
it 'has proper modes' do
expect(sprintf('%o', dir.mode)).to eq '755'
end end
end end
@ -1061,13 +1043,13 @@ describe 'openstack-block-storage::cinder-common' do
node.set['openstack']['block-storage']['custom_template_banner'] = 'banner' node.set['openstack']['block-storage']['custom_template_banner'] = 'banner'
expect(chef_run).to render_file(file.name) expect(chef_run).to render_file(file.name)
.with_content(/^banner$/) .with_content(/^banner$/)
end end
it 'sets the default attributes' do it 'sets the default attributes' do
[ [
%r(^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$), %r{^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$},
%r(^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$), %r{^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$},
/^use_syslog=False$/, /^use_syslog=False$/,
/^syslog_log_facility=syslog$/, /^syslog_log_facility=syslog$/,
/^syslog_log_level=ERROR$/ /^syslog_log_level=ERROR$/

View File

@ -99,13 +99,12 @@ def expect_creates_cinder_conf(service, user, group, action = :restart) # ruboco
describe 'cinder.conf' do describe 'cinder.conf' do
let(:file) { chef_run.template('/etc/cinder/cinder.conf') } let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
it 'has proper owner' do it 'creates the /etc/cinder/cinder.conf file' do
expect(file.owner).to eq(user) expect(chef_run).to create_template(file.name).with(
expect(file.group).to eq(group) user: user,
end group: group,
mode: 0640
it 'has proper modes' do )
expect(sprintf('%o', file.mode)).to eq '640'
end end
it 'notifies service restart' do it 'notifies service restart' do

View File

@ -63,9 +63,9 @@ describe 'openstack-block-storage::volume' do
it 'creates IBMNAS shares_config file' do it 'creates IBMNAS shares_config file' do
expect(chef_run).to create_template(file.name).with( expect(chef_run).to create_template(file.name).with(
owner: 'cinder', owner: 'cinder',
group: 'cinder', group: 'cinder',
mode: '0600' mode: '0600'
) )
expect(chef_run).to render_file(file.name).with_content('127.0.0.1:/ibm/fs/export') expect(chef_run).to render_file(file.name).with_content('127.0.0.1:/ibm/fs/export')
end end
@ -77,9 +77,9 @@ describe 'openstack-block-storage::volume' do
it 'creates the nfs mount point' do it 'creates the nfs mount point' do
expect(chef_run).to create_directory('/mnt/cinder-volumes').with( expect(chef_run).to create_directory('/mnt/cinder-volumes').with(
owner: 'cinder', owner: 'cinder',
group: 'cinder', group: 'cinder',
mode: '0755' mode: '0755'
) )
end end
end end
@ -155,9 +155,9 @@ describe 'openstack-block-storage::volume' do
it 'verifies gpfs volume directory is created with owner and mode set correctly' do it 'verifies gpfs volume directory is created with owner and mode set correctly' do
expect(@chef_run).to create_directory('volumes').with( expect(@chef_run).to create_directory('volumes').with(
owner: 'cinder', owner: 'cinder',
group: 'cinder', group: 'cinder',
mode: '0755' mode: '0755'
) )
end end
end end
@ -172,7 +172,7 @@ describe 'openstack-block-storage::volume' do
describe 'template contents' do describe 'template contents' do
it 'sources /etc/rc.d/init.d/functions' do it 'sources /etc/rc.d/init.d/functions' do
expect(chef_run).to render_file(file.name).with_content(%r(^\s*. /etc/rc.d/init.d/functions$)) expect(chef_run).to render_file(file.name).with_content(%r{^\s*. /etc/rc.d/init.d/functions$})
end end
it 'calls success and echo' do it 'calls success and echo' do

View File

@ -65,9 +65,9 @@ describe 'openstack-block-storage::volume' do
context 'IBMNAS shares_config file' do context 'IBMNAS shares_config file' do
it 'creates the file' do it 'creates the file' do
expect(chef_run).to create_template(file.name).with( expect(chef_run).to create_template(file.name).with(
owner: 'cinder', owner: 'cinder',
group: 'cinder', group: 'cinder',
mode: '0600' mode: '0600'
) )
end end
@ -84,9 +84,9 @@ describe 'openstack-block-storage::volume' do
it 'creates the nfs mount point' do it 'creates the nfs mount point' do
expect(chef_run).to create_directory('/mnt/cinder-volumes').with( expect(chef_run).to create_directory('/mnt/cinder-volumes').with(
owner: 'cinder', owner: 'cinder',
group: 'cinder', group: 'cinder',
mode: '0755' mode: '0755'
) )
end end
end end
@ -216,11 +216,9 @@ describe 'openstack-block-storage::volume' do
let(:file) { chef_run.template('/etc/tgt/targets.conf') } let(:file) { chef_run.template('/etc/tgt/targets.conf') }
it 'should create the targets.conf' do it 'should create the targets.conf' do
expect(chef_run).to create_template(file.name) expect(chef_run).to create_template(file.name).with(
end mode: 0600
)
it 'has proper modes' do
expect(sprintf('%o', file.mode)).to eq '600'
end end
it 'notifies iscsi restart' do it 'notifies iscsi restart' do
@ -277,7 +275,7 @@ describe 'openstack-block-storage::volume' do
end end
it 'calls vgs with the volume name attribute' do it 'calls vgs with the volume name attribute' do
expect(chef_run).to render_file(file.name).with_content(%r(vgs #{volume_group_value} > /dev/null 2>&1)) expect(chef_run).to render_file(file.name).with_content(%r{vgs #{volume_group_value} > /dev/null 2>&1})
end end
it 'calls vgcreate with the volume name and volume file attributes' do it 'calls vgcreate with the volume name and volume file attributes' do
@ -315,11 +313,9 @@ describe 'openstack-block-storage::volume' do
end end
it 'creates cinder emc config file' do it 'creates cinder emc config file' do
expect(chef_run).to create_template(file.name) expect(chef_run).to create_template(file.name).with(
end mode: 0644
)
it 'has proper modes' do
expect(sprintf('%o', file.mode)).to eq('644')
end end
describe 'template contents' do describe 'template contents' do