Commit 396cfaef authored by Francesc Guasch's avatar Francesc Guasch
Browse files

[#168] Fixed critic suggestions

- Conditional declaring
- Strict
- Loop vars

No big deal anyway
parent 722ab373
......@@ -339,7 +339,7 @@ sub create_domain {
my $vm_name = $args{vm};
delete $args{vm};
my $request = $args{request} if $args{request};
my $request = ( $args{request} or undef);
my $vm;
if ($vm_name) {
......@@ -805,7 +805,7 @@ sub list_vm_types {
my ($name) = ref($vm) =~ /.*::(.*)/;
$type{$name}++;
}
return sort keys %type;
return keys %type;
}
sub _execute {
......
......@@ -135,7 +135,8 @@ sub _vol_remove {
my $file = shift;
my $warning = shift;
my ($name) = $file =~ m{.*/(.*)} if $file =~ m{/};
my $name;
($name) = $file =~ m{.*/(.*)} if $file =~ m{/};
#TODO: do a remove_volume in the VM
my @vols = $self->_vm->storage_pool->list_volumes();
......
......@@ -297,7 +297,8 @@ sub disk_device {
sub list_volumes {
my $self = shift;
my $data = LoadFile($self->_config_file) if -e $self->_config_file;
my $data;
$data = LoadFile($self->_config_file) if -e $self->_config_file;
return () if !exists $data->{device};
my @vol;
......@@ -310,13 +311,15 @@ sub list_volumes {
}
sub list_volumes_target {
my $self = shift;
my $data = LoadFile($self->_config_file) if -e $self->_config_file;
my $self = shift;
my $data;
$data = LoadFile($self->_config_file) if -e $self->_config_file;
return () if !exists $data->{device};
my @vol;
for my $dev (keys %{$data->{device}}) {
my $vol = ($data->{device}->{$dev}->{path})
my $vol;
$vol = ($data->{device}->{$dev}->{path})
if ! exists $data->{device}->{$dev}->{type}
|| $data->{device}->{$dev}->{type} ne 'base';
next if !$vol;
......
......@@ -556,7 +556,8 @@ sub list_requests {
$sth->bind_columns(\($id, $command, $j_args, $date_changed, $status, $error));
while ( $sth->fetch) {
my $args = decode_json($j_args) if $j_args;
my $args;
$args = decode_json($j_args) if $j_args;
push @reqs,{ id => $id, command => $command, date_changed => $date_changed, status => $status, error => $error , name => $args->{name}};
}
......
package Ravada::I18N;
use warnings;
use strict;
use base 'Locale::Maketext';
use File::Basename qw/dirname/;
use Locale::Maketext::Lexicon {
......
......@@ -114,8 +114,8 @@ sub open {
confess "I can't find id=$id " if !defined $row;
$sth->finish;
my $args = decode_json($row->{args}) if $row->{args};
$args = {} if !$args;
my $args = {};
$args = decode_json($row->{args}) if $row->{args};
$row->{args} = $args;
......
......@@ -434,7 +434,8 @@ sub _domain_create_from_iso {
my $device_cdrom = $self->_iso_name($iso, $args{request});
my $disk_size = $args{disk} if $args{disk};
my $disk_size;
$disk_size = $args{disk} if $args{disk};
my $file_xml = $DIR_XML."/".$iso->{xml_volume};
......@@ -594,7 +595,7 @@ sub _domain_create_from_base {
die "Domain $args{name} already exists"
if $self->search_domain($args{name});
my $base = $args{base} if $args{base};
my $base = $args{base};
$base = $self->_search_domain_by_id($args{id_base}) if $args{id_base};
confess "Unknown base id: $args{id_base}" if !$base;
......@@ -1013,17 +1014,17 @@ sub _xml_add_usb_ehci1 {
my $devices = shift;
my $model = 'ich9-ehci1';
my $ctrl = _search_xml(
my $ctrl_found = _search_xml(
xml => $devices
,name => 'controller'
,type => 'usb'
,model => $model
);
if ($ctrl) {
if ($ctrl_found) {
# warn "$model found \n".$ctrl->toString."\n";
return;
}
for $ctrl ($devices->findnodes('controller')) {
for my $ctrl ($devices->findnodes('controller')) {
next if $ctrl->getAttribute('type') ne 'usb';
next if $ctrl->getAttribute('model')
&& $ctrl->getAttribute('model') eq $model;
......
......@@ -84,7 +84,7 @@ sub list_domains {
closedir $ls;
return sort keys %domain;
return keys %domain;
}
sub search_domain {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment