From 4ac0cd083d52bbcfcf953e9b3601c796240832e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 21 Aug 2018 12:32:23 +0200 Subject: [PATCH] [perlcritic] fix some severity 4 issues --- .perlcriticrc | 9 +++++++++ lib/Munin/Common/Defaults.pm.PL | 2 +- lib/Munin/Master/Node.pm | 1 + lib/Munin/Node/SpoolWriter.pm | 13 +++++++------ lib/Munin/Plugin/Framework.pm | 2 ++ lib/Munin/Plugin/HTTP.pm | 2 ++ script/munin-httpd | 4 ---- 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.perlcriticrc b/.perlcriticrc index ea6efc689a..5f6aee8e45 100644 --- a/.perlcriticrc +++ b/.perlcriticrc @@ -44,3 +44,12 @@ severity = 5 [Variables::ProhibitUnusedVariables] severity = 5 + +[Modules::ProhibitMultiplePackages] +severity = 5 + +[Modules::RequireEndWithOne] +severity = 5 + +[ValuesAndExpressions::ProhibitConstantPragma] +severity = 5 diff --git a/lib/Munin/Common/Defaults.pm.PL b/lib/Munin/Common/Defaults.pm.PL index c1101ba224..6602b8898e 100644 --- a/lib/Munin/Common/Defaults.pm.PL +++ b/lib/Munin/Common/Defaults.pm.PL @@ -73,7 +73,7 @@ print $fh <<'EOF'; sub get_defaults { my ($class) = @_; - ## no critic + ## no critic qw(TestingAndDebugging::ProhibitNoStrict) no strict 'refs'; my $defaults = {}; diff --git a/lib/Munin/Master/Node.pm b/lib/Munin/Master/Node.pm index c0256273b1..bf3074fe41 100644 --- a/lib/Munin/Master/Node.pm +++ b/lib/Munin/Master/Node.pm @@ -793,6 +793,7 @@ sub _merge_into_str_no_dup } # Defines the URL::scheme for munin +## no critic qw(Modules::ProhibitMultiplePackages) package URI::munin; # We are like a generic server diff --git a/lib/Munin/Node/SpoolWriter.pm b/lib/Munin/Node/SpoolWriter.pm index dfecf0eb15..674841a600 100644 --- a/lib/Munin/Node/SpoolWriter.pm +++ b/lib/Munin/Node/SpoolWriter.pm @@ -16,10 +16,11 @@ use Munin::Common::Utils qw( is_valid_hostname ); use Params::Validate qw( :all ); use List::Util qw( first ); +use Readonly; -use constant DEFAULT_TIME => 86_400; # put 1 day of results into a spool file -use constant MAXIMUM_AGE => 7; # remove spool files more than a week old -use constant DEFAULT_HOSTNAME => 'munin.example.com'; +Readonly my $DEFAULT_TIME => 86_400; # put 1 day of results into a spool file +Readonly my $MAXIMUM_AGE => 7; # remove spool files more than a week old +Readonly my $DEFAULT_HOSTNAME => 'munin.example.com'; sub _snap_to_epoch_boundary { my $self = shift; return $_[0] - ($_[0] % $self->{interval_size}) } @@ -50,19 +51,19 @@ sub new { $self->{interval_size} = first { defined($_) and $_ > 0 } ( $validated->{interval_size}, $self->{metadata}->{interval_size}, - DEFAULT_TIME + $DEFAULT_TIME ); $self->{interval_keep} = first { defined($_) and $_ > 0 } ( $validated->{interval_keep}, $self->{metadata}->{interval_keep}, - MAXIMUM_AGE, + $MAXIMUM_AGE, ); $self->{hostname} = first { defined($_) and is_valid_hostname($_) } ( $validated->{hostname}, $self->{metadata}->{hostname}, - DEFAULT_HOSTNAME, + $DEFAULT_HOSTNAME, ); return $self; diff --git a/lib/Munin/Plugin/Framework.pm b/lib/Munin/Plugin/Framework.pm index c9ccf37d62..756181923b 100644 --- a/lib/Munin/Plugin/Framework.pm +++ b/lib/Munin/Plugin/Framework.pm @@ -177,3 +177,5 @@ sub run { } } } + +1; diff --git a/lib/Munin/Plugin/HTTP.pm b/lib/Munin/Plugin/HTTP.pm index 90d7f52d9e..6b4a36a3da 100644 --- a/lib/Munin/Plugin/HTTP.pm +++ b/lib/Munin/Plugin/HTTP.pm @@ -111,3 +111,5 @@ sub get_basic_credentials { return $isproxy ? () : ($ENV{'http_username'}, $ENV{'http_password'}); } + +1; diff --git a/script/munin-httpd b/script/munin-httpd index 401d6b1588..67a0dd3c83 100755 --- a/script/munin-httpd +++ b/script/munin-httpd @@ -30,8 +30,6 @@ use warnings; # Trust PERL5LIB from environment use lib map { /(.*)/ } split(/:/, ($ENV{PERL5LIB} || '')); -package Munin::Master::Http; - use HTTP::Server::Simple::CGI::PreFork; use base qw(HTTP::Server::Simple::CGI::PreFork); @@ -59,8 +57,6 @@ sub handle_request } } -package main; - $ENV{PATH} = '/usr/bin:/bin'; # start the server on port 4948