SlideShare a Scribd company logo
Static Code Analysis
for Perl
@moznion
Taiki Kawakami
a.k.a @moznion
Sever side engineer
(Java and Perl)
Author of
- Perl::Lint
- go-setlock
Taiki Kawakami
a.k.a @moznion
Sever side engineer
(Java and Perl)
Author of
- Perl::Lint
- go-setlock
Taiki Kawakami
a.k.a @moznion
Sever side engineer
(Java and Perl)
Author of
- Perl::Lint
- go-setlock
Fundamental of
Static Analysis
Static Analysis
A method of analysis
source code WITHOUT
execution
Static Analysis
Example of advantages:
- Easy to detect
- unused vars
- irregular coding styles
- Analyze dependencies
between modules/classes
Static Analysis
Example of advantages:
- Easy to detect
- unused vars
- irregular coding styles
- Analyze dependencies
between modules/classes
BORING!
Static Analysis
Example of advantages:
- Easy to detect
- unused vars
- irregular coding styles
- Analyze dependencies
between modules/classes
Difficult…
Let's Exercise
This code has 5 traps
This code has 5 traps
This code has 5 traps
This code has 5 traps
This code has 5 traps
This code has 5 traps
It was fun?
This is ridiculous
code ceview
Probably
human overlooks
We should focus on
advanced topic
on code review
How?
It is necessary
clean code
Destroy these
Be maintainable
code!
Make computer
analyze them!
How to make
static analyzer?
Pre-Process
Lexical Analyze
Syntactic Analyze
Source code (String)
Result
Analyze
Pre-Process
Lexical Analyze
Syntactic Analyze
Source code (String)
Result
Analyze
Static analysis for perl
PPI::Tokenizer
Pre-Process
Lexical Analyze
Syntactic Analyze
Source code (String)
Result
Analyze
PPI::Document
Provides
PDOM
Structure
Pre-Process
Lexical Analyze
Syntactic Analyze
Source code (String)
Result
Analyze
“Analyze” phase
checks code with
using AST and tokens
in accordance with
rules
Method of some
languages are
different;
they look byte code
(e.g. Java:findbugs)
Perl::Critic
Perl::Critic is the
great tool!
Perl::Critic checks
the code conform
to PBP style or not
Perl::Critic uses
PPI as a Lexer
and Parser
Pre-Process
Lexical Analyze
Syntactic Analyze
Source code (String)
Result
Analyze
PPI
Perl::Lint
Perl::Lint is a
yet another static
analyser for perl
This project
supported by TPF
Perl::Critic is enough.
Why Perl::Lint?
I want to make it
faster!!!
Mechanism of
Perl::Lint
Pre-Process
Lexical Analyze
Syntactic Analyze
Source code (String)
Result
Analyze
Regex
Compiler::Lexer
Perl::Lint::Policy
Pre-Process
Lexical Analyze
Syntactic Analyze
Source code (String)
Result
Analyze
Regex
Compiler::Lexer
Perl::Lint::Policy
Pre-Processing
## no lint
## no lint
To retrieve this
Find where (what line) is
“## no lint” by regex
Find where (what line) is
“## no lint” by regex
And compare between
line number of “## no lint”
and violation’s one,
if match them, ignore form result!
Compiler::Lexer can retrieve
comments by verbose mode,
but it makes slower about 4 times😢
So using regex
Pre-Process
Lexical Analyze
Syntactic Analyze
Source code (String)
Result
Analyze
Regex
Compiler::Lexer
Perl::Lint::Policy
Tokenize source code
by Compiler::Lexer
Static analysis for perl
Static analysis for perl
Compiler::Lexer made of C++
Really fast!
Stable (nowadays)
But…
Static analysis for perl
Perl-5.22………………
Pre-Process
Lexical Analyze
Syntactic Analyze
Source code (String)
Result
Analyze
Regex
Compiler::Lexer
Perl::Lint::Policy
Compiler::Parser exists,
but that doesn’t work as expected
Pre-Process
Lexical Analyze
Syntactic Analyze
Source code (String)
Result
Analyze
Regex
Compiler::Lexer
Perl::Lint::Policy
Read token list sequentially
and evaluate them.
Each policies are responsible
for those.
Like this
Like this
Like this…
And it is necessary to analyze
contents of regex (m/here!/)
Using Regexp::Lexer
This is a module to tokenize regex
Example;
Each policies are independent,
so easy to write new policy
(You can write your own policy)
Easy and Simple:
Scan tokens and write
validation processing according to
scanned token sequentially
Perl::Lint has filter system
Perl::Lint executes all of the policies
by default.
Write a black list to ignore
any policy.
Current Status
Almost policies of Perl::Critic
are available on Perl::Lint
現状のステータス
Documentation is lacked…
Application
Test::Perl::Lint
Testing module like a
Test::Perl::Critic
Perl::Lint::Git
Connect git and Perl::Lint to blame the right people for
violations.Connect git and Perl::Lint to blame
the right people for violations.
Future works
I should have written a parser…
Compiler::Lexer::PP (?)
Enhance documentation
Bug fix
Support new perl notations
Support code climate
CHEATING:
Run each policies with
pre-fork model
Any Q?
(If I can answer…)

More Related Content

What's hot (20)

PPT
Packer Genetics: The selfish code
jduart
 
PDF
ShaREing Is Caring
sporst
 
PDF
GooglePropsal
Ahmed Abd El-Mawgood
 
PDF
ITB2019 Real World Scenarios for Modern CFML - Nolan Erck
Ortus Solutions, Corp
 
PDF
The why and how of moving to php 8
Wim Godden
 
PDF
The why and how of moving to php 7
Wim Godden
 
PDF
Type Profiler: Ambitious Type Inference for Ruby 3
mametter
 
PDF
Asynchronous I/O in Python 3
Feihong Hsu
 
PDF
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
mametter
 
PDF
Implementation of TypeGraphQL with Apollo Server
Fabien Pasquet
 
PDF
Python master class 2
Chathuranga Bandara
 
PPTX
An Introduction to ANTLR
Morteza Zakeri
 
PPTX
Code samples that actually compile - Clare Macrae
Clare Macrae
 
PDF
Python master class part 1
Chathuranga Bandara
 
PPTX
Introduction about Python by JanBask Training
JanBask Training
 
PPTX
Python Tutorial for Beginner
rajkamaltibacademy
 
PDF
Erlang - Concurrent Language for Concurrent World
Zvi Avraham
 
PDF
F# for Scala developers
Alfonso Garcia-Caro
 
PDF
From V8 to Modern Compilers
Min-Yih Hsu
 
PPTX
Kotlin L → ∞
Abdellah SELASSI
 
Packer Genetics: The selfish code
jduart
 
ShaREing Is Caring
sporst
 
GooglePropsal
Ahmed Abd El-Mawgood
 
ITB2019 Real World Scenarios for Modern CFML - Nolan Erck
Ortus Solutions, Corp
 
The why and how of moving to php 8
Wim Godden
 
The why and how of moving to php 7
Wim Godden
 
Type Profiler: Ambitious Type Inference for Ruby 3
mametter
 
Asynchronous I/O in Python 3
Feihong Hsu
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
mametter
 
Implementation of TypeGraphQL with Apollo Server
Fabien Pasquet
 
Python master class 2
Chathuranga Bandara
 
An Introduction to ANTLR
Morteza Zakeri
 
Code samples that actually compile - Clare Macrae
Clare Macrae
 
Python master class part 1
Chathuranga Bandara
 
Introduction about Python by JanBask Training
JanBask Training
 
Python Tutorial for Beginner
rajkamaltibacademy
 
Erlang - Concurrent Language for Concurrent World
Zvi Avraham
 
F# for Scala developers
Alfonso Garcia-Caro
 
From V8 to Modern Compilers
Min-Yih Hsu
 
Kotlin L → ∞
Abdellah SELASSI
 

Viewers also liked (6)

PDF
Namba.pm #0
moznion
 
PPTX
Redux: server side rendering and hot code reload for single-page applications
Alex Bumbu
 
PDF
Yet Another Perl Cooking
moznion
 
PDF
Talking About Japanese Area Code of Phone
moznion
 
PDF
Jesque robust-worker-pool
moznion
 
PDF
命名の話
moznion
 
Namba.pm #0
moznion
 
Redux: server side rendering and hot code reload for single-page applications
Alex Bumbu
 
Yet Another Perl Cooking
moznion
 
Talking About Japanese Area Code of Phone
moznion
 
Jesque robust-worker-pool
moznion
 
命名の話
moznion
 
Ad

Similar to Static analysis for perl (20)

PDF
Review unknown code with static analysis Zend con 2017
Damien Seguy
 
PPTX
Listen afup 2010
Gabriele Santini
 
PPTX
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
goccy
 
PDF
Perl 5.10
acme
 
ODP
YAPC::NA 2007 - An Introduction To Perl Critic
joshua.mcadams
 
PDF
Php engine
julien pauli
 
PPT
Static Code Analysis and AutoLint
Leander Hasty
 
ODP
Advanced Perl Techniques
Dave Cross
 
PPTX
Static Code Analysis PHP[tek] 2023
Scott Keck-Warren
 
PPT
SS & CD Module 3
ShwetaNirmanik
 
PPT
Module 2
ShwetaNirmanik
 
PDF
What's new in Perl 5.12?
acme
 
PDF
20 PHP Static Analysis and Documentation Generators #burningkeyboards
Denis Ristic
 
PDF
Preparing code for Php 7 workshop
Damien Seguy
 
PDF
Perl Critic In Depth
Jeffrey Ryan Thalhammer
 
PDF
The $path to knowledge: What little it take to unit-test Perl.
Workhorse Computing
 
PDF
PL/Perl - New Features in PostgreSQL 9.0 201012
Tim Bunce
 
PPTX
1._Introduction_.pptx
Anbarasan Radhakrishnan R
 
PPTX
Error-Handling-and-Recovery-in-Compilers.pptx
haassi136qva
 
PDF
Automatic Comment Analysis
Jerome DERN
 
Review unknown code with static analysis Zend con 2017
Damien Seguy
 
Listen afup 2010
Gabriele Santini
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
goccy
 
Perl 5.10
acme
 
YAPC::NA 2007 - An Introduction To Perl Critic
joshua.mcadams
 
Php engine
julien pauli
 
Static Code Analysis and AutoLint
Leander Hasty
 
Advanced Perl Techniques
Dave Cross
 
Static Code Analysis PHP[tek] 2023
Scott Keck-Warren
 
SS & CD Module 3
ShwetaNirmanik
 
Module 2
ShwetaNirmanik
 
What's new in Perl 5.12?
acme
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
Denis Ristic
 
Preparing code for Php 7 workshop
Damien Seguy
 
Perl Critic In Depth
Jeffrey Ryan Thalhammer
 
The $path to knowledge: What little it take to unit-test Perl.
Workhorse Computing
 
PL/Perl - New Features in PostgreSQL 9.0 201012
Tim Bunce
 
1._Introduction_.pptx
Anbarasan Radhakrishnan R
 
Error-Handling-and-Recovery-in-Compilers.pptx
haassi136qva
 
Automatic Comment Analysis
Jerome DERN
 
Ad

More from moznion (20)

PDF
Hachioji persec
moznion
 
PDF
Inner world of Perl::Lint
moznion
 
PDF
Hachiojipm 44
moznion
 
PDF
Perl::Lint is over, for the present
moznion
 
PDF
Hachioji pm 41
moznion
 
PDF
Hachioji.pm 40
moznion
 
PDF
Hachioji.pm #39
moznion
 
PDF
Hachioji.pm 38
moznion
 
PDF
Hokkaido.pm #11
moznion
 
PDF
Hachiojipm 36
moznion
 
PDF
Plack::Request with Encoding
moznion
 
PDF
YAPC::Asia 2013 - CPAN Testers Reports の情報を上手に使う
moznion
 
PDF
Net stalking with-lastfm
moznion
 
PDF
Takao.mt 2013
moznion
 
PDF
Perl beginners #08
moznion
 
PDF
Hachiojipm 28
moznion
 
PDF
Hachiojipm 26
moznion
 
PDF
Hachioji pm 25
moznion
 
PDF
Hokkaido pm 8 LT
moznion
 
KEY
You Can Be a CPAN Auhor
moznion
 
Hachioji persec
moznion
 
Inner world of Perl::Lint
moznion
 
Hachiojipm 44
moznion
 
Perl::Lint is over, for the present
moznion
 
Hachioji pm 41
moznion
 
Hachioji.pm 40
moznion
 
Hachioji.pm #39
moznion
 
Hachioji.pm 38
moznion
 
Hokkaido.pm #11
moznion
 
Hachiojipm 36
moznion
 
Plack::Request with Encoding
moznion
 
YAPC::Asia 2013 - CPAN Testers Reports の情報を上手に使う
moznion
 
Net stalking with-lastfm
moznion
 
Takao.mt 2013
moznion
 
Perl beginners #08
moznion
 
Hachiojipm 28
moznion
 
Hachiojipm 26
moznion
 
Hachioji pm 25
moznion
 
Hokkaido pm 8 LT
moznion
 
You Can Be a CPAN Auhor
moznion
 

Recently uploaded (20)

PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 

Static analysis for perl