Skip to content

Commit

Permalink
Apply perlcritic rule for useless interpolation of literal string
Browse files Browse the repository at this point in the history
This is propably the biggest load of files which should adapt to
the rule which force single quotes when string doesnt need
interpolation.
Includes also some minor changes for *Hash key with quotes* but
not all of them.
https://progress.opensuse.org/issues/138416

Signed-off-by: ybonatakis <ybonatakis@suse.com>
  • Loading branch information
b10n1k authored and okurz committed Feb 2, 2024
1 parent 9b485b9 commit 52eb046
Show file tree
Hide file tree
Showing 80 changed files with 277 additions and 277 deletions.
4 changes: 2 additions & 2 deletions lib/OpenQA/BuildResults.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sub count_job ($job, $jr, $labels) {
return;
}
my $state = $job->state;
log_error("Encountered not-implemented state:" . $job->state . " result:" . $job->result)
log_error('Encountered not-implemented state:' . $job->state . ' result:' . $job->result)
unless grep { /$state/ } (OpenQA::Jobs::Constants::PENDING_STATES);
$jr->{unfinished}++;
return;
Expand Down Expand Up @@ -206,7 +206,7 @@ sub compute_build_results ($group, $limit, $time_limit_days, $tags, $subgroup_fi

my %seen;
my @jobs = map {
my $key = $_->TEST . "-" . $_->ARCH . "-" . $_->FLAVOR . "-" . ($_->MACHINE // '');
my $key = $_->TEST . '-' . $_->ARCH . '-' . $_->FLAVOR . '-' . ($_->MACHINE // '');
$seen{$key}++ ? () : $_;
} $jobs->all;
my $comment_data = $group->result_source->schema->resultset('Comments')->comment_data_for_jobs(\@jobs);
Expand Down
4 changes: 2 additions & 2 deletions lib/OpenQA/CacheService/Model/Cache.pm
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ sub track_asset ($self, $asset) {
my $db = $self->sqlite->db;
my $tx = $db->begin('exclusive');
my $sql = "INSERT INTO assets (filename, size, last_use) VALUES (?, 0, strftime('%s','now'))"
. "ON CONFLICT (filename) DO UPDATE SET pending=1";
. 'ON CONFLICT (filename) DO UPDATE SET pending=1';
$db->query($sql, $asset);
$tx->commit;
};
if (my $err = $@) { $self->log->error("Tracking asset failed: $err") }
}

sub metrics ($self) {
return {map { $_->{name} => $_->{value} } $self->sqlite->db->query("SELECT * FROM metrics")->hashes->each};
return {map { $_->{name} => $_->{value} } $self->sqlite->db->query('SELECT * FROM metrics')->hashes->each};
}

sub _exclusive_query ($self, $sql, @args) {
Expand Down
2 changes: 1 addition & 1 deletion lib/OpenQA/CacheService/Task/Sync.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sub _cache_tests ($job, $from = undef, $to = undef) {
my $cmd = join ' ', @cmd;
$ctx->info("Calling: $cmd");
my $status;
my $full_output = "";
my $full_output = '';
for my $retry (1 .. RSYNC_RETRIES) {
my $output = `@cmd`;
$status = $? >> 8;
Expand Down
4 changes: 2 additions & 2 deletions lib/OpenQA/Client/Archive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sub run ($self, $options) {
my $code = $res->code;
die "There's an error openQA client returned $code" unless $code eq 200;

my $job = $res->json->{job} || die("No job could be retrieved");
my $job = $res->json->{job} || die('No job could be retrieved');

# We have a job now, make a directory in $pwd by default
my $path = path($options->{archive})->make_path;
Expand Down Expand Up @@ -193,7 +193,7 @@ sub _progress_monitior ($ua, $tx) {
$last_updated = time;
if ($progress < $current) {
$progress = $current;
print("\rDownloading $filename: ", $size == $len ? 100 : $progress . "%");
print("\rDownloading $filename: ", $size == $len ? 100 : $progress . '%');
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/OpenQA/Downloader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sub download ($self, $url, $target, $options = {}) {
last;
}

return $err ? $err : "No error message recorded";
return $err ? $err : 'No error message recorded';
}

sub _extract_asset ($self, $to_extract, $target) {
Expand Down Expand Up @@ -88,7 +88,7 @@ sub _get ($self, $url, $target, $options) {
my $code = $res->code // 521; # Used by cloudflare to indicate web server is down.
if ($code eq 304) {
$options->{on_unchanged}->() if $options->{on_unchanged};
return (520, "Unknown error") unless -e $target; # Avoid race condition between check and removal
return (520, 'Unknown error') unless -e $target; # Avoid race condition between check and removal
return (undef, undef);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/OpenQA/Files.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ sub verify_chunks ($class, $chunk_path, $verify_file) {
$chunk->decode_content;
$sum = $chunk->total_cksum if !$sum;
return Mojo::Exception->new(
"Chunk: " . $chunk->id() . " differs in total checksum, expected $sum given " . $chunk->total_cksum)
'Chunk: ' . $chunk->id() . ' differs in total checksum, expected $sum given ' . $chunk->total_cksum)
if $sum ne $chunk->total_cksum;
return Mojo::Exception->new("Can't verify written data from chunk")
unless $chunk->verify_content($verify_file);
Expand Down
2 changes: 1 addition & 1 deletion lib/OpenQA/JobSettings.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sub generate_settings ($params) {
}

# Prevent the MACHINE from being overridden by input args when doing isos post
if (my $machine = $params->{'machine'}) {
if (my $machine = $params->{machine}) {
$settings->{BACKEND} = $machine->backend;
$settings->{MACHINE} = $machine->name;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/OpenQA/Log.pm
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ sub setup_log ($app, $logfile = undef, $logdir = undef, $level = undef) {
$logfile = catfile($logdir, $logfile) if $logfile && $logdir;
# So each worker from each host get its own log (as the folder can be shared).
# Hopefully the machine hostname is already sanitized. Otherwise we need to check
$logfile //= catfile($logdir, hostname() . (defined $app->instance ? "-${\$app->instance}" : '') . ".log");
$logfile //= catfile($logdir, hostname() . (defined $app->instance ? "-${\$app->instance}" : '') . '.log');
$log = Mojo::Log->new(%settings, handle => path($logfile)->open('>>'));
$log->format(\&log_format_callback);
}
Expand Down
14 changes: 7 additions & 7 deletions lib/OpenQA/Parser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ sub _build_parser {

sub load {
my ($self, $file) = @_;
croak "You need to specify a file" if !$file;
croak 'You need to specify a file' if !$file;
my $file_content = $self->_read_file($file);
confess "Failed reading file $file" if !$file_content;
$self->content($file_content) if $self->include_content;
Expand Down Expand Up @@ -80,25 +80,25 @@ sub gen_tree_el {
if ($el->isa('OpenQA::Parser')) {
$el_ref = $el;
}
elsif ($el->can("gen_tree_el")) {
elsif ($el->can('gen_tree_el')) {
return $el->gen_tree_el;
}
elsif ($el->can("to_hash")) {
elsif ($el->can('to_hash')) {
$el_ref = $el->to_hash;
}
elsif ($el->can("to_array")) {
elsif ($el->can('to_array')) {
$el_ref = $el->to_array;
}
elsif (reftype $el eq 'ARRAY') {
warn "Serialization is officially supported only if object can be turned into an array with ->to_array()";
warn 'Serialization is officially supported only if object can be turned into an array with ->to_array()';
$el_ref = [@{$el}];
}
elsif (reftype $el eq 'HASH') {
warn "Serialization is officially supported only if object can be hashified with ->to_hash()";
warn 'Serialization is officially supported only if object can be hashified with ->to_hash()';
$el_ref = {%{$el}};
}
else {
warn "Data type with format not supported for serialization";
warn 'Data type with format not supported for serialization';
$el_ref = $el;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/OpenQA/Parser/Format/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ sub _write_all {

sub write_output {
my ($self, $dir) = @_;
croak "You need to specify a directory" unless $dir;
croak 'You need to specify a directory' unless $dir;
$self->_write_all(generated_tests_output => $dir);
}

sub write_test_result {
my ($self, $dir) = @_;
croak "You need to specify a directory" unless $dir;
croak 'You need to specify a directory' unless $dir;
$self->_write_all(generated_tests_results => $dir);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/OpenQA/Parser/Format/IPA.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sub _add_single_result { shift->results->add(OpenQA::Parser::Result::OpenQA->new
# Parser
sub parse {
my ($self, $json) = @_;
confess "No JSON given/loaded" unless $json;
confess 'No JSON given/loaded' unless $json;
my $decoded_json = Mojo::JSON::from_json($json);
my %unique_names;

Expand Down
6 changes: 3 additions & 3 deletions lib/OpenQA/Parser/Format/JUnit.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ sub _add_result {

sub parse {
my ($self, $xml) = @_;
confess "No XML given/loaded" unless $xml;
confess 'No XML given/loaded' unless $xml;
my $dom = Mojo::DOM->new($xml);
confess "Failed parsing XML" unless @{$dom->tree} > 2;
confess 'Failed parsing XML' unless @{$dom->tree} > 2;

my @tests;
for my $ts ($dom->find('testsuite')->each) {
Expand Down Expand Up @@ -103,7 +103,7 @@ sub parse {
$text_fn .= '.txt';
my $content = "# $tc->{name}\n";
for my $out ($tc->children('system-out, system-err, failure, error, skipped')->each) {
$content .= "# " . $out->tag . ": \n\n";
$content .= '# ' . $out->tag . ": \n\n";
$content .= $out->text . "\n";
}
$details->{text} = $text_fn;
Expand Down
2 changes: 1 addition & 1 deletion lib/OpenQA/Parser/Format/LTP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sub _add_single_result { shift->results->add(OpenQA::Parser::Result::LTP::Test->
# Parser
sub parse {
my ($self, $json) = @_;
confess "No JSON given/loaded" unless $json;
confess 'No JSON given/loaded' unless $json;
my $decoded_json = Mojo::JSON::from_json($json);

# may be optional since format result_array:v2
Expand Down
6 changes: 3 additions & 3 deletions lib/OpenQA/Parser/Format/TAP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ has [qw(test steps)];

sub parse {
my ($self, $TAP) = @_;
confess "No TAP given/loaded" unless $TAP;
confess 'No TAP given/loaded' unless $TAP;
my $tap = TAP::Parser->new({tap => $TAP});
confess "Failed " . $tap->parse_errors if $tap->parse_errors;
confess 'Failed ' . $tap->parse_errors if $tap->parse_errors;
my $test = {
flags => {},
category => "TAP",
category => 'TAP',
name => 'Extra test from TAP',
};
my $details;
Expand Down
6 changes: 3 additions & 3 deletions lib/OpenQA/Parser/Format/XUnit.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sub addproperty { shift->{properties}->add(OpenQA::Parser::Result::XUnit::Proper

sub parse {
my ($self, $xml) = @_;
confess "No XML given/loaded" unless $xml;
confess 'No XML given/loaded' unless $xml;
my $dom = Mojo::DOM->new->xml(1)->parse($xml);

my @tests;
Expand Down Expand Up @@ -73,12 +73,12 @@ sub parse {
my $text_fn = "$ts_category-$ts_name-$num";
$text_fn =~ s/[\/.]/_/g;
$text_fn .= '.txt';
my $content = "# Test messages ";
my $content = '# Test messages ';
$content .= "# $tc->{name}\n" if $tc->{name};

for my $out ($tc->children('skipped, passed, error, failure')->each) {
$tc_result = 'fail' if ($out->tag =~ m/failure|error/);
$content .= "# " . $out->tag . ": \n\n";
$content .= '# ' . $out->tag . ": \n\n";
$content .= $out->{message} . "\n" if $out->{message};
$content .= $out->text . "\n";
}
Expand Down
4 changes: 2 additions & 2 deletions lib/OpenQA/Scheduler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ sub setup ($self) {
# initial schedule
Mojo::IOLoop->next_tick(
sub {
log_debug("Scheduler default interval(ms): " . SCHEDULE_TICK_MS);
log_debug("Max job allocation: " . OpenQA::Scheduler::Model::Jobs::MAX_JOB_ALLOCATION());
log_debug('Scheduler default interval(ms): ' . SCHEDULE_TICK_MS);
log_debug('Max job allocation: ' . OpenQA::Scheduler::Model::Jobs::MAX_JOB_ALLOCATION());
OpenQA::Scheduler::Model::Jobs->singleton->schedule;
_reschedule();
});
Expand Down
16 changes: 8 additions & 8 deletions lib/OpenQA/Scheduler/Model/Jobs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sub _allocate_jobs ($self, $free_workers) {
my @rejected = sort { $rejected{$b} <=> $rejected{$a} || $a cmp $b } keys %rejected;
splice @rejected, MAX_REPORT_MISSING_WORKER_CLASSES;
my $stats = join ',', map { "$_:$rejected{$_}" } @rejected;
my $info = sprintf "Skipping %d jobs because of no free workers for requested worker classes (%s)",
my $info = sprintf 'Skipping %d jobs because of no free workers for requested worker classes (%s)',
sum(values %rejected), $stats;
log_debug($info);
}
Expand Down Expand Up @@ -133,7 +133,7 @@ sub _allocate_jobs ($self, $free_workers) {
my $busy = keys %$allocated_workers;
if ($busy >= $max_allocate || $busy >= @$free_workers) {
my $free_worker_count = @$free_workers;
log_debug("limit reached, scheduling no additional jobs"
log_debug('limit reached, scheduling no additional jobs'
. " (max_running_jobs=$limit, free workers=$free_worker_count, running=$running, allocated=$busy)");
last;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ sub schedule ($self) {
};
next unless $worker;
if ($worker->unfinished_jobs->count) {
log_debug "Worker already got jobs, skipping";
log_debug 'Worker already got jobs, skipping';
next;
}

Expand Down Expand Up @@ -268,7 +268,7 @@ sub schedule ($self) {
});
$res = $jobs[0]->ws_send($worker);
}
die "Failed contacting websocket server over HTTP" unless ref($res) eq "HASH" && exists $res->{state};
die 'Failed contacting websocket server over HTTP' unless ref($res) eq 'HASH' && exists $res->{state};
}
catch {
log_warning "Failed to send data to websocket server, reason: $_";
Expand Down Expand Up @@ -305,10 +305,10 @@ sub schedule ($self) {
}
}

my $elapsed_rounded = sprintf("%.5f", (time - $start_time));
my $elapsed_rounded = sprintf('%.5f', (time - $start_time));
log_debug "Scheduler took ${elapsed_rounded}s to perform operations and allocated "
. scalar(@successfully_allocated) . " jobs";
log_debug "Allocated: " . pp($_) for @successfully_allocated;
. scalar(@successfully_allocated) . ' jobs';
log_debug 'Allocated: ' . pp($_) for @successfully_allocated;
$self->emit('conclude');

return (\@successfully_allocated);
Expand Down Expand Up @@ -439,7 +439,7 @@ sub _update_scheduled_jobs ($self) {
}
# fetch worker classes
my $settings
= $schema->resultset("JobSettings")->search({key => 'WORKER_CLASS', job_id => {-in => \@missing_worker_class}});
= $schema->resultset('JobSettings')->search({key => 'WORKER_CLASS', job_id => {-in => \@missing_worker_class}});
while (my $line = $settings->next) {
push(@{$scheduled_jobs->{$line->job_id}->{worker_classes}}, $line->value);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/OpenQA/Schema/Profiler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sub query_end {
my ($self, $sql, @params) = @_;
$sql = "$sql: " . join(', ', @params) if @params;
my $elapsed = tv_interval($self->{start}, [gettimeofday()]);
log_debug(sprintf("[DBIC] Took %.8f seconds: %s", $elapsed, $sql));
log_debug(sprintf('[DBIC] Took %.8f seconds: %s', $elapsed, $sql));
}

# We need to override print because DBIx::Class::Storage::Statistics::print()
Expand All @@ -25,7 +25,7 @@ sub print {
my ($self, $msg) = @_;
chomp $msg;

log_debug(sprintf("[DBIC] %s", $msg));
log_debug(sprintf('[DBIC] %s', $msg));
}

sub enable_sql_debugging {
Expand Down
40 changes: 20 additions & 20 deletions lib/OpenQA/Schema/Result/Comments.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,38 @@ __PACKAGE__->set_primary_key('id');
__PACKAGE__->belongs_to(user => 'OpenQA::Schema::Result::Users', 'user_id');

__PACKAGE__->belongs_to(
"group",
"OpenQA::Schema::Result::JobGroups",
{'foreign.id' => "self.group_id"},
'group',
'OpenQA::Schema::Result::JobGroups',
{'foreign.id' => 'self.group_id'},
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
join_type => 'LEFT',
on_delete => 'CASCADE',
on_update => 'CASCADE',
},
);

__PACKAGE__->belongs_to(
"parent_group",
"OpenQA::Schema::Result::JobGroupParents",
{'foreign.id' => "self.parent_group_id"},
'parent_group',
'OpenQA::Schema::Result::JobGroupParents',
{'foreign.id' => 'self.parent_group_id'},
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
join_type => 'LEFT',
on_delete => 'CASCADE',
on_update => 'CASCADE',
},
);

__PACKAGE__->belongs_to(
"job",
"OpenQA::Schema::Result::Jobs",
{'foreign.id' => "self.job_id"},
'job',
'OpenQA::Schema::Result::Jobs',
{'foreign.id' => 'self.job_id'},
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
join_type => 'LEFT',
on_delete => 'CASCADE',
on_update => 'CASCADE',
},
);

Expand Down Expand Up @@ -175,8 +175,8 @@ sub extended_hash ($self, $render_markdown = 1) {
text => $self->text,
renderedMarkdown => ($render_markdown) ? $self->rendered_markdown->to_string : undef,
bugrefs => $self->bugrefs,
created => $self->t_created->strftime("%Y-%m-%d %H:%M:%S %z"),
updated => $self->t_updated->strftime("%Y-%m-%d %H:%M:%S %z"),
created => $self->t_created->strftime('%Y-%m-%d %H:%M:%S %z'),
updated => $self->t_updated->strftime('%Y-%m-%d %H:%M:%S %z'),
userName => $self->user->name
};
}
Expand Down

0 comments on commit 52eb046

Please sign in to comment.