Skip to content

Commit ea2f845

Browse files
committed
Upgrade rubocop config and fix some rubocop offenses
1 parent 5855671 commit ea2f845

File tree

7 files changed

+19
-24
lines changed

7 files changed

+19
-24
lines changed

.rubocop.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,6 @@ Style/DefWithParentheses:
528528
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
529529
Enabled: false
530530

531-
Style/DeprecatedHashMethods:
532-
Description: 'Checks for use of deprecated Hash methods.'
533-
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key'
534-
Enabled: false
535-
536531
Style/Documentation:
537532
Description: 'Document classes and non-namespace modules.'
538533
Enabled: false
@@ -716,7 +711,7 @@ Style/LineEndConcatenation:
716711
line end.
717712
Enabled: false
718713

719-
Style/MethodCallParentheses:
714+
Style/MethodCallWithoutArgsParentheses:
720715
Description: 'Do not use parentheses for method calls with no arguments.'
721716
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
722717
Enabled: false

lib/dory/dnsmasq.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def self.run_postconditions
4040
self.up_systemd_services if @@handle_systemd_services
4141
end
4242

43-
def self.handle_error(command_output)
43+
def self.handle_error(_command_output)
4444
puts "[DEBUG] handling dnsmasq start error" if Dory::Config.debug?
4545
# If we've already tried to handle failure, prevent infinite recursion
4646
if @@first_attempt_failed
@@ -101,16 +101,16 @@ def self.domain_addr_arg_string
101101
end
102102
end
103103

104-
def self.run_command(domains = self.domains)
104+
def self.run_command
105105
"docker run -d -p #{self.port}:#{self.port}/tcp -p #{self.port}:#{self.port}/udp " \
106106
"--name=#{Shellwords.escape(self.container_name)} " \
107107
"--cap-add=NET_ADMIN #{Shellwords.escape(self.dnsmasq_image_name)} " \
108108
"#{self.domain_addr_arg_string}"
109109
end
110110

111-
def self.check_port(port_num)
112-
puts "Requesting sudo to check if something is bound to port #{self.port}".green
113-
ret = Sh.run_command("sudo lsof -i :#{self.port}")
111+
def self.check_port(port_num = self.port)
112+
puts "Requesting sudo to check if something is bound to port #{port_num}".green
113+
ret = Sh.run_command("sudo lsof -i :#{port_num}")
114114
return [] unless ret.success?
115115

116116
list = ret.stdout.split("\n")

lib/dory/docker_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def run_postconditions
2121
return true
2222
end
2323

24-
def handle_error(command_output)
24+
def handle_error(_command_output)
2525
# Override to provide error handling
2626
return false
2727
end

lib/dory/proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def self.certs_arg
3131
def self.tls_arg
3232
if [:tls_enabled, :ssl_enabled, :https_enabled].any? { |s|
3333
Dory::Config.settings[:dory][:nginx_proxy][s]
34-
}
34+
}
3535
"-p 443:443"
3636
else
3737
''

spec/lib/resolv/linux_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@
166166
end
167167

168168
context "knows if we've edited the file" do
169-
let (:comment) { '# added by dory' }
169+
let(:comment) { '# added by dory' }
170170

171-
let (:stub_resolv) do
171+
let(:stub_resolv) do
172172
->(nameserver, file_comment = comment) do
173173
allow(Dory::Resolv::Linux).to receive(:nameserver){ nameserver }
174-
allow(Dory::Resolv::Linux).to receive(:file_comment){ comment }
174+
allow(Dory::Resolv::Linux).to receive(:file_comment){ file_comment }
175175
expect(Dory::Resolv::Linux.nameserver).to eq(nameserver)
176-
expect(Dory::Resolv::Linux.file_comment).to eq(comment)
176+
expect(Dory::Resolv::Linux.file_comment).to eq(file_comment)
177177
end
178178
end
179179

spec/lib/resolv/macos_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,18 @@
180180
end
181181

182182
context "knows if we've edited the file" do
183-
let (:comment) { '# added by dory' }
183+
let(:comment) { '# added by dory' }
184184

185-
let (:stub_resolv) do
185+
let(:stub_resolv) do
186186
->(nameserver, file_comment = comment) do
187187
allow(Dory::Resolv::Macos).to receive(:nameserver){ nameserver }
188-
allow(Dory::Resolv::Macos).to receive(:file_comment){ comment }
188+
allow(Dory::Resolv::Macos).to receive(:file_comment){ file_comment }
189189
expect(Dory::Resolv::Macos.nameserver).to eq(nameserver)
190-
expect(Dory::Resolv::Macos.file_comment).to eq(comment)
190+
expect(Dory::Resolv::Macos.file_comment).to eq(file_comment)
191191
end
192192
end
193193

194-
let (:contents) do
194+
let(:contents) do
195195
->(nameserver, port) do
196196
<<-EOF.gsub(' ' * 10, '')
197197
# added by dory
@@ -201,7 +201,7 @@
201201
end
202202
end
203203

204-
let (:stub_the_things) do
204+
let(:stub_the_things) do
205205
->(nameserver, port) do
206206
allow(Dory::Resolv::Macos).to receive(:file_nameserver_line) { "nameserver #{nameserver}" }
207207
allow(Dory::Resolv::Macos).to receive(:port) { port }

spec/lib/upgrade_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
let(:stub_sh) do
1414
->(success, stdout) do
1515
allow(Dory::Sh).to receive(:run_command) do
16-
OpenStruct.new(success?: true, stdout: stdout)
16+
OpenStruct.new(success?: success, stdout: stdout)
1717
end
1818
end
1919
end

0 commit comments

Comments
 (0)