Your (coding) standards matter

19
YOUR (CODING) STANDARDS MATTER

description

My short talk at the berlin php user group about phpmd and phpcs..

Transcript of Your (coding) standards matter

Page 1: Your (coding) standards matter

YOUR (CODING) STANDARDSMATTER

Page 2: Your (coding) standards matter

ABOUT MESoftware EngineerPHP since 11 yearsCICleanCodeDevOpsTDDShippingBullet points

Page 3: Your (coding) standards matter

WORKING FOR

ResearchGate gives science back to the people who make it happen.

We help researchers build reputation and accelerate scientificprogress.

On their terms.

Page 4: Your (coding) standards matter

GET IN TOUCH

stackoverflow:

Twitter: @_ _edorian

G+ / Xing: Volker Dusch

IRC (freenode): edorian

Mail: [email protected]

Page 5: Your (coding) standards matter

WHY I AM HERE TODAY

Page 6: Your (coding) standards matter

SO WHAT IS THIS TALK ABOUT?

Page 7: Your (coding) standards matter

PHP!

Page 8: Your (coding) standards matter

CODING GUIDELINES!

Page 9: Your (coding) standards matter

THE TOOLSPHP MESS DETECTOR

Complexity, long term maintainability, keeps you honest whendesigning

PHP CODE SNIFFERCode formatting, simple coding errors, helps you stay consistent in a

team

Page 10: Your (coding) standards matter

PURPOSE (IMHO)PHPMD is for naming, size, complexity and all the hard to changethings

PHPCS is for whitespace and all the things that are easy to fix

Page 11: Your (coding) standards matter

HOW TO MAKE USE OF THEMConfigure rules that match the way you are working!

It's easier than it feels!

Page 12: Your (coding) standards matter

WHAT ABOUT STANDARDS?PHPMD: Use all the rules, they are reasonable. Configure them later

PHPCS: Use PSR2. Replace things if they don't work for your team

Page 13: Your (coding) standards matter

INSTALLING{ "require": { "squizlabs/php_codesniffer": "*", "phpmd/phpmd": "*" }, "config": { "bin-dir": "/usr/local/bin/" }}

Page 14: Your (coding) standards matter

DEMOLet's create ruleset files for both of the tools :)

http://edorian.github.io/php-coding-standard-generator/#phpmd

Page 15: Your (coding) standards matter

COMMANDS USEDUse most of PHPMDs rules:

Use your custom ruleset:

Use PSR2 with PHPCS:

Use your own PHPCS rules:

phpmd source text codesize,unusedcode,naming,design

phpmd source text phpmd.xml

phpcs --standard=PSR2 source/

phpcs --standard=phpcs.xml source/

Page 16: Your (coding) standards matter

CONTINUOUS INTEGRATIONReal world usage along a projects lifecylce

Pretty graphs in Jenkins!Fail your travis ci build on phpcs errors?Fail your travis ci build on phpmd errors???

Page 17: Your (coding) standards matter

THANK YOU!

Page 18: Your (coding) standards matter

QUESTIONS?

GET IN TOUCH

stackoverflow:

Twitter: @_ _edorian

G+ / Xing: Volker Dusch

IRC (freenode): edorian

Mail: [email protected]

Page 19: Your (coding) standards matter