Skip to content

Commit 5d04cda

Browse files
committed
Fix Rubocop offenses
Rubocop can not be added to Gemfile or Travis testing until sunggun-yu#49 is merged due to dependency conflicts
1 parent 1b6565c commit 5d04cda

File tree

9 files changed

+184
-162
lines changed

9 files changed

+184
-162
lines changed

.rubocop.yml

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,56 @@
11
AllCops:
2+
DisplayCopNames: true
23
Exclude:
34
- 'Berksfile'
45
- 'Thorfile'
56
- 'Vagrantfile'
67
- 'Gemfile'
78
- 'metadata.rb'
89

9-
AlignParameters:
10+
Lint/LiteralInCondition:
1011
Enabled: false
1112

12-
Encoding:
13+
Lint/ParenthesesAsGroupedExpression:
1314
Enabled: false
1415

15-
LineLength:
16-
Max: 200
16+
Metrics/LineLength:
17+
Enabled: false
1718

18-
HashSyntax:
19-
EnforcedStyle: hash_rockets
19+
Metrics/MethodLength:
20+
Max: 18
2021

21-
AsciiComments:
22+
Style/AlignParameters:
2223
Enabled: false
2324

24-
MethodLength:
25-
Max: 18
25+
Style/AsciiComments:
26+
Enabled: false
27+
28+
Style/ConditionalAssignment:
29+
Enabled: false
30+
31+
Style/Documentation:
32+
Enabled: false
33+
34+
Style/EachWithObject:
35+
Enabled: false
36+
37+
Style/Encoding:
38+
Enabled: false
2639

2740
Style/FileName:
2841
Enabled: false
42+
43+
Style/HashSyntax:
44+
EnforcedStyle: hash_rockets
45+
46+
Style/NumericLiterals:
47+
Enabled: false
48+
49+
Style/SpaceInsideBrackets:
50+
Enabled: false
51+
52+
Style/RedundantParentheses:
53+
Enabled: false
54+
55+
Style/WordArray:
56+
Enabled: false

attributes/default.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@
3232
default['mongodb3']['package']['repo']['url'] = nil
3333

3434
# MongoDB repository info for apt
35-
default['mongodb3']['package']['repo']['apt']['name'] = nil # eg. 3.0, 3.2
35+
default['mongodb3']['package']['repo']['apt']['name'] = nil # eg. 3.0, 3.2
3636
default['mongodb3']['package']['repo']['apt']['keyserver'] = nil # eg. hkp://keyserver.ubuntu.com:80
3737
default['mongodb3']['package']['repo']['apt']['key'] = nil # eg. 3.2 : 'EA312927', 3.0 : '7F0CEB10'
3838
default['mongodb3']['package']['repo']['apt']['components'] = nil # eg. ['multiverse']
3939

4040
# Default attribute for MongoDB installation
4141
case node['platform_family']
42-
when 'rhel', 'fedora'
43-
mongo_user = 'mongod'
44-
mongo_group = 'mongod'
45-
mongo_dbpath = '/var/lib/mongo'
46-
# To guarantee the compatibility for centos 6 in previous version of mongodb3 cookbook
47-
if node['platform_version'].to_i >= 7
48-
mongo_pid_file = '/var/run/mongodb/mongod.pid'
49-
else
50-
mongo_pid_file = '/var/run/mongodb/mongodb.pid'
51-
end
52-
config_processManagement_fork = true
53-
when 'debian'
54-
mongo_user = 'mongodb'
55-
mongo_group = 'mongodb'
56-
mongo_dbpath = '/var/lib/mongodb'
57-
mongo_pid_file = nil
58-
config_processManagement_fork = nil
42+
when 'rhel', 'fedora'
43+
mongo_user = 'mongod'
44+
mongo_group = 'mongod'
45+
mongo_dbpath = '/var/lib/mongo'
46+
# To guarantee the compatibility for centos 6 in previous version of mongodb3 cookbook
47+
if node['platform_version'].to_i >= 7
48+
mongo_pid_file = '/var/run/mongodb/mongod.pid'
49+
else
50+
mongo_pid_file = '/var/run/mongodb/mongodb.pid'
51+
end
52+
config_process_management_fork = true
53+
when 'debian'
54+
mongo_user = 'mongodb'
55+
mongo_group = 'mongodb'
56+
mongo_dbpath = '/var/lib/mongodb'
57+
mongo_pid_file = nil
58+
config_process_management_fork = nil
5959
end
6060

6161
# MongoDB user:group
@@ -113,7 +113,7 @@
113113

114114
# processManagement Options : http://docs.mongodb.org/manual/reference/configuration-options/#processmanagement-options
115115

116-
default['mongodb3']['config']['mongod']['processManagement']['fork'] = config_processManagement_fork # default : false
116+
default['mongodb3']['config']['mongod']['processManagement']['fork'] = config_process_management_fork # default : false
117117
default['mongodb3']['config']['mongod']['processManagement']['pidFilePath'] = mongo_pid_file
118118

119119
# net Options : http://docs.mongodb.org/manual/reference/configuration-options/#net-options

recipes/default.rb

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
package pkg do
2727
version node['mongodb3']['package']['version']
2828
case node['platform_family']
29-
when 'debian'
30-
# bypass dpkg errors about pre-existing init or conf file
31-
options '-o Dpkg::Options::="--force-confold" --force-yes'
29+
when 'debian'
30+
# bypass dpkg errors about pre-existing init or conf file
31+
options '-o Dpkg::Options::="--force-confold" --force-yes'
3232
end
3333
action :install
3434
end
@@ -75,9 +75,9 @@
7575
# Update the mongodb config file
7676
template node['mongodb3']['mongod']['config_file'] do
7777
source 'mongodb.conf.erb'
78-
mode 0644
78+
mode '0644'
7979
variables(
80-
:config => node['mongodb3']['config']['mongod']
80+
:config => node['mongodb3']['config']['mongod']
8181
)
8282
helpers Mongodb3Helper
8383
end
@@ -90,59 +90,53 @@
9090
group 'root'
9191
mode '0755'
9292
action :create
93-
only_if {
94-
node['mongodb3']['mongod']['disable-transparent-hugepages']
95-
}
93+
only_if { node['mongodb3']['mongod']['disable-transparent-hugepages'] }
9694
end
9795

9896
case node['platform']
99-
when 'ubuntu'
100-
if node['platform_version'].to_f >= 15.04
101-
cookbook_file '/lib/systemd/system/disable-transparent-hugepages.service' do
102-
source 'disable-transparent-hugepages.service'
103-
owner 'root'
104-
group 'root'
105-
mode '0655'
106-
action :create
107-
only_if {
108-
node['mongodb3']['mongod']['disable-transparent-hugepages']
109-
}
110-
end
97+
when 'ubuntu'
98+
if node['platform_version'].to_f >= 15.04
99+
cookbook_file '/lib/systemd/system/disable-transparent-hugepages.service' do
100+
source 'disable-transparent-hugepages.service'
101+
owner 'root'
102+
group 'root'
103+
mode '0655'
104+
action :create
105+
only_if { node['mongodb3']['mongod']['disable-transparent-hugepages'] }
111106
end
107+
end
112108
end
113109

114110
service 'disable-transparent-hugepages' do
115111
case node['platform']
116-
when 'ubuntu'
117-
if node['platform_version'].to_f >= 15.04
118-
provider Chef::Provider::Service::Systemd
119-
end
112+
when 'ubuntu'
113+
if node['platform_version'].to_f >= 15.04
114+
provider Chef::Provider::Service::Systemd
115+
end
120116
end
121117
action [ :enable, :start ]
122-
only_if {
123-
node['mongodb3']['mongod']['disable-transparent-hugepages']
124-
}
118+
only_if { node['mongodb3']['mongod']['disable-transparent-hugepages'] }
125119
end
126120

127121
# Create the mongod.service file
128122
case node['platform']
129-
when 'ubuntu'
130-
template '/lib/systemd/system/mongod.service' do
131-
source 'mongod.service.erb'
132-
mode 0644
133-
only_if { node['platform_version'].to_f >= 15.04 }
134-
end
123+
when 'ubuntu'
124+
template '/lib/systemd/system/mongod.service' do
125+
source 'mongod.service.erb'
126+
mode '0644'
127+
only_if { node['platform_version'].to_f >= 15.04 }
128+
end
135129
end
136130

137131
# Start the mongod service
138132
service 'mongod' do
139133
case node['platform']
140-
when 'ubuntu'
141-
if node['platform_version'].to_f >= 15.04
142-
provider Chef::Provider::Service::Systemd
143-
elsif node['platform_version'].to_f >= 14.04
144-
provider Chef::Provider::Service::Upstart
145-
end
134+
when 'ubuntu'
135+
if node['platform_version'].to_f >= 15.04
136+
provider Chef::Provider::Service::Systemd
137+
elsif node['platform_version'].to_f >= 14.04
138+
provider Chef::Provider::Service::Upstart
139+
end
146140
end
147141
supports :start => true, :stop => true, :restart => true, :status => true
148142
action :enable

recipes/mms_automation_agent.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424

2525
# Set variables by platform
2626
case node['platform_family']
27-
when 'rhel', 'fedora'
28-
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager-latest.x86_64.rpm'
29-
mms_agent_file = '/root/mongodb-mms-automation-agent-manager-latest.x86_64.rpm'
30-
when 'debian'
31-
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 15.04
32-
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb'
33-
mms_agent_file = '/root/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb'
34-
else
35-
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.deb'
36-
mms_agent_file = '/root/mongodb-mms-automation-agent-manager_latest_amd64.deb'
37-
end
27+
when 'rhel', 'fedora'
28+
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager-latest.x86_64.rpm'
29+
mms_agent_file = '/root/mongodb-mms-automation-agent-manager-latest.x86_64.rpm'
30+
when 'debian'
31+
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 15.04
32+
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb'
33+
mms_agent_file = '/root/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb'
34+
else
35+
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.deb'
36+
mms_agent_file = '/root/mongodb-mms-automation-agent-manager_latest_amd64.deb'
37+
end
3838
end
3939

4040
# Download the mms automation agent manager latest
@@ -48,26 +48,26 @@
4848

4949
# Install package
5050
case node['platform_family']
51-
when 'rhel', 'fedora'
52-
rpm_package 'mongodb-mms-automation-agent-manager' do
53-
source mms_agent_file
54-
action :install
55-
end
56-
when 'debian'
57-
dpkg_package 'mongodb-mms-automation-agent-manager' do
58-
source mms_agent_file
59-
action :install
60-
end
51+
when 'rhel', 'fedora'
52+
rpm_package 'mongodb-mms-automation-agent-manager' do
53+
source mms_agent_file
54+
action :install
55+
end
56+
when 'debian'
57+
dpkg_package 'mongodb-mms-automation-agent-manager' do
58+
source mms_agent_file
59+
action :install
60+
end
6161
end
6262

6363
# Create or modify the mms agent config file
6464
template '/etc/mongodb-mms/automation-agent.config' do
6565
source 'automation-agent.config.erb'
66-
mode 0600
66+
mode '0600'
6767
owner node['mongodb3']['user']
6868
group node['mongodb3']['group']
6969
variables(
70-
:config => node['mongodb3']['config']['mms']
70+
:config => node['mongodb3']['config']['mms']
7171
)
7272
end
7373

recipes/mms_monitoring_agent.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424

2525
# Set variables by platform
2626
case node['platform_family']
27-
when 'rhel', 'fedora'
28-
mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent-latest.x86_64.rpm'
29-
mms_agent_file = '/root/mongodb-mms-monitoring-agent-latest.x86_64.rpm'
30-
when 'debian'
31-
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 15.04
32-
mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_latest_amd64.ubuntu1604.deb'
33-
mms_agent_file = '/root/mongodb-mms-monitoring-agent_latest_amd64.ubuntu1604.deb'
34-
else
35-
mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_latest_amd64.deb'
36-
mms_agent_file = '/root/mongodb-mms-monitoring-agent_latest_amd64.deb'
37-
end
27+
when 'rhel', 'fedora'
28+
mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent-latest.x86_64.rpm'
29+
mms_agent_file = '/root/mongodb-mms-monitoring-agent-latest.x86_64.rpm'
30+
when 'debian'
31+
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 15.04
32+
mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_latest_amd64.ubuntu1604.deb'
33+
mms_agent_file = '/root/mongodb-mms-monitoring-agent_latest_amd64.ubuntu1604.deb'
34+
else
35+
mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_latest_amd64.deb'
36+
mms_agent_file = '/root/mongodb-mms-monitoring-agent_latest_amd64.deb'
37+
end
3838
end
3939

4040
# Download the mms automation agent manager latest
@@ -45,26 +45,26 @@
4545

4646
# Install package
4747
case node['platform_family']
48-
when 'rhel', 'fedora'
49-
rpm_package 'mongodb-mms-monitoring-agent' do
50-
source mms_agent_file
51-
action :install
52-
end
53-
when 'debian'
54-
dpkg_package 'mongodb-mms-monitoring-agent' do
55-
source mms_agent_file
56-
action :install
57-
end
48+
when 'rhel', 'fedora'
49+
rpm_package 'mongodb-mms-monitoring-agent' do
50+
source mms_agent_file
51+
action :install
52+
end
53+
when 'debian'
54+
dpkg_package 'mongodb-mms-monitoring-agent' do
55+
source mms_agent_file
56+
action :install
57+
end
5858
end
5959

6060
# Create or modify the mms agent config file
6161
template '/etc/mongodb-mms/monitoring-agent.config' do
6262
source 'monitoring-agent.config.erb'
63-
mode 0600
63+
mode '0600'
6464
owner 'mongodb-mms-agent'
6565
group 'mongodb-mms-agent'
6666
variables(
67-
:config => node['mongodb3']['config']['mms']
67+
:config => node['mongodb3']['config']['mms']
6868
)
6969
end
7070

recipes/mongos.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
template node['mongodb3']['mongos']['config_file'] do
4040
source 'mongodb.conf.erb'
4141
owner node['mongodb3']['user']
42-
mode 0644
42+
mode '0644'
4343
variables(
44-
:config => node['mongodb3']['config']['mongos']
44+
:config => node['mongodb3']['config']['mongos']
4545
)
4646
helpers Mongodb3Helper
4747
notifies :restart, 'runit_service[mongos]'
@@ -84,7 +84,7 @@
8484
restart_on_update true
8585
cookbook node['mongodb3']['mongos']['runit_template_cookbook']
8686
options ({
87-
:user => node['mongodb3']['user'],
88-
:config_file => node['mongodb3']['mongos']['config_file']
89-
})
87+
:user => node['mongodb3']['user'],
88+
:config_file => node['mongodb3']['mongos']['config_file']
89+
})
9090
end

0 commit comments

Comments
 (0)