Skip to content

Commit

Permalink
Merge pull request #6294 from jknphy/add_perlcritic_travis
Browse files Browse the repository at this point in the history
Add perlcritic to Travis with gentle severity
  • Loading branch information
okurz committed Nov 30, 2018
2 parents 3f24566 + 43df0cc commit e70ba1c
Show file tree
Hide file tree
Showing 19 changed files with 255 additions and 239 deletions.
9 changes: 9 additions & 0 deletions .perlcriticrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[-Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval]

[Perl::Critic::Policy::HashKeyQuotes]

[Perl::Critic::Policy::ConsistentQuoteLikeWords]

[Perl::Critic::Policy::ControlStructures::ProhibitDeepNests]
severity = 5
max_nests = 5
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test-merge:
FILES=$$(git diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD master 2>/dev/null` | grep 'tests.*pm') ;\
for file in $$FILES; do if test -f $$file; then \
tools/check_metadata $$file || touch failed; \
git grep wait_idle $$file && touch failed; \
git grep -q wait_idle $$file && touch failed; \
${PERLCRITIC} $$file || (echo $$file ; touch failed) ;\
fi ; done; \
fi
Expand All @@ -74,7 +74,7 @@ test-dry:

.PHONY: test-no-wait_idle
test-no-wait_idle:
@! git grep wait_idle lib/ tests/
@! git grep -q wait_idle lib/ tests/

.PHONY: test-static
test-static: tidy test-merge test-dry test-no-wait_idle test-unused-modules test-soft_failure-no-reference
Expand All @@ -83,19 +83,19 @@ test-static: tidy test-merge test-dry test-no-wait_idle test-unused-modules test
ifeq ($(TESTS),compile)
test: test-compile
else
test: unit-test test-static test-compile
test: unit-test test-static test-compile perlcritic
endif

PERLCRITIC=PERL5LIB=tools/lib/perlcritic:$$PERL5LIB perlcritic --quiet --gentle --include Perl::Critic::Policy::HashKeyQuote --include Perl::Critic::Policy::ConsistentQuoteLikeWords
PERLCRITIC=PERL5LIB=tools/lib/perlcritic:$$PERL5LIB perlcritic --quiet --gentle

.PHONY: perlcritic
perlcritic: tools/lib/
${PERLCRITIC} .
${PERLCRITIC} $$(git ls-files "*.p[ml]")

.PHONY: test-unused-modules
test-unused-modules:
tools/detect_unused_modules

.PHONY: test-soft_failure-no-reference
test-soft_failure-no-reference:
@! git grep -E -e 'soft_failure\>.*\;' --and --not -e '([$$0-9a-z]+#[$$0-9]+|fate.suse.com/[0-9]|\$$[a-z]+)' lib/ tests/
@! git grep -q -E -e 'soft_failure\>.*\;' --and --not -e '([$$0-9a-z]+#[$$0-9]+|fate.suse.com/[0-9]|\$$[a-z]+)' lib/ tests/
2 changes: 1 addition & 1 deletion lib/apachetest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ sub setup_apache2 {
}
# Create x509 certificate for this apache server
if ($mode eq "SSL") {
my $gensslcert_C_opt = '-C $(hostname)' unless is_sle('15+');
my $gensslcert_C_opt = !is_sle('15+') ? '-C $(hostname)' : '';
assert_script_run "gensslcert -n \$(hostname) $gensslcert_C_opt -e webmaster@\$(hostname)", 900;
assert_script_run 'ls /etc/apache2/ssl.crt/$(hostname)-server.crt /etc/apache2/ssl.key/$(hostname)-server.key';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/hacluster.pm
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ sub ha_export_logs {
my $corosync_conf = '/etc/corosync/corosync.conf';
my $hb_log = '/var/log/hb_report';
my $packages_list = '/tmp/packages.list';
my $report_opt = '-f0' unless is_sle('12-sp4+');
my $report_opt = !is_sle('12-sp4+') ? '-f0' : '';
my @y2logs;

# Extract HA logs and upload them
Expand Down
2 changes: 1 addition & 1 deletion lib/ipmi_backend_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use Exporter;
use strict;
use warnings;
use testapi;
use version_utils qw/is_storage_ng is_sle/;
use version_utils qw(is_storage_ng is_sle);
use utils;
use power_action_utils 'prepare_system_shutdown';

Expand Down
2 changes: 1 addition & 1 deletion lib/kdump_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use Exporter;
use strict;
use testapi;
use utils;
use List::Util qw(maxstr);
use List::Util 'maxstr';
use version_utils qw(is_sle is_jeos);

our @EXPORT = qw(install_kernel_debuginfo prepare_for_kdump activate_kdump kdump_is_active do_kdump);
Expand Down
6 changes: 3 additions & 3 deletions lib/main_common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ sub get_ltp_tag {
{
local $@;

eval 'use main_ltp;';
eval 'use main_ltp';
if ($@) {
bmwqemu::fctwarn("Failed to load main_ltp.pm:\n$@", 'main_common.pm');
eval q%
eval q%{
sub load_kernel_tests {
if (is_kernel_test())
{
Expand Down Expand Up @@ -331,7 +331,7 @@ sub is_desktop_module_selected {

sub default_desktop {
return 'textmode' if (get_var('SYSTEM_ROLE') && !check_var('SYSTEM_ROLE', 'default'));
return undef if get_var('VERSION', '') lt '12';
return if get_var('VERSION', '') lt '12';
return 'gnome' if get_var('VERSION', '') lt '15';
# with SLE 15 LeanOS only the default is textmode
return 'gnome' if get_var('BASE_VERSION', '') =~ /^12/;
Expand Down
6 changes: 3 additions & 3 deletions lib/main_ltp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use Exporter;
use testapi qw(check_var get_var);
use autotest;
use utils;
use LTP::TestInfo qw(testinfo);
use LTP::TestInfo 'testinfo';
use File::Basename 'basename';
use main_common qw(load_bootloader_s390x boot_hdd_image get_ltp_tag);
use 5.018;
Expand All @@ -40,7 +40,7 @@ sub shutdown_ltp {
sub parse_openposix_runfile {
my ($path, $cmd_pattern, $cmd_exclude, $test_result_export) = @_;

open(my $rfile, $path) or die "Can not open runfile asset $path: $!";
open(my $rfile, $path) or die "Can not open runfile asset $path: $!"; ## no critic
while (my $line = <$rfile>) {
chomp($line);
if ($line =~ m/$cmd_pattern/ && !($line =~ m/$cmd_exclude/)) {
Expand All @@ -54,7 +54,7 @@ sub parse_openposix_runfile {
sub parse_runtest_file {
my ($path, $cmd_pattern, $cmd_exclude, $test_result_export) = @_;

open(my $rfile, $path) or die "Can not open runtest asset $path: $!";
open(my $rfile, $path) or die "Can not open runtest asset $path: $!"; ## no critic
while (my $line = <$rfile>) {
next if ($line =~ /(^#)|(^$)/);

Expand Down
2 changes: 1 addition & 1 deletion lib/migration.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use strict;
use testapi;
use utils;
use registration;
use qam qw/remove_test_repositories/;
use qam 'remove_test_repositories';
use version_utils qw(is_sle is_sles4sap);

our @EXPORT = qw(
Expand Down
1 change: 1 addition & 0 deletions lib/publiccloud/basetest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use testapi;
use publiccloud::azure;
use publiccloud::ec2;
use publiccloud::gce;
use strict;

sub provider_factory {
my ($self) = @_;
Expand Down
Loading

0 comments on commit e70ba1c

Please sign in to comment.