Browse Source

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
Mark Vanderwiel 3 years ago
parent
commit
0b94103098
10 changed files with 94 additions and 156 deletions
  1. 21
    55
      .rubocop_todo.yml
  2. 13
    13
      metadata.rb
  3. 1
    1
      recipes/cinder-common.rb
  4. 3
    2
      recipes/volume.rb
  5. 5
    10
      spec/api_spec.rb
  6. 0
    1
      spec/backup_spec.rb
  7. 22
    40
      spec/cinder_common_spec.rb
  8. 6
    7
      spec/spec_helper.rb
  9. 10
    10
      spec/volume-redhat_spec.rb
  10. 13
    17
      spec/volume_spec.rb

+ 21
- 55
.rubocop_todo.yml View File

@@ -1,55 +1,21 @@
1
-# This configuration was generated by `rubocop --auto-gen-config`
2
-# on 2015-02-27 14:45:01 -0600 using RuboCop version 0.29.1.
3
-# The point is for the user to remove these configuration records
4
-# one by one as the offenses are removed from the code base.
5
-# Note that changes in the inspected code, or installation of new
6
-# versions of RuboCop, may require this file to be generated again.
7
-
8
-# Offense count: 1
9
-Metrics/AbcSize:
10
-  Max: 28
11
-
12
-# Offense count: 5
13
-# Configuration parameters: EnforcedStyle, SupportedStyles.
14
-Style/ClassAndModuleChildren:
15
-  Enabled: false
16
-
17
-# Offense count: 3
18
-# Cop supports --auto-correct.
19
-# Configuration parameters: EnforcedStyle, SupportedStyles.
20
-Style/EmptyLinesAroundBlockBody:
21
-  Enabled: false
22
-
23
-# Offense count: 5
24
-# Cop supports --auto-correct.
25
-# Configuration parameters: EnforcedStyle, SupportedStyles.
26
-Style/FirstParameterIndentation:
27
-  Enabled: false
28
-
29
-# Offense count: 8
30
-# Configuration parameters: EnforcedStyle, SupportedStyles.
31
-Style/FormatString:
32
-  Enabled: false
33
-
34
-# Offense count: 1
35
-# Cop supports --auto-correct.
36
-# Configuration parameters: EnforcedStyle, SupportedStyles.
37
-Style/MultilineOperationIndentation:
38
-  Enabled: false
39
-
40
-# Offense count: 6
41
-# Cop supports --auto-correct.
42
-# Configuration parameters: PreferredDelimiters.
43
-Style/PercentLiteralDelimiters:
44
-  Enabled: false
45
-
46
-# Offense count: 13
47
-# Cop supports --auto-correct.
48
-Style/SingleSpaceBeforeFirstArg:
49
-  Enabled: false
50
-
51
-# Offense count: 1
52
-# Cop supports --auto-correct.
53
-# Configuration parameters: IgnoredMethods.
54
-Style/SymbolProc:
55
-  Enabled: false
1
+# This configuration was generated by `rubocop --auto-gen-config`
2
+# on 2015-05-28 14:36:48 -0500 using RuboCop version 0.29.1.
3
+# The point is for the user to remove these configuration records
4
+# one by one as the offenses are removed from the code base.
5
+# Note that changes in the inspected code, or installation of new
6
+# versions of RuboCop, may require this file to be generated again.
7
+
8
+# Offense count: 1
9
+Metrics/AbcSize:
10
+  Max: 18
11
+
12
+# Offense count: 5
13
+# Configuration parameters: EnforcedStyle, SupportedStyles.
14
+Style/ClassAndModuleChildren:
15
+  Enabled: false
16
+
17
+# Offense count: 1
18
+# Cop supports --auto-correct.
19
+# Configuration parameters: IgnoredMethods.
20
+Style/SymbolProc:
21
+  Enabled: false

+ 13
- 13
metadata.rb View File

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

+ 1
- 1
recipes/cinder-common.rb View File

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

+ 3
- 2
recipes/volume.rb View File

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

+ 5
- 10
spec/api_spec.rb View File

@@ -39,16 +39,11 @@ describe 'openstack-block-storage::api' do
39 39
       let(:dir) { chef_run.directory('/var/cache/cinder') }
40 40
 
41 41
       it 'should create the directory' do
42
-        expect(chef_run).to create_directory(dir.name)
43
-      end
44
-
45
-      it 'has proper owner' do
46
-        expect(dir.owner).to eq('cinder')
47
-        expect(dir.group).to eq('cinder')
48
-      end
49
-
50
-      it 'has proper modes' do
51
-        expect(sprintf('%o', dir.mode)).to eq('700')
42
+        expect(chef_run).to create_directory(dir.name).with(
43
+          owner: 'cinder',
44
+          group: 'cinder',
45
+          mode: 00700
46
+        )
52 47
       end
53 48
     end
54 49
 

+ 0
- 1
spec/backup_spec.rb View File

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

+ 22
- 40
spec/cinder_common_spec.rb View File

@@ -25,16 +25,11 @@ describe 'openstack-block-storage::cinder-common' do
25 25
       let(:dir) { chef_run.directory('/etc/cinder') }
26 26
 
27 27
       it 'should create the /etc/cinder directory' do
28
-        expect(chef_run).to create_directory(dir.name)
29
-      end
30
-
31
-      it 'has proper owner' do
32
-        expect(dir.owner).to eq('cinder')
33
-        expect(dir.group).to eq('cinder')
34
-      end
35
-
36
-      it 'has proper modes' do
37
-        expect(sprintf('%o', dir.mode)).to eq '750'
28
+        expect(chef_run).to create_directory(dir.name).with(
29
+          owner: 'cinder',
30
+          group: 'cinder',
31
+          mode: 00750
32
+        )
38 33
       end
39 34
     end
40 35
 
@@ -48,16 +43,11 @@ describe 'openstack-block-storage::cinder-common' do
48 43
       end
49 44
 
50 45
       it 'should create the cinder.conf template' do
51
-        expect(chef_run).to create_template(file.name)
52
-      end
53
-
54
-      it 'has proper owner' do
55
-        expect(file.owner).to eq('cinder')
56
-        expect(file.group).to eq('cinder')
57
-      end
58
-
59
-      it 'has proper modes' do
60
-        expect(sprintf('%o', file.mode)).to eq '640'
46
+        expect(chef_run).to create_template(file.name).with(
47
+          owner: 'cinder',
48
+          group: 'cinder',
49
+          mode: 00640
50
+        )
61 51
       end
62 52
 
63 53
       context 'keystone authtoken attributes with default values' do
@@ -124,13 +114,12 @@ describe 'openstack-block-storage::cinder-common' do
124 114
         end
125 115
 
126 116
         context 'endpoint related' do
127
-
128 117
           it 'has auth_uri' do
129
-            expect(chef_run).to render_file(file.name).with_content(%r(^auth_uri = http://127.0.0.1:5000/v2.0$))
118
+            expect(chef_run).to render_file(file.name).with_content(%r{^auth_uri = http://127.0.0.1:5000/v2.0$})
130 119
           end
131 120
 
132 121
           it 'has identity_uri' do
133
-            expect(chef_run).to render_file(file.name).with_content(%r(^identity_uri = http://127.0.0.1:35357/$))
122
+            expect(chef_run).to render_file(file.name).with_content(%r{^identity_uri = http://127.0.0.1:35357/$})
134 123
           end
135 124
         end
136 125
 
@@ -165,7 +154,6 @@ describe 'openstack-block-storage::cinder-common' do
165 154
       end
166 155
 
167 156
       context 'template contents' do
168
-
169 157
         context 'commonly named attributes' do
170 158
           %w(debug verbose host notification_driver
171 159
              storage_availability_zone quota_volumes quota_gigabytes quota_driver
@@ -237,7 +225,7 @@ describe 'openstack-block-storage::cinder-common' do
237 225
         end
238 226
 
239 227
         it 'has a lock_path attribute' do
240
-          expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r(^lock_path=/var/lib/cinder/lock$))
228
+          expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r{^lock_path=/var/lib/cinder/lock$})
241 229
         end
242 230
 
243 231
         it 'does not have unique host id by default' do
@@ -839,7 +827,7 @@ describe 'openstack-block-storage::cinder-common' do
839 827
 
840 828
           it 'has wsdl_location line with attribute present' do
841 829
             node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = 'http://127.0.0.1/wsdl'
842
-            expect(chef_run).to render_file(file.name).with_content(%r(^vmware_wsdl_location = http://127.0.0.1/wsdl$))
830
+            expect(chef_run).to render_file(file.name).with_content(%r{^vmware_wsdl_location = http://127.0.0.1/wsdl$})
843 831
           end
844 832
         end
845 833
 
@@ -1015,7 +1003,6 @@ describe 'openstack-block-storage::cinder-common' do
1015 1003
           it 'set gpfs option' do
1016 1004
             expect(chef_run).to render_file(file.name).with_content(/^gpfs_mount_point_base = multi-gpfs-mnt$/)
1017 1005
           end
1018
-
1019 1006
         end
1020 1007
 
1021 1008
         it 'no multiple backends configured' do
@@ -1032,16 +1019,11 @@ describe 'openstack-block-storage::cinder-common' do
1032 1019
       let(:dir) { chef_run.directory('/var/lib/cinder/lock') }
1033 1020
 
1034 1021
       it 'should create the /var/lib/cinder/lock directory' do
1035
-        expect(chef_run).to create_directory(dir.name)
1036
-      end
1037
-
1038
-      it 'has proper owner' do
1039
-        expect(dir.owner).to eq('cinder')
1040
-        expect(dir.group).to eq('cinder')
1041
-      end
1042
-
1043
-      it 'has proper modes' do
1044
-        expect(sprintf('%o', dir.mode)).to eq '755'
1022
+        expect(chef_run).to create_directory(dir.name).with(
1023
+          user: 'cinder',
1024
+          group: 'cinder',
1025
+          mode: 00755
1026
+        )
1045 1027
       end
1046 1028
     end
1047 1029
 
@@ -1061,13 +1043,13 @@ describe 'openstack-block-storage::cinder-common' do
1061 1043
           node.set['openstack']['block-storage']['custom_template_banner'] = 'banner'
1062 1044
 
1063 1045
           expect(chef_run).to render_file(file.name)
1064
-          .with_content(/^banner$/)
1046
+            .with_content(/^banner$/)
1065 1047
         end
1066 1048
 
1067 1049
         it 'sets the default attributes' do
1068 1050
           [
1069
-            %r(^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$),
1070
-            %r(^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$),
1051
+            %r{^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$},
1052
+            %r{^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$},
1071 1053
             /^use_syslog=False$/,
1072 1054
             /^syslog_log_facility=syslog$/,
1073 1055
             /^syslog_log_level=ERROR$/

+ 6
- 7
spec/spec_helper.rb View File

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

+ 10
- 10
spec/volume-redhat_spec.rb View File

@@ -63,9 +63,9 @@ describe 'openstack-block-storage::volume' do
63 63
 
64 64
       it 'creates IBMNAS shares_config file' do
65 65
         expect(chef_run).to create_template(file.name).with(
66
-           owner: 'cinder',
67
-           group: 'cinder',
68
-           mode: '0600'
66
+          owner: 'cinder',
67
+          group: 'cinder',
68
+          mode: '0600'
69 69
         )
70 70
         expect(chef_run).to render_file(file.name).with_content('127.0.0.1:/ibm/fs/export')
71 71
       end
@@ -77,9 +77,9 @@ describe 'openstack-block-storage::volume' do
77 77
 
78 78
       it 'creates the nfs mount point' do
79 79
         expect(chef_run).to create_directory('/mnt/cinder-volumes').with(
80
-           owner: 'cinder',
81
-           group: 'cinder',
82
-           mode: '0755'
80
+          owner: 'cinder',
81
+          group: 'cinder',
82
+          mode: '0755'
83 83
         )
84 84
       end
85 85
     end
@@ -155,9 +155,9 @@ describe 'openstack-block-storage::volume' do
155 155
 
156 156
       it 'verifies gpfs volume directory is created with owner and mode set correctly' do
157 157
         expect(@chef_run).to create_directory('volumes').with(
158
-           owner: 'cinder',
159
-           group: 'cinder',
160
-           mode: '0755'
158
+          owner: 'cinder',
159
+          group: 'cinder',
160
+          mode: '0755'
161 161
         )
162 162
       end
163 163
     end
@@ -172,7 +172,7 @@ describe 'openstack-block-storage::volume' do
172 172
 
173 173
       describe 'template contents' do
174 174
         it 'sources /etc/rc.d/init.d/functions' do
175
-          expect(chef_run).to render_file(file.name).with_content(%r(^\s*. /etc/rc.d/init.d/functions$))
175
+          expect(chef_run).to render_file(file.name).with_content(%r{^\s*. /etc/rc.d/init.d/functions$})
176 176
         end
177 177
 
178 178
         it 'calls success and echo' do

+ 13
- 17
spec/volume_spec.rb View File

@@ -65,9 +65,9 @@ describe 'openstack-block-storage::volume' do
65 65
       context 'IBMNAS shares_config file' do
66 66
         it 'creates the file' do
67 67
           expect(chef_run).to create_template(file.name).with(
68
-           owner: 'cinder',
69
-           group: 'cinder',
70
-           mode: '0600'
68
+            owner: 'cinder',
69
+            group: 'cinder',
70
+            mode: '0600'
71 71
         )
72 72
         end
73 73
 
@@ -84,9 +84,9 @@ describe 'openstack-block-storage::volume' do
84 84
 
85 85
       it 'creates the nfs mount point' do
86 86
         expect(chef_run).to create_directory('/mnt/cinder-volumes').with(
87
-           owner: 'cinder',
88
-           group: 'cinder',
89
-           mode: '0755'
87
+          owner: 'cinder',
88
+          group: 'cinder',
89
+          mode: '0755'
90 90
         )
91 91
       end
92 92
     end
@@ -216,11 +216,9 @@ describe 'openstack-block-storage::volume' do
216 216
       let(:file) { chef_run.template('/etc/tgt/targets.conf') }
217 217
 
218 218
       it 'should create the targets.conf' do
219
-        expect(chef_run).to create_template(file.name)
220
-      end
221
-
222
-      it 'has proper modes' do
223
-        expect(sprintf('%o', file.mode)).to eq '600'
219
+        expect(chef_run).to create_template(file.name).with(
220
+          mode: 0600
221
+        )
224 222
       end
225 223
 
226 224
       it 'notifies iscsi restart' do
@@ -277,7 +275,7 @@ describe 'openstack-block-storage::volume' do
277 275
         end
278 276
 
279 277
         it 'calls vgs with the volume name attribute' do
280
-          expect(chef_run).to render_file(file.name).with_content(%r(vgs #{volume_group_value} > /dev/null 2>&1))
278
+          expect(chef_run).to render_file(file.name).with_content(%r{vgs #{volume_group_value} > /dev/null 2>&1})
281 279
         end
282 280
 
283 281
         it 'calls vgcreate with the volume name and volume file attributes' do
@@ -315,11 +313,9 @@ describe 'openstack-block-storage::volume' do
315 313
       end
316 314
 
317 315
       it 'creates cinder emc config file' do
318
-        expect(chef_run).to create_template(file.name)
319
-      end
320
-
321
-      it 'has proper modes' do
322
-        expect(sprintf('%o', file.mode)).to eq('644')
316
+        expect(chef_run).to create_template(file.name).with(
317
+          mode: 0644
318
+        )
323 319
       end
324 320
 
325 321
       describe 'template contents' do

Loading…
Cancel
Save