Skip to content

Commit 58fd26f

Browse files
committed
(maint) Restore rubocop line length
1 parent 7a05c01 commit 58fd26f

File tree

7 files changed

+37
-23
lines changed

7 files changed

+37
-23
lines changed

.rubocop.yml

-3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,3 @@ Metrics/ParameterLists:
5959

6060
Metrics/PerceivedComplexity:
6161
Enabled: false
62-
63-
Metrics/LineLength:
64-
Max: 130

lib/bolt/cli.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def create_option_parser(results)
119119
end
120120
results[:concurrency] = 100
121121
opts.on('-c', '--concurrency CONCURRENCY', Integer,
122-
"Maximum number of simultaneous connections (Optional, defaults to 100)") do |concurrency|
122+
"Maximum number of simultaneous connections " \
123+
"(Optional, defaults to 100)") do |concurrency|
123124
results[:concurrency] = concurrency
124125
end
125126
opts.on('--modules MODULES', "Path to modules directory") do |modules|

lib/bolt/node/orch.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ def unwrap_bolt_result(result)
8484
end
8585

8686
def _run_command(command, options = {})
87-
result = _run_task(BOLT_MOCK_FILE, 'stdin', action: 'command', command: command, options: options)
87+
result = _run_task(BOLT_MOCK_FILE,
88+
'stdin',
89+
action: 'command',
90+
command: command,
91+
options: options)
8892
unwrap_bolt_result(result)
8993
end
9094

lib/bolt/node/winrm.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ def execute(command, _ = {})
117117
# 10 minutes in milliseconds
118118
DEFAULT_EXECUTION_TIMEOUT = 10 * 60 * 1000
119119

120-
def execute_process(path = '', arguments = '', stdin = nil, timeout_ms = DEFAULT_EXECUTION_TIMEOUT)
120+
def execute_process(path = '', arguments = '', stdin = nil,
121+
timeout_ms = DEFAULT_EXECUTION_TIMEOUT)
121122
execute(<<-PS)
122123
$invokeArgs = @{
123124
Path = "#{path}"
@@ -133,6 +134,9 @@ def execute_process(path = '', arguments = '', stdin = nil, timeout_ms = DEFAULT
133134

134135
VALID_EXTENSIONS = ['.ps1', '.rb'].freeze
135136

137+
PS_ARGS =
138+
'-NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass'.freeze
139+
136140
def process_from_extension(path)
137141
case Pathname(path).extname.downcase
138142
when '.rb'
@@ -143,7 +147,7 @@ def process_from_extension(path)
143147
when '.ps1'
144148
[
145149
'powershell.exe',
146-
"-NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File \"#{path}\""
150+
"#{PS_ARGS} -File \"#{path}\""
147151
]
148152
end
149153
end
@@ -201,7 +205,7 @@ def _run_command(command)
201205
def _run_script(script)
202206
@logger.info { "Running script '#{script}'" }
203207
with_remote_file(script) do |remote_path|
204-
args = "-NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File \"#{remote_path}\""
208+
args = "#{PS_ARGS} -File \"#{remote_path}\""
205209
execute_process('powershell.exe', args)
206210
end
207211
end

spec/bolt/cli_spec.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@
117117
cli = Bolt::CLI.new(%w[command run --nodes foo --concurrency])
118118
expect {
119119
cli.parse
120-
}.to raise_error(Bolt::CLIError, /option '--concurrency' needs a parameter/)
120+
}.to raise_error(Bolt::CLIError,
121+
/option '--concurrency' needs a parameter/)
121122
end
122123
end
123124

spec/bolt/node/orch_spec.rb

+17-13
Original file line numberDiff line numberDiff line change
@@ -100,32 +100,35 @@ def set_script_params(path, _options = {})
100100
end
101101

102102
it 'errors when not in a module' do
103-
expect { orch.task_name_from_path('foo/nottasks/init.sh') }.to raise_error(ArgumentError)
103+
expect { orch.task_name_from_path('foo/nottasks/init.sh') }
104+
.to raise_error(ArgumentError)
104105
end
105106
end
106107

107108
describe :_run_task do
108109
it "executes a task on a host" do
109110
mock_client
110-
expect(orch._run_task(@taskpath, 'stdin', @params).value).to eq(@result.to_json)
111+
expect(orch._run_task(@taskpath, 'stdin', @params).value)
112+
.to eq(@result.to_json)
111113
end
112114

113115
it "returns a success" do
114116
mock_client
115-
expect(orch._run_task(@taskpath, 'stdin', @params).class).to eq(Bolt::Node::Success)
117+
expect(orch._run_task(@taskpath, 'stdin', @params)).to be_success
116118
end
117119

118120
context "the task failed" do
119121
before(:each) { @result_state = 'failed' }
120122

121123
it "returns a failure for failed" do
122124
mock_client
123-
expect(orch._run_task(@taskpath, 'stdin', @params).class).to eq(Bolt::Node::Failure)
125+
expect(orch._run_task(@taskpath, 'stdin', @params)).not_to be_success
124126
end
125127

126128
it "adds an unkown exitcode when absent" do
127129
mock_client
128-
expect(orch._run_task(@taskpath, 'stdin', @params).exit_code).to eq('unknown')
130+
expect(orch._run_task(@taskpath, 'stdin', @params).exit_code)
131+
.to eq('unknown')
129132
end
130133

131134
it "uses the exitcode when present" do
@@ -149,7 +152,7 @@ def set_script_params(path, _options = {})
149152
end
150153

151154
it 'it is a success' do
152-
expect(orch._run_command(@command).class).to eq(Bolt::Node::Success)
155+
expect(orch._run_command(@command)).to be_success
153156
end
154157

155158
it 'captures stderr' do
@@ -166,7 +169,7 @@ def set_script_params(path, _options = {})
166169
bolt_task_client
167170
end
168171
it 'is a failure' do
169-
expect(orch._run_command(@command).class).to eq(Bolt::Node::Failure)
172+
expect(orch._run_command(@command)).not_to be_success
170173
end
171174

172175
it 'captures the exit_code' do
@@ -190,14 +193,15 @@ def set_script_params(path, _options = {})
190193
describe :_upload do
191194
it 'should write the file' do
192195
Dir.mktmpdir(nil, '/tmp') do |dir|
193-
source_path = File.join(base_path, 'spec', 'fixtures', 'scripts', 'success.sh')
196+
source_path = File.join(base_path, 'spec', 'fixtures',
197+
'scripts', 'success.sh')
194198
dest_path = File.join(dir, "success.sh")
195199

196200
set_upload_params(source_path, dest_path)
197201
bolt_task_client
198202
result = orch._upload(source_path, dest_path)
199203

200-
expect(result.class).to eq(Bolt::Node::Success)
204+
expect(result).to be_success
201205

202206
source_mode = File.stat(source_path).mode
203207
dest_mode = File.stat(dest_path).mode
@@ -213,7 +217,7 @@ def set_script_params(path, _options = {})
213217
describe :_run_script do
214218
context "the script succeeds" do
215219
let(:script_path) do
216-
File.expand_path(File.join(base_path, 'spec', 'fixtures', 'scripts', 'success.sh'))
220+
File.join(base_path, 'spec', 'fixtures', 'scripts', 'success.sh')
217221
end
218222

219223
before(:each) do
@@ -222,7 +226,7 @@ def set_script_params(path, _options = {})
222226
end
223227

224228
it 'is a success' do
225-
expect(orch._run_script(script_path).class).to eq(Bolt::Node::Success)
229+
expect(orch._run_script(script_path)).to be_success
226230
end
227231

228232
it 'captures stdout' do
@@ -238,7 +242,7 @@ def set_script_params(path, _options = {})
238242

239243
context "when the script fails" do
240244
let(:script_path) do
241-
File.expand_path(File.join(base_path, 'spec', 'fixtures', 'scripts', 'failure.sh'))
245+
File.join(base_path, 'spec', 'fixtures', 'scripts', 'failure.sh')
242246
end
243247

244248
before(:each) do
@@ -247,7 +251,7 @@ def set_script_params(path, _options = {})
247251
end
248252

249253
it 'returns a failure' do
250-
expect(orch._run_script(script_path).class).to eq(Bolt::Node::Failure)
254+
expect(orch._run_script(script_path)).not_to be_success
251255
end
252256

253257
it 'captures exit_code' do

spec/bolt/node/winrm_spec.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@
7373
with_tempfile_containing('tasks-test-both-winrm', contents) do |file|
7474
expect(
7575
winrm._run_task(file.path, 'both', arguments).value
76-
).to eq("Hello from task\r\nGoodbye\r\n{\"message_one\":\"Hello from task\",\"message_two\":\"Goodbye\"}\r\n\r\n")
76+
).to eq(['Hello from task',
77+
'Goodbye',
78+
'{"message_one":"Hello from task","message_two":"Goodbye"}',
79+
"\r\n"].join("\r\n"))
7780
end
7881
end
7982
end

0 commit comments

Comments
 (0)