From 273e84b3424f444b5a21f5c1c604fe28fce6cc7e Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Mon, 7 May 2018 17:17:55 +0200 Subject: [PATCH] Clean some Dumper usage (#1416) --- lemonldap-ng-common/eg/llng-app.psgi | 1 - lemonldap-ng-common/lib/Lemonldap/NG/Common/Cli.pm | 1 - .../lib/Lemonldap/NG/Common/Conf/SAML/Metadata.pm | 1 - .../lib/Lemonldap/NG/Common/Conf/Serializer.pm | 2 +- .../lib/Lemonldap/NG/Common/PSGI/Cli/Lib.pm | 3 +++ .../lib/Lemonldap/NG/Common/PSGI/Router.pm | 2 -- .../lib/Lemonldap/NG/Handler/Lib/Status.pm | 1 - lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t | 1 - .../t/61-Lemonldap-NG-Handler-PSGI-Server.t | 1 - lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t | 1 - .../t/63-Lemonldap-NG-Handler-PSGI-Try.t | 1 - .../t/64-Lemonldap-NG-Handler-PSGI-DevOps.t | 1 - .../t/66-Lemonldap-NG-Handler-PSGI-wildcard.t | 1 - lemonldap-ng-handler/t/test-psgi-lib.pm | 2 -- lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli.pm | 1 + .../lib/Lemonldap/NG/Manager/Conf/Parser.pm | 1 + lemonldap-ng-manager/scripts/lmConfigEditor | 10 ++++++---- lemonldap-ng-manager/t/03-HTML-forms.t | 1 - lemonldap-ng-manager/t/05-rest-api.t | 1 - lemonldap-ng-manager/t/06-rest-api.t | 2 -- lemonldap-ng-manager/t/10-save-unchanged-conf.t | 1 - lemonldap-ng-manager/t/12-save-changed-conf.t | 1 - lemonldap-ng-manager/t/14-bad-changes-in-conf.t | 1 - lemonldap-ng-manager/t/15-combination.t | 1 - lemonldap-ng-manager/t/80-attributes.t | 1 - lemonldap-ng-manager/t/test-lib.pm | 1 - .../lib/Lemonldap/NG/Portal/Main/Run.pm | 3 ++- lemonldap-ng-portal/t/test-lib.pm | 5 +++-- 28 files changed, 17 insertions(+), 32 deletions(-) diff --git a/lemonldap-ng-common/eg/llng-app.psgi b/lemonldap-ng-common/eg/llng-app.psgi index 48074fa1c..c302eca81 100644 --- a/lemonldap-ng-common/eg/llng-app.psgi +++ b/lemonldap-ng-common/eg/llng-app.psgi @@ -1,6 +1,5 @@ #!/usr/bin/perl -use Data::Dumper; use Plack::Builder; # Basic test app diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Cli.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Cli.pm index e757476b1..132306dd6 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Cli.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Cli.pm @@ -2,7 +2,6 @@ package Lemonldap::NG::Common::Cli; use strict; use Mouse; -use Data::Dumper; use Lemonldap::NG::Common::Conf; our $VERSION = '2.0.0'; diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/SAML/Metadata.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/SAML/Metadata.pm index caa4edac2..9bb715b3d 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/SAML/Metadata.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/SAML/Metadata.pm @@ -9,7 +9,6 @@ use strict; use Mouse; use Crypt::OpenSSL::RSA; use Crypt::OpenSSL::X509; -use Data::Dumper; use HTML::Template; use MIME::Base64; use Safe; diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Serializer.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Serializer.pm index df2c9c879..3ceb632f8 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Serializer.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Serializer.pm @@ -131,7 +131,7 @@ sub oldUnserialize { if ( $k =~ $hashParameters and $v ||= {} and not ref($v) ) { $conf->{$k} = {}; - # Value should be a Data::Dumper, else this is an old format + # Value should be a Data::Dumper, else this is an old-old format if ( defined($v) and $v !~ /^\$/ ) { $Lemonldap::NG::Common::Conf::msg .= diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Cli/Lib.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Cli/Lib.pm index fc3a6526e..937e3ba69 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Cli/Lib.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Cli/Lib.pm @@ -125,6 +125,7 @@ sub jsonResponse { or die "PSGI lib has refused my get, aborting"; unless ( $res->[0] == 200 ) { require Data::Dumper; + $Data::Dumper::Useperl = 1; print STDERR "Result dump :\n" . Data::Dumper::Dumper($res); die "Manager lib does not return a 200 code, aborting"; } @@ -139,6 +140,7 @@ sub jsonPostResponse { or die "PSGI lib has refused my post, aborting"; unless ( $res->[0] == 200 ) { require Data::Dumper; + $Data::Dumper::Useperl = 1; print STDERR "Result dump :\n" . Data::Dumper::Dumper($res); die "Manager lib does not return a 200 code, aborting"; } @@ -153,6 +155,7 @@ sub jsonPutResponse { or die "PSGI lib has refused my put, aborting"; unless ( $res->[0] == 200 ) { require Data::Dumper; + $Data::Dumper::Useperl = 1; print STDERR "Result dump :\n" . Data::Dumper::Dumper($res); die "Manager lib does not return a 200 code, aborting"; } diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm index b49a87db0..887a8caf9 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm @@ -117,8 +117,6 @@ sub handlerAbort { sub handler { my ( $self, $req ) = @_; - #print STDERR Dumper($self->routes);use Data::Dumper; - # Reinitialize configuration message $Lemonldap::NG::Common::Conf::msg = ''; diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/Status.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/Status.pm index d53baa735..e969db724 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/Status.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/Status.pm @@ -6,7 +6,6 @@ package Lemonldap::NG::Handler::Lib::Status; use strict; use POSIX qw(setuid setgid); use JSON qw(to_json); -use Data::Dumper; our $VERSION = '2.0.0'; diff --git a/lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t b/lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t index aa47024a5..20a429e88 100644 --- a/lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t +++ b/lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t @@ -1,6 +1,5 @@ use Test::More; use JSON; -use Data::Dumper; use MIME::Base64; require 't/test-psgi-lib.pm'; diff --git a/lemonldap-ng-handler/t/61-Lemonldap-NG-Handler-PSGI-Server.t b/lemonldap-ng-handler/t/61-Lemonldap-NG-Handler-PSGI-Server.t index cca58cb35..f37deba1d 100644 --- a/lemonldap-ng-handler/t/61-Lemonldap-NG-Handler-PSGI-Server.t +++ b/lemonldap-ng-handler/t/61-Lemonldap-NG-Handler-PSGI-Server.t @@ -1,6 +1,5 @@ use Test::More; use JSON; -use Data::Dumper; use MIME::Base64; require 't/test-psgi-lib.pm'; diff --git a/lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t b/lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t index 29d6008e0..2ab1fe7ac 100644 --- a/lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t +++ b/lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t @@ -1,6 +1,5 @@ use Test::More; use JSON; -use Data::Dumper; use MIME::Base64; require 't/test-psgi-lib.pm'; diff --git a/lemonldap-ng-handler/t/63-Lemonldap-NG-Handler-PSGI-Try.t b/lemonldap-ng-handler/t/63-Lemonldap-NG-Handler-PSGI-Try.t index 0618f8e82..b7affe815 100644 --- a/lemonldap-ng-handler/t/63-Lemonldap-NG-Handler-PSGI-Try.t +++ b/lemonldap-ng-handler/t/63-Lemonldap-NG-Handler-PSGI-Try.t @@ -1,6 +1,5 @@ use Test::More; use JSON; -use Data::Dumper; use MIME::Base64; require 't/test-psgi-lib.pm'; diff --git a/lemonldap-ng-handler/t/64-Lemonldap-NG-Handler-PSGI-DevOps.t b/lemonldap-ng-handler/t/64-Lemonldap-NG-Handler-PSGI-DevOps.t index 53b205691..1f4cfd419 100644 --- a/lemonldap-ng-handler/t/64-Lemonldap-NG-Handler-PSGI-DevOps.t +++ b/lemonldap-ng-handler/t/64-Lemonldap-NG-Handler-PSGI-DevOps.t @@ -1,6 +1,5 @@ use Test::More; use JSON; -use Data::Dumper; use MIME::Base64; use LWP::UserAgent; diff --git a/lemonldap-ng-handler/t/66-Lemonldap-NG-Handler-PSGI-wildcard.t b/lemonldap-ng-handler/t/66-Lemonldap-NG-Handler-PSGI-wildcard.t index 9dc3c5c51..f2d1d7631 100644 --- a/lemonldap-ng-handler/t/66-Lemonldap-NG-Handler-PSGI-wildcard.t +++ b/lemonldap-ng-handler/t/66-Lemonldap-NG-Handler-PSGI-wildcard.t @@ -1,6 +1,5 @@ use Test::More; use JSON; -use Data::Dumper; use MIME::Base64; BEGIN { diff --git a/lemonldap-ng-handler/t/test-psgi-lib.pm b/lemonldap-ng-handler/t/test-psgi-lib.pm index de1000700..c62c3d1b1 100644 --- a/lemonldap-ng-handler/t/test-psgi-lib.pm +++ b/lemonldap-ng-handler/t/test-psgi-lib.pm @@ -1,14 +1,12 @@ # Base library for tests use strict; -use Data::Dumper; use 5.10.0; use POSIX 'strftime'; use_ok('Lemonldap::NG::Common::PSGI::Cli::Lib'); our $client; our $count = 1; -$Data::Dumper::Deparse = 1; no warnings 'redefine'; diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli.pm index add5694cd..bf83e547c 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli.pm @@ -6,6 +6,7 @@ use Data::Dumper; use Lemonldap::NG::Common::Conf::ReConstants; our $VERSION = '2.0.0'; +$Data::Dumper::Useperl = 1; extends('Lemonldap::NG::Manager::Cli::Lib'); diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm index 43b6ea8db..01ff0b692 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm @@ -79,6 +79,7 @@ sub hdebug { foreach my $d (@_) { if ( ref $d ) { require Data::Dumper; + $Data::Dumper::Useperl = 1; print STDERR Data::Dumper::Dumper($d); } else { print STDERR "$d\n" } diff --git a/lemonldap-ng-manager/scripts/lmConfigEditor b/lemonldap-ng-manager/scripts/lmConfigEditor index 293cfd441..629c87b8e 100644 --- a/lemonldap-ng-manager/scripts/lmConfigEditor +++ b/lemonldap-ng-manager/scripts/lmConfigEditor @@ -32,7 +32,8 @@ $refConf->{cfgLog} = ''; # Sort keys $Data::Dumper::Sortkeys = 1; -my $tmp = Dumper($refConf); +$Data::Dumper::Useperl = 1; +my $tmp = Dumper($refConf); my $refFile = File::Temp->new( UNLINK => 1 ); my $editFile = File::Temp->new( UNLINK => 1 ); @@ -68,12 +69,13 @@ if (`diff $refFile $editFile`) { { refConf => $refConf, newConf => $VAR1, - req => 1, + req => 1, } ); - unless($parser->testNewConf) { + unless ( $parser->testNewConf ) { print STDERR "Configuration seems to have some errors:\n "; - print STDERR Dumper({errors => $parser->errors,warnings => $parser->warnings}); + print STDERR Dumper( + { errors => $parser->errors, warnings => $parser->warnings } ); print STDERR "Are you sure you want to write it ? (yes/no) "; my $resp = ; die "Aborted" unless $resp =~ /^yes$/i; diff --git a/lemonldap-ng-manager/t/03-HTML-forms.t b/lemonldap-ng-manager/t/03-HTML-forms.t index 81900b7fc..1dc0317b3 100644 --- a/lemonldap-ng-manager/t/03-HTML-forms.t +++ b/lemonldap-ng-manager/t/03-HTML-forms.t @@ -3,7 +3,6 @@ use Test::More; use strict; -use Data::Dumper; my $formDir = 'site/htdocs/static/forms'; diff --git a/lemonldap-ng-manager/t/05-rest-api.t b/lemonldap-ng-manager/t/05-rest-api.t index 7e9f799c9..3468a8ce3 100644 --- a/lemonldap-ng-manager/t/05-rest-api.t +++ b/lemonldap-ng-manager/t/05-rest-api.t @@ -43,7 +43,6 @@ foreach my $query (@bad) { or print STDERR "# Receive a $res->[0] code"; my $href; - #print STDERR Dumper($res->[2]);use Data::Dumper; ok( $href = from_json( $res->[2]->[0] ), 'Response is JSON' ); ok( $href->{error}, "Receive an explanation message ($href->{error})" ); count(3); diff --git a/lemonldap-ng-manager/t/06-rest-api.t b/lemonldap-ng-manager/t/06-rest-api.t index f33f1a12e..c08779ad8 100644 --- a/lemonldap-ng-manager/t/06-rest-api.t +++ b/lemonldap-ng-manager/t/06-rest-api.t @@ -29,6 +29,4 @@ ok( $res->[0] == 200, "Result code is 200" ); ok( $key = from_json( $res->[2]->[0] ), 'Response is JSON' ); count(3); -#print STDERR Dumper($key);use Data::Dumper; - done_testing( count() ); diff --git a/lemonldap-ng-manager/t/10-save-unchanged-conf.t b/lemonldap-ng-manager/t/10-save-unchanged-conf.t index 6ee635509..10251efd2 100644 --- a/lemonldap-ng-manager/t/10-save-unchanged-conf.t +++ b/lemonldap-ng-manager/t/10-save-unchanged-conf.t @@ -3,7 +3,6 @@ use Test::More; use strict; use JSON; -use Data::Dumper; require 't/test-lib.pm'; my @struct = diff --git a/lemonldap-ng-manager/t/12-save-changed-conf.t b/lemonldap-ng-manager/t/12-save-changed-conf.t index efdc635f9..483ab63b9 100644 --- a/lemonldap-ng-manager/t/12-save-changed-conf.t +++ b/lemonldap-ng-manager/t/12-save-changed-conf.t @@ -4,7 +4,6 @@ use Test::More; use strict; use JSON; -use Data::Dumper; require 't/test-lib.pm'; my $struct = 't/jsonfiles/12-modified.json'; diff --git a/lemonldap-ng-manager/t/14-bad-changes-in-conf.t b/lemonldap-ng-manager/t/14-bad-changes-in-conf.t index f1f6998a2..9b2d78826 100644 --- a/lemonldap-ng-manager/t/14-bad-changes-in-conf.t +++ b/lemonldap-ng-manager/t/14-bad-changes-in-conf.t @@ -3,7 +3,6 @@ use Test::More; use strict; use JSON; -use Data::Dumper; require 't/test-lib.pm'; my $struct = 't/jsonfiles/14-bad.json'; diff --git a/lemonldap-ng-manager/t/15-combination.t b/lemonldap-ng-manager/t/15-combination.t index b9ee8f048..b17216353 100644 --- a/lemonldap-ng-manager/t/15-combination.t +++ b/lemonldap-ng-manager/t/15-combination.t @@ -3,7 +3,6 @@ use Test::More; use strict; use JSON; -use Data::Dumper; require 't/test-lib.pm'; my $struct = 't/jsonfiles/15-combination.json'; diff --git a/lemonldap-ng-manager/t/80-attributes.t b/lemonldap-ng-manager/t/80-attributes.t index 73cce1178..3e32f10fe 100644 --- a/lemonldap-ng-manager/t/80-attributes.t +++ b/lemonldap-ng-manager/t/80-attributes.t @@ -3,7 +3,6 @@ use strict; use Test::More; -use Data::Dumper; # CONSTANTS diff --git a/lemonldap-ng-manager/t/test-lib.pm b/lemonldap-ng-manager/t/test-lib.pm index c0b80df2b..b8b549767 100644 --- a/lemonldap-ng-manager/t/test-lib.pm +++ b/lemonldap-ng-manager/t/test-lib.pm @@ -1,7 +1,6 @@ # Base library for tests use strict; -use Data::Dumper; use 5.10.0; use_ok('Lemonldap::NG::Manager::Cli::Lib'); diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm index 9004a2fe3..e32d0c027 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm @@ -679,7 +679,8 @@ sub cookie { sub _dump { my ( $self, $variable ) = @_; require Data::Dumper; - $Data::Dumper::Indent = 0; + $Data::Dumper::Indent = 0; + $Data::Dumper::Useperl = 1; $self->logger->debug( "Dump: " . Data::Dumper::Dumper($variable) ); return; } diff --git a/lemonldap-ng-portal/t/test-lib.pm b/lemonldap-ng-portal/t/test-lib.pm index 9e9da16d5..557129be6 100644 --- a/lemonldap-ng-portal/t/test-lib.pm +++ b/lemonldap-ng-portal/t/test-lib.pm @@ -3,7 +3,6 @@ package main; use strict; use Data::Dumper; -$Data::Dumper::Sortkeys = 1; use LWP::UserAgent; use URI::Escape; use 5.10.0; @@ -15,7 +14,9 @@ BEGIN { } our $count = 1; -$Data::Dumper::Deparse = 1; +$Data::Dumper::Deparse = 1; +$Data::Dumper::Sortkeys = 1; +$Data::Dumper::Useperl = 1; my $ini; sub count {