SlideShare a Scribd company logo
1 of 33
Download to read offline
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 | 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...
 
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
 
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

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 

Recently uploaded (20)

DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 

Fix: static code analysis into our project