Skip to content

Commit

Permalink
fix all linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Sri-2023 committed Dec 13, 2024
1 parent 666d1bb commit 487986a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 30 deletions.
8 changes: 4 additions & 4 deletions lib/CXGN/Dataset.pm
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ sub set_dataset_public {
if ($@) {
return "An error occurred, $@";
} else {
return undef;
return;
}
}
}
Expand All @@ -474,7 +474,7 @@ sub set_dataset_private {
if ($@) {
return "An error occurred, $@";
} else {
return undef;
return;
}
}
}
Expand Down Expand Up @@ -1258,7 +1258,7 @@ sub delete {
if ($@) {
return "An error occurred, $@";
} else {
return undef;
return;
}

}
Expand All @@ -1280,7 +1280,7 @@ sub update_description {
if ($@) {
return "An error occurred, $@";
} else {
return undef;
return;
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion lib/CXGN/Trial/Download/Plugin/TrialPhenotypeCSV.pm
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ sub download {
my $num_col = scalar(@$header);
for (my $line =0; $line< @data; $line++) {
my $columns = $data[$line];
print $F join ',', map { $_ =~ s/"/""/g; qq!"$_"! } @$columns;
print $F join ',', map {
my $field = $_;
$field =~ s/"/""/g;
qq!"$field"!;
} @$columns;
print $F "\n";
}
close($F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ sub download {
my $entry_number = $trial_entry_numbers{$trial_id}{$stock_id};
splice(@$columns, $ENTRY_NUMBER_COLUMN, 0, $entry_number);
}
print $F join ',', map { $_ =~ s/"/""/g; qq!"$_"! } @$columns;
print $F join ',', map {
my $field = $_;
$field =~ s/"/""/g;
qq!"$field"!;
} @$columns;
print $F "\n";
}
close($F);
Expand Down
48 changes: 24 additions & 24 deletions lib/SGN/Controller/BreedersToolbox/Download.pm
Original file line number Diff line number Diff line change
Expand Up @@ -634,26 +634,26 @@ sub download_action : Path('/breeders/download_action') Args(0) {
if ($format eq ".csv") {

#build csv with column names
open(CSV, "> :encoding(UTF-8)", $tempfile) || die "Can't open file $tempfile\n";
my @header = @{$data[0]};
my $num_col = scalar(@header);
for (my $line =0; $line< @data; $line++) {
my @columns = @{$data[$line]};
my $step = 1;
for(my $i=0; $i<$num_col; $i++) {
if (defined($columns[$i])) {
print CSV "\"$columns[$i]\"";
} else {
print CSV "\"\"";
}
if ($step < $num_col) {
print CSV ",";
}
$step++;
open(my $csv_fh, "> :encoding(UTF-8)", $tempfile) || die "Can't open file $tempfile\n";
my @header = @{$data[0]};
my $num_col = scalar(@header);
for (my $line =0; $line< @data; $line++) {
my @columns = @{$data[$line]};
my $step = 1;
for(my $i=0; $i<$num_col; $i++) {
if (defined($columns[$i])) {
print $csv_fh "\"$columns[$i]\"";
} else {
print $csv_fh "\"\"";
}
print CSV "\n";
if ($step < $num_col) {
print $csv_fh ",";
}
$step++;
}
close CSV;
print $csv_fh "\n";
}
close $csv_fh;

} else {
my $ss = Excel::Writer::XLSX->new($tempfile);
Expand Down Expand Up @@ -769,7 +769,7 @@ sub download_accession_properties_action : Path('/breeders/download_accession_pr
my $file_name = basename($file_path);

# Write to csv file
open(CSV, "> :encoding(UTF-8)", $file_path) || die "Can't open file $file_path\n";
open(my $csv_fh, "> :encoding(UTF-8)", $file_path) || die "Can't open file $file_path\n";
my @header = @{$rows->[0]};
my $num_col = scalar(@header);

Expand All @@ -778,18 +778,18 @@ sub download_accession_properties_action : Path('/breeders/download_accession_pr
my $step = 1;
for ( my $i = 0; $i < $num_col; $i++ ) {
if ($columns->[$i]) {
print CSV "\"$columns->[$i]\"";
print $csv_fh "\"$columns->[$i]\"";
} else {
print CSV "\"\"";
print $csv_fh "\"\"";
}
if ($step < $num_col) {
print CSV ",";
print $csv_fh ",";
}
$step++;
}
print CSV "\n";
print $csv_fh "\n";
}
close CSV;
close $csv_fh;

# Return the csv file
$c->res->content_type('text/csv');
Expand Down

0 comments on commit 487986a

Please sign in to comment.