Fix remaining linter errors

This commit is contained in:
Rumperuu 2021-03-20 19:53:38 +00:00
parent 6399354b80
commit 1f6225e506
9 changed files with 28 additions and 18 deletions

View file

@ -71,6 +71,7 @@ sub post_add {
} }
); );
## no critic (InputOutput::RequireBriefOpen)
open my $fh, '<', \$csv_data; open my $fh, '<', \$csv_data;
# List context returns the actual headers # List context returns the actual headers
@ -99,6 +100,9 @@ sub post_add {
} }
my $csv_output = $csv->getline_hr_all($fh); my $csv_output = $csv->getline_hr_all($fh);
close $fh;
## use critic
unless ( scalar(@$csv_output) ) { unless ( scalar(@$csv_output) ) {
$c->_csv_flash_error("No data found"); $c->_csv_flash_error("No data found");

View file

@ -123,7 +123,7 @@ sub valid_read {
} }
sub valid_edit { sub valid_edit {
my $c = shift; my ($c, $warning) = @_;
my $validation = $c->validation; my $validation = $c->validation;
$validation->required('name'); $validation->required('name');
@ -180,9 +180,9 @@ sub valid_edit {
); );
} }
finally { finally {
if (@_) { if ($warning) {
use Devel::Dwarn; use Devel::Dwarn;
Dwarn \@_; Dwarn \$warning;
$c->flash( $c->flash(
error => 'Something went wrong Updating the Organisation' ); error => 'Something went wrong Updating the Organisation' );
} }

View file

@ -70,7 +70,7 @@ sub read {
## no critic (Subroutines::ProhibitBuiltinHomonyms) ## no critic (Subroutines::ProhibitBuiltinHomonyms)
sub update { sub update {
## use critic ## use critic
my $c = shift; my ($c, $error) = @_;
my $id = $c->param('id'); my $id = $c->param('id');
@ -145,9 +145,9 @@ sub update {
); );
} }
finally { finally {
if (@_) { if ($error) {
$c->flash( error => 'Something went wrong Updating the User' ); $c->flash( error => 'Something went wrong Updating the User' );
$c->app->log->warn( Dumper @_ ); $c->app->log->warn( Dumper $error );
} }
else { else {
$c->flash( success => 'Updated User' ); $c->flash( success => 'Updated User' );
@ -188,9 +188,9 @@ sub update {
); );
} }
finally { finally {
if (@_) { if ($error) {
$c->flash( error => 'Something went wrong Updating the User' ); $c->flash( error => 'Something went wrong Updating the User' );
$c->app->log->warn( Dumper @_ ); $c->app->log->warn( Dumper $error );
} }
else { else {
$c->flash( success => 'Updated User' ); $c->flash( success => 'Updated User' );

View file

@ -460,14 +460,16 @@ sub post_leaderboards {
my @leaderboard_array = $today_values->all; my @leaderboard_array = $today_values->all;
if ( $validation->param('type') =~ /total$/ ) { if ( $validation->param('type') =~ /total$/ ) {
## no critic (ValuesAndExpressions::ProhibitCommaSeparatedStatements)
@leaderboard_array = ( @leaderboard_array = (
map { map {
{ {
%$_, %$_,
value => $_->{value} / 100000, value => $_->{value} / 100000
} }
} @leaderboard_array } @leaderboard_array
); );
## use critic
} }
my $current_user_position = my $current_user_position =
@ -543,6 +545,7 @@ sub post_leaderboards_paged {
$values_count = $today_values->pager->total_entries; $values_count = $today_values->pager->total_entries;
if ( $validation->param('type') =~ /total$/ ) { if ( $validation->param('type') =~ /total$/ ) {
## no critic (ValuesAndExpressions::ProhibitCommaSeparatedStatements)
@leaderboard_array = ( @leaderboard_array = (
map { map {
{ {
@ -551,6 +554,7 @@ sub post_leaderboards_paged {
} }
} @leaderboard_array } @leaderboard_array
); );
## use critic
} }
$current_user_position = $today_values->find( $current_user_position = $today_values->find(

View file

@ -34,3 +34,5 @@ __PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to( "entity", "Pear::LocalLoop::Schema::Result::Entity", __PACKAGE__->belongs_to( "entity", "Pear::LocalLoop::Schema::Result::Entity",
"entity_id", ); "entity_id", );
1;

View file

@ -5,7 +5,9 @@ use warnings;
use base 'DBIx::Class::ResultSet'; use base 'DBIx::Class::ResultSet';
## no critic (Subroutines::RequireArgUnpacking)
sub sales { return shift->search_related( 'sales', @_ ) } sub sales { return shift->search_related( 'sales', @_ ) }
## use critic
sub create_org { sub create_org {
my ( $self, $org ) = @_; my ( $self, $org ) = @_;
@ -16,8 +18,6 @@ sub create_org {
type => 'organisation', type => 'organisation',
} }
); );
return 1;
} }
1; 1;

View file

@ -39,9 +39,9 @@ sub _unordered_get_values {
} }
sub get_users { sub get_users {
my $self = shift; my ($self, $set_id) = @_;
return $self->_unordered_get_values(@_)->search( return $self->_unordered_get_values($set_id)->search(
{}, {},
{ {
group_by => 'user_name', group_by => 'user_name',
@ -51,9 +51,9 @@ sub get_users {
} }
sub get_orgs { sub get_orgs {
my $self = shift; my ( $self, $set_id ) = shift;
return $self->_unordered_get_values(@_)->search( return $self->_unordered_get_values($set_id)->search(
{}, {},
{ {
group_by => 'org_name', group_by => 'org_name',

View file

@ -5,6 +5,8 @@ use warnings;
use base 'DBIx::Class::ResultSet'; use base 'DBIx::Class::ResultSet';
## no critic (Subroutines::RequireArgUnpacking)
sub entity { return shift->search_related( 'entity', @_ ) } sub entity { return shift->search_related( 'entity', @_ ) }
## use critic
1; 1;

View file

@ -69,7 +69,7 @@ has mojo => (
builder => sub { builder => sub {
my $self = shift; my $self = shift;
$ENV{MOJO_CONFIG} = $self->config->filename; local $ENV{MOJO_CONFIG} = $self->config->filename;
my $t = Test::Mojo->new('Pear::LocalLoop'); my $t = Test::Mojo->new('Pear::LocalLoop');
$t->app->schema->deploy; $t->app->schema->deploy;
@ -197,8 +197,6 @@ sub gen_upload {
json => Mojo::JSON::encode_json($args), json => Mojo::JSON::encode_json($args),
file => $file, file => $file,
}; };
return 1;
} }
sub install_fixtures { sub install_fixtures {