Kang-min Liu
LINE Fukuoka
β π γ
Kang-min Liu / εεΊ·ζ°
Twitter: @gugod
Perl
Server-side dev
3 frontend devs
4 server-side devs
frontend: angularjs β vue.js
server: perl, mysql, nginx, memcached
git push
β CIGain understandings on
Readibility > Correctness
Maintainability > Optimized solution
Unconventional
Quirks, magic, shenanigans
Mismatching style
Random "code waste"
Can I understand this new piece code
written by my teammate
by just reading it ?
understandable code βββ maintainable code
perl -c
Perl::Critic / Perl::Lint
CPAN::Audit
eslint https://eslint.org/
CI
Continuous Testing (Test::Continuous)
All pair testing
Mutation Test (Devel::Mutation)
fuzzing
$EDITOR
Critique Perl source code for best-practices.
Perl::Critic is a static code analysis system for the Perl programming language. Perl::Critic is available as a source-code distribution on CPAN. It comes with a commandline tool, perlcritic, which can check Perl source code files and report on the code quality therein. Perl::Critic has an extensible architecture that allows the programmer to choose from many "policies" which enforce different Perl programming styles and tastes.
Online Demo
Bad: too much work.
if ( grep { $_->can_code() } @people ) {
say "Developers!";
}
Better: just enough amount of work
use List::Util 'first';
if ( first { $_->can_code() } @people ) {
say "Developers!";
}
my $is_product = $object =~ m/
\A (?: sticker | theme | emoji ) \z
/xms;
my $is_product = $object eq 'sticker' ||
$object eq 'theme' ||
$object eq 'emoji';
my $is_product = first { $object eq $_ } (
'sticker', 'theme', 'emoji'
);
use Quantum::Superposition 'any';
my $is_product = $object eq any('sticker', 'theme', 'emoji');
# perl6
my $is_product = $object eq 'sticker'|'theme'| 'emoji';
do_this();;
Extra semi-colons / empty statements.Jenkins
Travis
CircleCI
Drone CI
Reviewdog γι£Όγ£γ¦γ³γΌγγ¬γγ₯γΌγιηΊγζΉεγγΎγγγ
http://haya14busa.com/reviewdog/
Let CI do some code reviews
# .reviewdog.yml
runner:
perlcritic:
cmd: perlcritic --profile .perlcriticrc --verbose 1 *.psgi lib/
errorformat:
- "%f:%l:%c:%m"
name: perlcritic
Scan dependency graph for
known vulnerabilities
Mutation Testing
Original
if (a && b) {
do_this();
}
Mutant
if (a || b) {
do_this();
}
π "Thank you for listening"; π€