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,5 +1,5 @@
# 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
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@@ -7,47 +7,13 @@
# Offense count: 1
Metrics/AbcSize:
Max: 28
Max: 18
# Offense count: 5
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/EmptyLinesAroundBlockBody:
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.

View File

@@ -15,7 +15,7 @@ recipe 'openstack-block-storage::scheduler', 'Installs the cinder-sche
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'
%w{ ubuntu fedora redhat centos suse }.each do |os|
%w(ubuntu fedora redhat centos suse).each do |os|
supports os
end

View File

@@ -22,7 +22,8 @@
# limitations under the License.
#
class ::Chef::Recipe # rubocop:disable Documentation
# Chef
class ::Chef::Recipe
include ::Openstack
end

View File

@@ -39,16 +39,11 @@ describe 'openstack-block-storage::api' do
let(:dir) { chef_run.directory('/var/cache/cinder') }
it 'should create the directory' do
expect(chef_run).to create_directory(dir.name)
end
it 'has proper owner' do
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')
expect(chef_run).to create_directory(dir.name).with(
owner: 'cinder',
group: 'cinder',
mode: 00700
)
end
end

View File

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

View File

@@ -25,16 +25,11 @@ describe 'openstack-block-storage::cinder-common' do
let(:dir) { chef_run.directory('/etc/cinder') }
it 'should create the /etc/cinder directory' do
expect(chef_run).to create_directory(dir.name)
end
it 'has proper owner' do
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'
expect(chef_run).to create_directory(dir.name).with(
owner: 'cinder',
group: 'cinder',
mode: 00750
)
end
end
@@ -48,16 +43,11 @@ describe 'openstack-block-storage::cinder-common' do
end
it 'should create the cinder.conf template' do
expect(chef_run).to create_template(file.name)
end
it 'has proper owner' do
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'
expect(chef_run).to create_template(file.name).with(
owner: 'cinder',
group: 'cinder',
mode: 00640
)
end
context 'keystone authtoken attributes with default values' do
@@ -124,13 +114,12 @@ describe 'openstack-block-storage::cinder-common' do
end
context 'endpoint related' 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
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
@@ -165,7 +154,6 @@ describe 'openstack-block-storage::cinder-common' do
end
context 'template contents' do
context 'commonly named attributes' do
%w(debug verbose host notification_driver
storage_availability_zone quota_volumes quota_gigabytes quota_driver
@@ -237,7 +225,7 @@ describe 'openstack-block-storage::cinder-common' do
end
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
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
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
@@ -1015,7 +1003,6 @@ describe 'openstack-block-storage::cinder-common' do
it 'set gpfs option' do
expect(chef_run).to render_file(file.name).with_content(/^gpfs_mount_point_base = multi-gpfs-mnt$/)
end
end
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') }
it 'should create the /var/lib/cinder/lock directory' do
expect(chef_run).to create_directory(dir.name)
end
it 'has proper owner' do
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'
expect(chef_run).to create_directory(dir.name).with(
user: 'cinder',
group: 'cinder',
mode: 00755
)
end
end
@@ -1066,8 +1048,8 @@ describe 'openstack-block-storage::cinder-common' do
it 'sets the default attributes' do
[
%r(^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$),
%r(^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$),
%r{^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$},
%r{^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$},
/^use_syslog=False$/,
/^syslog_log_facility=syslog$/,
/^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
let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
it 'has proper owner' do
expect(file.owner).to eq(user)
expect(file.group).to eq(group)
end
it 'has proper modes' do
expect(sprintf('%o', file.mode)).to eq '640'
it 'creates the /etc/cinder/cinder.conf file' do
expect(chef_run).to create_template(file.name).with(
user: user,
group: group,
mode: 0640
)
end
it 'notifies service restart' do

View File

@@ -172,7 +172,7 @@ describe 'openstack-block-storage::volume' do
describe 'template contents' 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
it 'calls success and echo' do

View File

@@ -216,11 +216,9 @@ describe 'openstack-block-storage::volume' do
let(:file) { chef_run.template('/etc/tgt/targets.conf') }
it 'should create the targets.conf' do
expect(chef_run).to create_template(file.name)
end
it 'has proper modes' do
expect(sprintf('%o', file.mode)).to eq '600'
expect(chef_run).to create_template(file.name).with(
mode: 0600
)
end
it 'notifies iscsi restart' do
@@ -277,7 +275,7 @@ describe 'openstack-block-storage::volume' do
end
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
it 'calls vgcreate with the volume name and volume file attributes' do
@@ -315,11 +313,9 @@ describe 'openstack-block-storage::volume' do
end
it 'creates cinder emc config file' do
expect(chef_run).to create_template(file.name)
end
it 'has proper modes' do
expect(sprintf('%o', file.mode)).to eq('644')
expect(chef_run).to create_template(file.name).with(
mode: 0644
)
end
describe 'template contents' do