LoginSignup
0
0

More than 5 years have passed since last update.

Perl::Critic(perlcritic)を使用して静的解析、コーディング規約テストを実施(実施編:ファイル)

Last updated at Posted at 2017-02-26

Perlの静的解析、コーディング規約テストを実施する為にPerl::Criticを使用する事になったので、内容を残しておきます。

dockerのubuntuにて実行
「Ubuntu 14.04.3 LTS」
(実行日付:2017/02/26)

コマンド実行

コマンド:
perl 「Perl::Critic記載ファイル」 「Perl::Critic対象ファイル」

(実行結果)

# perl checkCritic.pl testCode.pl
Code before strictures are enabled at line 1, column 1. See page 429 of PBP.
# 

(Perl::Critic記載ファイル内容)

# cat checkCritic.pl
use Perl::Critic;
use warnings;
use utf8;

my $critic = Perl::Critic->new();

# arg is only one
if ( @ARGV == 1 ){
    my $checkFile = $ARGV[0];
    print $critic->critique($checkFile);

}else {
    print "arg is only one! arg1 is Perl::Critic check File!! \n";
}

# 

(Perl::Critic対象ファイル内容)

# cat testCode.pl
print "Hello world";

# 

出力結果を対象外とする場合

指定内容:
-exclude => ['strict']

newの引数に指定する
my $critic = Perl::Critic->new(-exclude => ['strict']);

(実行例)

# perl checkCritic.pl testCode.pl
# 

(、、ん、何も出力されない。せめて問題なしのメッセージがほしい)

参照サイト:
Perl::Critic

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0