Skip to content

Commit 5546703

Browse files
committed
experiment: Unify perl linting rules
Testing the perltidy config from os-autoinst/os-autoinst-common#30
1 parent 64b339c commit 5546703

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1757
-1182
lines changed

.perltidyrc

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
# # See <https://github.com/houseabsolute/perl-code-tidyall/issues/84>.
33
--character-encoding=none
44
--no-valign
5-
# 120 characters would be desired but it is not feasible right now
6-
#-l=120 # 120 characters per line
5+
6+
# TBD: openqa defines: -l=120 vs -l=160 in os-autoinst-distri-opensuse
7+
# taking the most relaxed for now.
8+
79
-l=160
810
-fbl # don't change blank lines
9-
-fnl # don't remove new lines
1011
-nsfs # no spaces before semicolons
1112
-baao # space after operators
1213
-bbao # space before operators

OpenQA/Commands.pm

+7-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ sub start_ws ($self) {
4545
message => sub ($self, $msg) {
4646
$self->pass_message_from_ws_client_to_isotovideo($id, $msg);
4747
});
48-
$self->on(finish => sub {
48+
$self->on(
49+
finish => sub {
4950
$self->handle_ws_client_disconnects($id);
50-
});
51+
});
5152
}
5253

5354
sub broadcast_message_to_websocket_clients ($self) {
@@ -70,10 +71,12 @@ sub broadcast_message_to_websocket_clients ($self) {
7071
return $self->render(json => {status => 'boradcast done'}) unless $outstanding_transactions;
7172

7273
for (keys %$clients) {
73-
$clients->{$_}->send({json => $message}, sub {
74+
$clients->{$_}->send(
75+
{json => $message},
76+
sub {
7477
return undef if (($outstanding_transactions -= 1) > 0);
7578
return $self->render(json => {status => 'boradcast done'});
76-
});
79+
});
7780
}
7881

7982
return $self;

OpenQA/Isotovideo/CommandHandler.pm

+33-22
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,11 @@ sub _pass_command_to_backend_unless_paused ($self, $response, $backend_cmd) {
139139
die 'isotovideo: we need to implement a backend queue' if $self->backend_requester;
140140
$self->backend_requester($self->answer_fd);
141141

142-
$self->_send_to_cmd_srv({
142+
$self->_send_to_cmd_srv(
143+
{
143144
$backend_cmd => $response,
144145
current_api_function => $backend_cmd,
145-
});
146+
});
146147
$self->_send_to_backend({cmd => $backend_cmd, arguments => $response});
147148
$self->current_api_function($backend_cmd);
148149
}
@@ -173,9 +174,9 @@ sub _handle_command_report_timeout ($self, $response, @) {
173174
}
174175

175176
sub _handle_command_is_configured_to_pause_on_timeout ($self, $response, @) {
176-
$self->_respond({
177-
ret => ($self->_is_configured_to_pause_on_timeout($response) ? 1 : 0)
178-
});
177+
$self->_respond(
178+
{
179+
ret => ($self->_is_configured_to_pause_on_timeout($response) ? 1 : 0)});
179180
}
180181

181182
sub _handle_command_set_pause_at_test ($self, $response, @) {
@@ -225,8 +226,9 @@ sub _handle_command_resume_test_execution ($self, $response, @) {
225226
my $postponed_command = $self->postponed_command;
226227
my $postponed_answer_fd = $self->postponed_answer_fd;
227228

228-
diag($self->reason_for_pause ?
229-
'isotovideo: test execution will be resumed'
229+
diag(
230+
$self->reason_for_pause
231+
? 'isotovideo: test execution will be resumed'
230232
: 'isotovideo: resuming test execution requested but not paused anyways'
231233
);
232234
$self->_send_to_cmd_srv({resume_test_execution => $postponed_command});
@@ -245,10 +247,12 @@ sub _handle_command_resume_test_execution ($self, $response, @) {
245247

246248
# if no command has been postponed (because paused due to timeout or on set_current_test) just return 1
247249
if (!$postponed_command) {
248-
myjsonrpc::send_json($postponed_answer_fd, {
250+
myjsonrpc::send_json(
251+
$postponed_answer_fd,
252+
{
249253
ret => ($response->{options} // 1),
250254
new_needles => $response->{new_needles},
251-
});
255+
});
252256
$self->postponed_answer_fd(undef);
253257
return;
254258
}
@@ -271,12 +275,13 @@ sub _handle_command_set_current_test ($self, $response, @) {
271275
$self->current_test_name($test_name);
272276
$self->status('running');
273277
$self->current_test_full_name($full_test_name);
274-
$self->_send_to_cmd_srv({
278+
$self->_send_to_cmd_srv(
279+
{
275280
set_current_test => $test_name,
276281
current_test_full_name => $full_test_name,
277-
});
282+
});
278283

279-
if ($pause_test_name
284+
if ( $pause_test_name
280285
&& $test_name
281286
&& $full_test_name
282287
&& ($pause_test_name eq $test_name || $pause_test_name eq $full_test_name))
@@ -307,30 +312,35 @@ sub _handle_command_check_screen ($self, $response, @) {
307312
check => $response->{check},
308313
);
309314
my $current_api_function = $response->{check} ? 'check_screen' : 'assert_screen';
310-
$self->_send_to_cmd_srv({
315+
$self->_send_to_cmd_srv(
316+
{
311317
check_screen => \%arguments,
312318
current_api_function => $current_api_function,
313-
});
314-
$self->tags($bmwqemu::backend->_send_json(
319+
});
320+
$self->tags(
321+
$bmwqemu::backend->_send_json(
315322
{
316323
cmd => 'set_tags_to_assert',
317324
arguments => \%arguments,
318-
})->{tags});
325+
}
326+
)->{tags});
319327
$self->current_api_function($current_api_function);
320328
}
321329

322330
sub _handle_command_set_assert_screen_timeout ($self, $response, @) {
323331
my $timeout = $response->{timeout};
324332
$self->_send_to_cmd_srv({set_assert_screen_timeout => $timeout});
325-
$bmwqemu::backend->_send_json({
333+
$bmwqemu::backend->_send_json(
334+
{
326335
cmd => 'set_assert_screen_timeout',
327336
arguments => $timeout,
328-
});
337+
});
329338
$self->_respond_ok();
330339
}
331340

332341
sub _handle_command_status ($self, $response, @) {
333-
$self->_respond({
342+
$self->_respond(
343+
{
334344
tags => $self->tags,
335345
running => $self->current_test_name,
336346
current_test_full_name => $self->current_test_full_name,
@@ -342,15 +352,16 @@ sub _handle_command_status ($self, $response, @) {
342352
test_execution_paused => $self->reason_for_pause,
343353
devel_mode_major_version => $OpenQA::Isotovideo::Interface::developer_mode_major_version,
344354
devel_mode_minor_version => $OpenQA::Isotovideo::Interface::developer_mode_minor_version,
345-
});
355+
});
346356
}
347357

348358
sub _handle_command_version ($self, $response, @) {
349-
$self->_respond({
359+
$self->_respond(
360+
{
350361
test_git_hash => $bmwqemu::vars{TEST_GIT_HASH},
351362
needles_git_hash => $bmwqemu::vars{NEEDLES_GIT_HASH},
352363
version => $OpenQA::Isotovideo::Interface::version,
353-
});
364+
});
354365
}
355366

356367
sub _handle_command_read_serial ($self, $response, @) {

OpenQA/Isotovideo/NeedleDownloader.pm

+6-3
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,19 @@ sub _add_download ($self, $needle, $extension, $path_param) {
6565
if (my $target_last_modified = $target_stat->[9] // $target_stat->[8]) {
6666
$target_last_modified = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime($target_last_modified));
6767
if ($target_last_modified ge $latest_update) {
68-
bmwqemu::diag("skipping downloading new needle: $download_target seems already up-to-date (last update: $target_last_modified > $latest_update)");
68+
bmwqemu::diag(
69+
"skipping downloading new needle: $download_target seems already up-to-date (last update: $target_last_modified > $latest_update)");
6970
return;
7071
}
7172
}
7273
}
7374

74-
push(@{$self->files_to_download}, {
75+
push(
76+
@{$self->files_to_download},
77+
{
7578
target => $download_target,
7679
url => Mojo::URL->new($self->openqa_url . $needle->{$path_param}),
77-
});
80+
});
7881
}
7982

8083
sub _download_file ($self, $download) {

OpenQA/Isotovideo/Runner.pm

+10-6
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ sub _read_response ($self, $rsp, $fd) {
5656
if (!defined $rsp) {
5757
fctwarn sprintf("THERE IS NOTHING TO READ %d %d %d", fileno($fd), fileno($self->testfd), fileno($self->cmd_srv_fd));
5858
$self->loop(0);
59-
} elsif ($fd == $self->command_handler->backend_out_fd) {
59+
}
60+
elsif ($fd == $self->command_handler->backend_out_fd) {
6061
$self->command_handler->send_to_backend_requester({ret => $rsp->{rsp}});
61-
} else {
62+
}
63+
else {
6264
$self->command_handler->process_command($fd, $rsp);
6365
}
6466
}
@@ -115,22 +117,24 @@ sub handle_commands ($self) {
115117
backend_fd => $self->backend->process->channel_in,
116118
backend_out_fd => $self->backend->process->channel_out,
117119
);
118-
$command_handler->on(tests_done => sub (@) {
120+
$command_handler->on(
121+
tests_done => sub (@) {
119122
CORE::close($self->testfd);
120123
$self->testfd(undef);
121124
$self->stop_autotest();
122125
$self->loop(0);
123-
});
126+
});
124127
# uncoverable statement count:1
125128
# uncoverable statement count:2
126129
# uncoverable statement count:3
127130
# uncoverable statement count:4
128-
$command_handler->on(signal => sub ($event, $sig) {
131+
$command_handler->on(
132+
signal => sub ($event, $sig) {
129133
$self->backend->stop if defined $self->backend; # uncoverable statement
130134
$self->stop_commands("received signal $sig"); # uncoverable statement
131135
$self->stop_autotest(); # uncoverable statement
132136
_exit(1); # uncoverable statement
133-
});
137+
});
134138
$self->setup_signal_handler;
135139

136140
$self->command_handler($command_handler);

OpenQA/Isotovideo/Utils.pm

+11-3
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,21 @@ sub handle_generated_assets ($command_handler, $clean_shutdown) {
214214
push @toextract, _store_asset($i, $name, $dir);
215215
}
216216
if ($bmwqemu::vars{UEFI} && $bmwqemu::vars{PUBLISH_PFLASH_VARS}) {
217-
push(@toextract, {pflash_vars => 1,
217+
push(
218+
@toextract,
219+
{
220+
pflash_vars => 1,
218221
name => $bmwqemu::vars{PUBLISH_PFLASH_VARS},
219222
dir => 'assets_public',
220-
format => 'qcow2'});
223+
format => 'qcow2'
224+
});
221225
}
222226
if (@toextract && !$clean_shutdown) {
223-
bmwqemu::serialize_state(component => 'isotovideo', msg => 'unable to handle generated assets: machine not shut down when uploading disks', error => 1);
227+
bmwqemu::serialize_state(
228+
component => 'isotovideo',
229+
msg => 'unable to handle generated assets: machine not shut down when uploading disks',
230+
error => 1
231+
);
224232
return 1;
225233
}
226234
}

OpenQA/Qemu/BlockDev.pm

+14-20
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,15 @@ sub gen_cmdline ($self) {
119119
# The first blockdev defines the data store, we only use files, but in
120120
# theory it could be a http address, ISCSI or a link to an object store
121121
# item (like Ceph).
122-
push(@cmdl, ('-blockdev',
123-
join(',', ('driver=file',
124-
'node-name=' . $self->node_name . FILE_POSTFIX,
125-
'filename=' . $self->file,
126-
'cache.no-flush=on'))));
122+
push(@cmdl, ('-blockdev', join(',', ('driver=file', 'node-name=' . $self->node_name . FILE_POSTFIX, 'filename=' . $self->file, 'cache.no-flush=on'))));
127123
# The second blockdev tells QEMU what format we are using i.e. qcow2.
128-
push(@cmdl, ('-blockdev',
129-
join(',', ('driver=' . $self->driver,
130-
'node-name=' . $self->node_name,
131-
'file=' . $self->node_name . FILE_POSTFIX,
132-
'cache.no-flush=on',
133-
'discard=unmap'))));
124+
push(
125+
@cmdl,
126+
(
127+
'-blockdev',
128+
join(',',
129+
('driver=' . $self->driver, 'node-name=' . $self->node_name, 'file=' . $self->node_name . FILE_POSTFIX, 'cache.no-flush=on', 'discard=unmap')))
130+
);
134131

135132
return @cmdl;
136133
}
@@ -171,13 +168,15 @@ sub gen_unlink_list ($self) {
171168
}
172169

173170
sub _to_map ($self) {
174-
return {driver => $self->driver,
171+
return {
172+
driver => $self->driver,
175173
file => $self->file,
176174
node_name => $self->node_name,
177175
size => $self->size,
178176
needs_creating => $self->needs_creating,
179177
implicit => $self->implicit,
180-
snapshot => $self->snapshot->sequence};
178+
snapshot => $self->snapshot->sequence
179+
};
181180
}
182181

183182
sub _from_map ($self, $drives, $snap_conf) {
@@ -186,13 +185,8 @@ sub _from_map ($self, $drives, $snap_conf) {
186185
$self->backing_file(OpenQA::Qemu::BlockDev->new()->_from_map(\@rest, $snap_conf))
187186
if @rest > 0;
188187

189-
return $self->driver($this->{driver})
190-
->file($this->{file})
191-
->node_name($this->{node_name})
192-
->size($this->{size})
193-
->needs_creating($this->{needs_creating})
194-
->implicit($this->{implicit})
195-
->snapshot($snap_conf->get_snapshot(sequence => $this->{snapshot}));
188+
return $self->driver($this->{driver})->file($this->{file})->node_name($this->{node_name})->size($this->{size})->needs_creating($this->{needs_creating})
189+
->implicit($this->{implicit})->snapshot($snap_conf->get_snapshot(sequence => $this->{snapshot}));
196190
}
197191

198192
sub deduce_driver ($self) { $self->driver($self->file =~ qr/\.(qcow2|vmdk)/ ? "$1" : 'raw') }

0 commit comments

Comments
 (0)