Perl::Lint - Yet Another 
Perl Source Code Linter 
http://bit.ly/1p5HdSA 
@moznion
VOTE ME!
SEE ALSO 
Perlの静的解析入門と 
Perlリファクタリングツール 
App::PRTのご紹介 
@hitode909 
! 
Day 2, 多目的教室3, 16:00
@moznion
@moznion 
@hitode909
Perl::Lint 
! https://github.com/moznion/Perl-Lint 
  
https://metacpan.org/release/MOZNION/Perl- 
Lint-0.01_01 (<= UNDERDEVELOPMENT!!!)
Perl::Lint 
! https://github.com/moznion/Perl-Lint 
  
https://metacpan.org/release/MOZNION/Perl- 
Lint-0.01_02 (<= UNDERDEVELOPMENT!!!)
What is 
Perl::Lint?
A. Source Code Linter 
for Perl
Yes, It’s like… 
Perl:: 
http://bit.ly/1l5HrYX
Are you using 
Perl::Critic? http://bit.ly/1pfMxCW
What is 
Perl::Critic?
A. Source Code Linter 
for Perl
Wait!!
What is 
Source Code 
Linter???
A. Analyzes the 
source code and 
detects the causes 
of bugs
Search 
and 
Destroy 
http://bit.ly/1AT3Bl3
Concretely…
There are five bad things
There are five bad things
There are five bad things
There are five bad things
There are five bad things
There are five bad things
It was fun?
Is this what I think it is?
It’s just CODE REVIEW?
But do you think human 
should do the such code 
review?
Human should work 
more creative
It seems possible to 
check by computer
There are five bad things
And probably 
human overlooks
Hard to Understand Code
Hard to Understand Code 
Destroy!
Hard to Understand Code 
Easy to review
Do you like clean code, 
and why?
Readable code 
! 
! 
Reviewable code
Readable code 
≒ 
! 
! 
Reviewable code
=> Maintainable!!
Maintainable code 
will be growing up 
along maintainable
Humans can focus on 
creative work
Okay, 
Make maintainable code 
by computer!
And then source code 
linter was appeared 
(1979 for C)
Now; 
js-lint, find-bugs, 
rubocop, etc…
And language 
processors: 
Go, Scala and etc.
Does Perl have?
Perl::Critic is awesome!
Perl::Critic checks 
the code conform 
to PBP style or not
Benefit to analyze 
code by computer
He don’t grumble
He is 
inexhaustible
He don’t take a mistake
He is fast 
(in many cases)
And can automation
Cost of human: HIGH 
! 
Cost of computer: LOW
Cost of human: HIGH 
! 
Cost of computer: LOW 
Good!!
Got it.
But… 
If there is Perl::Critic, 
Is Perl::Lint don’t need?
Perl::Critic is awesome 
but a little slow
In large project, 
It takes 3 minutes 
to run only Perl::Critic
How do you spend in 
meantime?
Coffee? 
How do you spend in 
meantime?
Coffee? 
Chat? 
How do you spend in 
meantime?
Coffee? 
Nap? Chat? 
How do you spend in 
meantime?
Coffee? 
Swing Copters? 
Nap? Chat? 
How do you spend in 
meantime?
Life is too short, 
so let’s accelerate!!
Rate [num/sec] 
100 
75 
50 
25 
0 
97 
18 
Perl::Critic Perl::Lint
Rate [num/sec] 
100 
75 
About 50 
400% increase 
25 
0 
97 
18 
Perl::Critic Perl::Lint
Yeah!!!! 
I'll show you all my tricks
A little break
Background that led to 
the development
This project receive 
TPF grant
Do you know 
TPF grant?
Nozaki-san and 
Maki-san (@lestrrat-san) 
are people in a high 
position of TPF grant
Maki-san「日本人がトップになっ 
たのに日本から1つもProposal出な 
いのちょっとアレじゃない?」▼ 
me「そうですなあ」▼ 
Maki-san「moznion出してよ」▼ 
me「!!!!!」▼
Time flies everything 
goes…
Perl::Lint!!!!
Let’s apply!!!
Return to our subject…
How do we do 
static analyzing for Perl?
Enough!
Joke :p
Two major methods 
- Evaluate Token 
- Evaluate AST
Two major methods 
- Evaluate Token 
- Evaluate AST
Tools - PPI - Compiler::Lexer
Tools - PPI - Compiler::Lexer
What is Compiler::Lexer?
*Very Fast* tokenizer 
made of C++
Compiler::Lexer is fast 
⇛ Perl::Lint is fast!
And others: 
Compiler::Parser, 
C::CodeGenerator::LLVM, 
etc… 
@goccy54++
Example of tokens 
that is generated by 
Compiler::Lexer
my $foo;
my $foo;
Points
Use these tokens 
to analyze
Enough!
Architecture of Perl::Lint
Top Level 
+args 
+site_policies 
+lint 
+lint_string 
Policies 
+evaluate 
1 
Filters 
+filter 
1 
1 .. * 
1 .. *
Simple and Easy!
Policies
Each policies are 
isolated
Easy to make 
your own policy
Samples
*** CAUTION *** 
A lot of bad 
code are here. 
Close your eyes.
@P::L::P::Miscellanea::ProhibitTies
@P::L::P::Miscellanea::ProhibitTies 
Check type
@P::L::P::Miscellanea::ProhibitTies 
Check data
アッ
Feature of 
Implementation 
and Bad Know-hows
Use C-Style for()
Use C-Style for() 
But PBP prohibit it!!
Use List::Util::any 
instead of grep
Don’t use regex, 
compare by eq in series
Or use hash 
…
Function calling 
is almost gone.
Use simple parts 
e.g. raw-bless, POPO
Filtering mechanism
Perl::Critic’s 
default rule system 
is a bit difficult…
Yes, I know, 
perlcriticrc can 
adjust them. 
But too much hustle
Perl::Lint checks 
the all of policies 
as default
And you can filter 
any policies as you like
Filter by `ignore`
Filter by `filter`
Yes, of course 
you can deny 
the all of policies :)
You can define 
your own filter
e.g.
And Perl::Lint provides 
default policies
For Perl::Critic users ;)
These are features 
of Perl::Lint
But installation is such a 
hassle!
Perl::Lint 
Playground 
http://perl-lint.moznion.net
You can try!
Meaning to publish 
Playground
It makes easy to get 
feedback
Motivation ➚
Publish the Playground 
is looking good!
Future works
Implement the all of 
policies…
## no lint
Module for testing 
(Like a Test::Perl::Critic)
Cooperate with GitHub 
(Like a Coveralls)
Inject the result 
into code as TODO 
comment 
(inspired by rubocop)
As you see, 
Perl::Lint is 
under development
SEGV, ABRT, etc…
I’m looking for 
contributors!
DEMO
Any Questions?

Perl::Lint - Yet Another Perl Source Code Linter