SlideShare a Scribd company logo
Introducing static code analysis
into our project has made code
reviews more efficient
Noël
NOV 27, 2020
@English Night vol.5
presented by GAOGAO Inc.
Introduction
<?php
/** ellipsis */
class Noel extends BackEnd implements Engineer
{
use Laravel, AWSCloudFormation;
public function performCodeReviews(): object
{/** ellipsis */}
public function focusOnNodeJSInPrivate(): void
{/** ellipsis */}
}
Dynamic Analysis
Static Analysis
Dynamic Analysis
Static Analysis
Works well so far
Never introduced
Dynamic Analysis
PHPUnit on CircleCI
Deploy to
ECS
Trigger Build
Push doc
to Repo
Pull
Request
Pull
Request
On the other hand...
Whenever I was working on
the code review on Github
there would be
a bunch of conflicts due to subtle
differences, which include
- indent size differences in the same line
- single quote or double quote
- the differences with the number of whitespaces
How much time can we spare
fixing these nonsense differences ?
More than 10 file
conflicts per PR..!?
Come on !!!!!
We want to focus on thinking about
whether the architecture, the algorithm,
and the naming
are optimized or not.
More than 10 file
conflicts per PR..!?
Come on !!!!!
The stunning solution
has come to us!
Got inspired when assigned
for Vue.js projects
LinterFormatter
Awesome
Developer Experience
Spare yourself the extra time it takes to
indent the code differences.
Let’s move it onto Laravel
・Larastan
・PHPStan (2016)
・PHP CS
・PHP MD (2010)
Linter Candidates
・PHP-CS-Fixer
・Prettier PHP Plugin
Formatter Candidates
Let’s move it onto Laravel
Linter / Larastan
Formatter / PHP-CS-Fixer
Why?
Larastan
As for every tool except Larastan,
the parts used Facade and Magick Methods
automatically cause errors even if they
don’t have any problems on Laravel App.
Reasons why we had chosen
these two packages
Reasons why we had chosen
these two packages
Let us care for dependency managers by
simply only using composer and not using
npm or yarn for PHP environment.
PHP-CS-Fixer
Settings
{
// ellipsis
"require-dev": {
// ellipsis
"friendsofphp/php-cs-fixer": "^2.16",
"nunomaduro/larastan": "^0.6.9",
"phpunit/phpunit": "^8.0",
// ellipsis
},
// ellipsis
}
composer.json
Larastan
PHP-CS-Fixer
Notions
Fatal error: Allowed memory size of 1610612736 bytes exhausted
Standard Error
Larastan
services:
php-fpm:
build: // ellipsis
volumes: // ellipsis
environment:
- COMPOSER_MEMORY_LIMIT= -1 /usr/bin/composer
docker-compose.yml
1,610,612,736 bytes = 1.5 * (2^30) GB
PHP can use 128MB memory with default per script,
Composer can internally increase the memory_limit to 1.5 GB.
Explaination Larastan
・the discrepancy of type
・the discrepancy of PHPDoc
・the undefined methods / variables
etc...
Benefits Larastan
・Putting more emphasis on
writing phpdoc than before
・Becoming conscious of the type of
arguments, return values,
(Making up for the lack of PHP)
Results
root@dbdd4a531fc8:/var/www/html# ./vendor/bin/phpstan
analyse
Note: Using configuration file /var/www/html/phpstan.neon.
26/26 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
[OK] No errors
root@dbdd4a531fc8:/var/www/html#
app container
Larastan
Rules PHP-CS-Fixer
https://mlocati.github.io/php-cs-fixer-configurator/#version:2.16
Default
rule set (v2.16)
PhpCsFixerConfig::create()
->setRiskyAllowed(true)
->setRules([
'@PHP56Migration' => true,
'@PHPUnit60Migration:risky' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'header_comment' => ['header' => $header],
'list_syntax' => ['syntax' => 'long'],
])
->setFinder($finder)
;
PHP-CS-Fixer
Results
root@dbdd4a531fc8:/var/www/html# ./vendor/bin/php-cs-fixer
fix --dry-run ./app
Loaded config default.
Using cache file ".php_cs.cache".
1) app/Http/Controllers/PhotoController.php
2) app/Photo.php
3) app/User.php
Checked all files in 0.214 seconds, 14.000 MB memory used
app container
PHP-CS-Fixer
Default
rule set (v2.16)
PHP-CS-Fixer
// ellipsis
'@PHP56Migration' => true,
'@PHPUnit60Migration:risky' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'header_comment' => ['header' => $header],
'list_syntax' => ['syntax' => 'long'],
// ellipsis
PHP-CS-FixerCustomize rule
set example
return PhpCsFixerConfig::create()
->setRiskyAllowed(false)
/* indent_size */
->setIndent(" ")
->setRules([])
->setFinder();
// For example
'@PSR2' => true,
'concat_space' => ['spacing' => 'one'],
A peaceful time of
code review
has come at last
Whenever I was working on
the code review on Github
Just important conflicts
come up !
We can concentrate on reviewing more efficiently.
I’m supposed to post this as an
article in the Laravel Advent
Calendar on Qiita in Japanese
All free images credited by:
https://publicdomainq.net/tag/%E8%83%8C%E6%99%AF%EF%BC%88%E3%82%A4%E3%83%A9
%E3%82%B9%E3%83%88%EF%BC%89/?ssort=_ratings_score-pm&sdir=desc
https://iconbu.com/illust/3484
http://creativefreaks.net/%E3%83%95%E3%83%AA%E3%83%BC%E7%B4%A0%E6%9D%90/
https://www.stockio.com/free-vector/data-analysis-2
https://www.vectorstock.com/royalty-free-vector/young-man-worried-avatar-character-icon-vector-302
65520
Thanks a bunch
for listening up
to this Lightning Talk.
@ingenieur_noel

More Related Content

What's hot

Minko - Build WebGL applications with C++ and asm.js
Minko - Build WebGL applications with C++ and asm.jsMinko - Build WebGL applications with C++ and asm.js
Minko - Build WebGL applications with C++ and asm.js
Minko3D
 

What's hot (20)

Introduction to protocol buffer
Introduction to protocol bufferIntroduction to protocol buffer
Introduction to protocol buffer
 
Php internal architecture
Php internal architecturePhp internal architecture
Php internal architecture
 
Data Management and Streaming Strategies in Drakensang Online
Data Management and Streaming Strategies in Drakensang OnlineData Management and Streaming Strategies in Drakensang Online
Data Management and Streaming Strategies in Drakensang Online
 
Pc54
Pc54Pc54
Pc54
 
Multiplatform C++ on the Web with Emscripten
Multiplatform C++ on the Web with EmscriptenMultiplatform C++ on the Web with Emscripten
Multiplatform C++ on the Web with Emscripten
 
Docker at Cloud9 IDE
Docker at Cloud9 IDEDocker at Cloud9 IDE
Docker at Cloud9 IDE
 
Conscious Coupling
Conscious CouplingConscious Coupling
Conscious Coupling
 
Developing high-performance network servers in Lisp
Developing high-performance network servers in LispDeveloping high-performance network servers in Lisp
Developing high-performance network servers in Lisp
 
Porting and Maintaining your C++ Game on Android without losing your mind
Porting and Maintaining your C++ Game on Android without losing your mindPorting and Maintaining your C++ Game on Android without losing your mind
Porting and Maintaining your C++ Game on Android without losing your mind
 
Statyczna analiza kodu PHP
Statyczna analiza kodu PHPStatyczna analiza kodu PHP
Statyczna analiza kodu PHP
 
Return on Ignite 2019: Azure, .NET, A.I. & Data
Return on Ignite 2019: Azure, .NET, A.I. & DataReturn on Ignite 2019: Azure, .NET, A.I. & Data
Return on Ignite 2019: Azure, .NET, A.I. & Data
 
Droidcon Summary 2021
Droidcon Summary 2021Droidcon Summary 2021
Droidcon Summary 2021
 
Ways to generate PDF from Python Web applications, Gaël Le Mignot
Ways to generate PDF from Python Web applications, Gaël Le MignotWays to generate PDF from Python Web applications, Gaël Le Mignot
Ways to generate PDF from Python Web applications, Gaël Le Mignot
 
GCC Compiler as a Performance Testing tool for C programs
GCC Compiler as a Performance Testing tool for C programsGCC Compiler as a Performance Testing tool for C programs
GCC Compiler as a Performance Testing tool for C programs
 
Minko - Build WebGL applications with C++ and asm.js
Minko - Build WebGL applications with C++ and asm.jsMinko - Build WebGL applications with C++ and asm.js
Minko - Build WebGL applications with C++ and asm.js
 
20151117 IoT를 위한 서비스 구성과 개발
20151117 IoT를 위한 서비스 구성과 개발20151117 IoT를 위한 서비스 구성과 개발
20151117 IoT를 위한 서비스 구성과 개발
 
Bdd Net Frameworks
Bdd Net FrameworksBdd Net Frameworks
Bdd Net Frameworks
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tiger
 
IL2CPP: Debugging and Profiling
IL2CPP: Debugging and ProfilingIL2CPP: Debugging and Profiling
IL2CPP: Debugging and Profiling
 
Run Go applications on Pico using TinyGo
Run Go applications on Pico using TinyGo Run Go applications on Pico using TinyGo
Run Go applications on Pico using TinyGo
 

Similar to Fix: static code analysis into our project

Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
tutorialsruby
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
tutorialsruby
 
Easy deployment & management of cloud apps
Easy deployment & management of cloud appsEasy deployment & management of cloud apps
Easy deployment & management of cloud apps
David Cunningham
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opm
isnull
 

Similar to Fix: static code analysis into our project (20)

Scaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesScaleable PHP Applications in Kubernetes
Scaleable PHP Applications in Kubernetes
 
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
 
Essential Tools for Modern PHP
Essential Tools for Modern PHPEssential Tools for Modern PHP
Essential Tools for Modern PHP
 
Composer Helpdesk
Composer HelpdeskComposer Helpdesk
Composer Helpdesk
 
Build optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerBuild optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and Docker
 
OSDC 2017 - Casey Callendrello -The evolution of the Container Network Interface
OSDC 2017 - Casey Callendrello -The evolution of the Container Network InterfaceOSDC 2017 - Casey Callendrello -The evolution of the Container Network Interface
OSDC 2017 - Casey Callendrello -The evolution of the Container Network Interface
 
OSDC 2017 | The evolution of the Container Network Interface by Casey Callend...
OSDC 2017 | The evolution of the Container Network Interface by Casey Callend...OSDC 2017 | The evolution of the Container Network Interface by Casey Callend...
OSDC 2017 | The evolution of the Container Network Interface by Casey Callend...
 
TestUpload
TestUploadTestUpload
TestUpload
 
Php Development With Eclipde PDT
Php Development With Eclipde PDTPhp Development With Eclipde PDT
Php Development With Eclipde PDT
 
Start using PHP 7
Start using PHP 7Start using PHP 7
Start using PHP 7
 
PHP Internals
PHP InternalsPHP Internals
PHP Internals
 
Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)
 
Easy deployment & management of cloud apps
Easy deployment & management of cloud appsEasy deployment & management of cloud apps
Easy deployment & management of cloud apps
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opm
 
GDB - a tough nut to crack: only a few bugs found by PVS-Studio
GDB - a tough nut to crack: only a few bugs found by PVS-StudioGDB - a tough nut to crack: only a few bugs found by PVS-Studio
GDB - a tough nut to crack: only a few bugs found by PVS-Studio
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Hyperion EPM APIs - Added value from HFM, Workspace, FDM, Smartview, and Shar...
Hyperion EPM APIs - Added value from HFM, Workspace, FDM, Smartview, and Shar...Hyperion EPM APIs - Added value from HFM, Workspace, FDM, Smartview, and Shar...
Hyperion EPM APIs - Added value from HFM, Workspace, FDM, Smartview, and Shar...
 
PHP Development Tools 2.0 - Success Story
PHP Development Tools 2.0 - Success StoryPHP Development Tools 2.0 - Success Story
PHP Development Tools 2.0 - Success Story
 

Recently uploaded

Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
Kamal Acharya
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
Kamal Acharya
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 

Recently uploaded (20)

BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge
 
Toll tax management system project report..pdf
Toll tax management system project report..pdfToll tax management system project report..pdf
Toll tax management system project report..pdf
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docxThe Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
fundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionfundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projection
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf
 
fluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answerfluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answer
 

Fix: static code analysis into our project