Skip to content

Commit 7c64136

Browse files
authored
Merge pull request #119 from bastelfreak/rubocop
fix multiple rubocop violations
2 parents a0e5756 + e87f17e commit 7c64136

4 files changed

Lines changed: 17 additions & 77 deletions

File tree

.rubocop_todo.yml

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,11 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-03-17 09:38:53 UTC using RuboCop version 1.12.1.
3+
# on 2023-03-17 12:20:43 UTC using RuboCop version 1.12.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 1
10-
Lint/IneffectiveAccessModifier:
11-
Exclude:
12-
- 'lib/beaker-rspec/helpers/serverspec.rb'
13-
14-
# Offense count: 1
15-
# Cop supports --auto-correct.
16-
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
17-
Lint/UnusedBlockArgument:
18-
Exclude:
19-
- 'lib/beaker-rspec/spec_helper.rb'
20-
21-
# Offense count: 2
22-
# Cop supports --auto-correct.
23-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
24-
Lint/UnusedMethodArgument:
25-
Exclude:
26-
- 'lib/beaker-rspec/helpers/serverspec.rb'
27-
28-
# Offense count: 1
29-
# Cop supports --auto-correct.
30-
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
31-
Lint/UselessAccessModifier:
32-
Exclude:
33-
- 'lib/beaker-rspec/helpers/serverspec.rb'
34-
359
# Offense count: 3
3610
Lint/UselessAssignment:
3711
Exclude:
@@ -56,24 +30,6 @@ Naming/MethodParameterName:
5630
Exclude:
5731
- 'lib/beaker-rspec/beaker_shim.rb'
5832

59-
# Offense count: 4
60-
# Cop supports --auto-correct.
61-
Performance/RegexpMatch:
62-
Exclude:
63-
- 'lib/beaker-rspec/helpers/serverspec.rb'
64-
65-
# Offense count: 3
66-
# Cop supports --auto-correct.
67-
Performance/StringIdentifierArgument:
68-
Exclude:
69-
- 'lib/beaker-rspec/helpers/serverspec.rb'
70-
71-
# Offense count: 3
72-
# Cop supports --auto-correct.
73-
Performance/StringInclude:
74-
Exclude:
75-
- 'lib/beaker-rspec/helpers/serverspec.rb'
76-
7733
# Offense count: 3
7834
# Configuration parameters: Prefixes.
7935
# Prefixes: when, with, without
@@ -86,18 +42,3 @@ RSpec/ContextWording:
8642
RSpec/DescribeClass:
8743
Exclude:
8844
- 'spec/acceptance/example_spec.rb'
89-
90-
# Offense count: 5
91-
# Cop supports --auto-correct.
92-
# Configuration parameters: .
93-
# SupportedStyles: is_expected, should
94-
RSpec/ImplicitExpect:
95-
EnforcedStyle: should
96-
97-
# Offense count: 1
98-
# Cop supports --auto-correct.
99-
# Configuration parameters: EnforcedStyleForMultiline.
100-
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
101-
Style/TrailingCommaInHashLiteral:
102-
Exclude:
103-
- 'lib/beaker-rspec/helpers/serverspec.rb'

lib/beaker-rspec/helpers/serverspec.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def detect_os
8080
return Specinfra.configuration.os if Specinfra.configuration.os
8181
backend = Specinfra.backend
8282
node = get_working_node
83-
if node['platform'] =~ /windows/
83+
if node['platform'].include?('windows')
8484
return {:family => 'windows'}
8585
end
8686
Specinfra::Helper::DetectOs.subclasses.each do |c|
@@ -103,9 +103,9 @@ def get_windows_cmd(meth, *args)
103103
method += "_#{subaction}" if subaction
104104

105105
common_class = Specinfra::Command
106-
base_class = common_class.const_get('Base')
107-
os_class = common_class.const_get('Windows')
108-
version_class = os_class.const_get('Base')
106+
base_class = common_class.const_get(:Base)
107+
os_class = common_class.const_get(:Windows)
108+
version_class = os_class.const_get(:Base)
109109
command_class = version_class.const_get(resource_type.to_camel_case)
110110

111111
command_class = command_class.create
@@ -126,7 +126,7 @@ class Runner
126126
def self.method_missing(meth, *args)
127127
backend = Specinfra.backend
128128
node = get_working_node
129-
if node['platform'] !~ /windows/
129+
if !node['platform'].include?('windows')
130130
processor = Specinfra::Processor
131131
if processor.respond_to?(meth)
132132
processor.send(meth, *args)
@@ -144,14 +144,13 @@ def self.method_missing(meth, *args)
144144
end
145145
end
146146

147-
private
148147

149148
def self.run(meth, *args)
150149
backend = Specinfra.backend
151150
cmd = Specinfra.command.get(meth, *args)
152151
backend = Specinfra.backend
153152
ret = backend.run_command(cmd)
154-
if meth.to_s =~ /^check/
153+
if meth.to_s.start_with?('check')
155154
ret.success?
156155
else
157156
ret
@@ -189,7 +188,7 @@ def ssh_exec!(node, command)
189188
{
190189
:exit_status => r.exit_code,
191190
:stdout => r.stdout,
192-
:stderr => r.stderr
191+
:stderr => r.stderr,
193192
}
194193
end
195194

@@ -201,7 +200,7 @@ module Specinfra::Backend
201200
class BeakerDispatch < BeakerBase
202201

203202
def dispatch_method(meth, *args)
204-
if get_working_node['platform'] =~ /windows/
203+
if get_working_node['platform'].include?('windows')
205204
cygwin_backend.send(meth, *args)
206205
else
207206
exec_backend.send(meth, *args)
@@ -232,7 +231,7 @@ class BeakerCygwin < BeakerBase
232231
# @param [String] cmd The serverspec command to executed
233232
# @param [Hash] opt No currently supported options
234233
# @return [Hash] Returns a hash containing :exit_status, :stdout and :stderr
235-
def run_command(cmd, opt = {})
234+
def run_command(cmd, _opt = {})
236235
node = get_working_node
237236
script = create_script(cmd)
238237
#when node is not cygwin rm -rf will fail so lets use native del instead
@@ -269,7 +268,7 @@ class BeakerExec < BeakerBase
269268
# @param [String] cmd The serverspec command to executed
270269
# @param [Hash] opt No currently supported options
271270
# @return [Hash] Returns a hash containing :exit_status, :stdout and :stderr
272-
def run_command(cmd, opt = {})
271+
def run_command(cmd, _opt = {})
273272
node = get_working_node
274273
cmd = build_command(cmd)
275274
cmd = add_pre_command(cmd)

lib/beaker-rspec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
:debug => ENV['BEAKER_debug'] || ENV['RS_DEBUG'],
3333
:destroy => ENV['BEAKER_destroy'] || ENV['RS_DESTROY'],
3434
:optionsfile => ENV['BEAKER_options_file'] || ENV['RS_OPTIONS_FILE'],
35-
}.delete_if {|key, value| value.nil?}
35+
}.delete_if {|_key, value| value.nil?}
3636
#combine defaults and env_vars to determine overall options
3737
options = defaults.merge(env_vars)
3838

spec/acceptance/example_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
'ssh'
3939
end
4040
describe service(sshd), :node => node do
41-
it { should be_running }
41+
it { is_expected.to be_running }
4242
end
4343

4444
usr = case node['platform']
@@ -48,7 +48,7 @@
4848
'root'
4949
end
5050
describe user(usr), :node => node do
51-
it { should exist }
51+
it { is_expected.to exist }
5252
end
5353
end
5454
end
@@ -61,16 +61,16 @@
6161
'root'
6262
end
6363
describe user(usr) do
64-
it { should exist }
64+
it { is_expected.to exist }
6565
end
6666
end
6767

6868
context "serverspec: can match multiline file to multiline contents" do
6969
contents = "four = five\n[one]\ntwo = three"
7070
create_remote_file(default, "file_with_contents.txt", contents)
7171
describe file("file_with_contents.txt") do
72-
it { should be_file }
73-
it { should contain(contents) }
72+
it { is_expected.to be_file }
73+
it { is_expected.to contain(contents) }
7474
end
7575
end
7676
end

0 commit comments

Comments
 (0)