Con$nuous	  QA Michelangelo	  van	  Dam          Macq	  NV
Michelangelo	  van	  Dam•   independent	  contractor•   president	  PHPBenelux•   conference	  speaker•   community	  anim...
Overview• introduc$on• overview	  of	  tools• con$nuous	  integra$on  -­‐ interpreta$on	  of	  reports• roundup           ...
Introduc$on              4
What	  is	  quality	  assurance?• safeguarding	  source	  code• applica$on	  behaves	  as	  expected• bugs	  discovered	  ...
Why	  invest	  in	  QA?• improving	  development	  code• improving	  development	  team• saving	  $me	  in	  aJer	  sales	...
Overview	  of	  tools                          7
php	  -­‐l	  (lint)hPp://www.php.net/manual/en/features.commandline.op$ons.php   8
PHP	  Lint                                                                     TIP:	  pre-­‐commit	  hook• checks	  the	  ...
Execu$on           10
Parse	  error                 11
Fatal	  error                 12
PHPUnithPp://www.phpunit.de/manual/current/en/   13
PHPUnit• tes$ng	  framework	  for	  PHP	  projects• port	  of	  xUnit	  unit	  test	  frameworks  -­‐ compa$ble	  with	  J...
Execu$on	  of	  phpunit                            15
PHPDocumentor   hPp://www.phpdoc.org   16
PHPDoc• uses	  in	  code	  docblocks• parses	  API	  documenta$on                                    17
PHPDoc	  in	  ac$on                        18
API	  documenta$on                      19
PHP_CodeSniffer hPp://pear.php.net/package/PHP_CodeSniffer/   20
PHP_CodeSniffer• checks	  source	  code	  on	  coding	  standards• reports	  viola$ons	  on	  a	  given	  standard• ensures...
Report	  types• full:	  all	  details	  of	  viola$ons• summary:	  total	  of	  errors	  and	  warnings• source:	  targete...
Example	  Full	  reportFILE: /path/to/file.php----------------------------------------------------------------------------...
Example	  Summary	  reportPHP CODE SNIFFER REPORT SUMMARY-----------------------------------------------------------------...
Example	  Source	  reportPHP CODE SNIFFER VIOLATION SOURCE SUMMARY--------------------------------------------------------...
Example	  XML	  report<?xml version="1.0" encoding="UTF-8"?><phpcs version="1.3.0"> <file name="/path/to/file.php" errors=...
Example	  CheckStyle	  report<?xml version="1.0" encoding="UTF-8"?><checkstyle version="1.3.0"> <file name="/path/to/file....
Example	  CSV	  reportFile,Line,Column,Type,Message,Source,Severity"/path/to/file.php",111,83,error,"Arguments with defaul...
Example	  Blame	  reportPHP CODE SNIFFER SVN BLAME SUMMARY----------------------------------------------------------------...
Execu$on	  of	  phpcs                          30
PHPCPDhPps://github.com/sebas$anbergmann/phpcpd   31
Copy/Paste	  Detec$on                                              TIP:	  pre-­‐commit	  hook• detects	  duplicate	  or	  ...
phpcpd	  in	  ac$on                        33
Pdepend hPp://pdepend.org   34
Pdepend	  in	  ac$on                         35
pdepend	  pyramid                     36
• CYCLO:	  Cycloma$c	  Complexity• LOC:	  Lines	  of	  Code• NOM:	  Number	  of	  Methods• NOC:	  Number	  of	  Classes• N...
Cycloma$c	  Complexity• metric	  calcula$on• execu$on	  paths• independent	  control	  structures  -­‐ if,	  else,	  for,	...
Average	  Hierarchy	  HeightThe	  average	  of	  the	  maximum	  length	  from	  a	          root	  class	  to	  its	  dee...
pdepend	  pyramid                     40
pdepend-­‐graphgraph	  about	  stability:	  a	  mix	  between	  abstract	  and	  concrete	  classes                       ...
42
43
PHPMD	  (Mess	  detec$on)          hPp://phpmd.org     44
PHPMD• iden$fy	  poten$al	  problems	  in	  source	  code  -­‐   possible	  bugs  -­‐   subop$mal	  code  -­‐   overcompli...
PHPMD	  in	  ac$on                       46
PHPMD	  repor$ng                    47
PHP	  Code	  Browser hPps://github.com/mayflowergmbh/PHP_CodeBrowser   48
phpcb• code	  browser	  for	  php	  sources   -­‐ syntax	  highligh$ng   -­‐ colored	  error	  sec$ons• designed	  for	  u...
phpcb	  example                   50
PHPLOChPps://github.com/sebas$anbergmann/phploc   51
Lines	  of	  Code• calculates	  the	  size	  of	  a	  project   -­‐ gives	  a	  brief	  detail	  on	  quality	  of	  sourc...
phploc	  in	  ac$on                        53
Overview	  of	  outputphploc 1.6.1 by Sebastian Bergmann.Directories:                                      547Files:      ...
PhinghPp://www.phing.info/docs/guide/stable   55
Phing’s	  purpose• build	  tool	  wriPen	  in	  PHP   -­‐ comparable	  to	  Ant	  or	  make• used	  to	  automate	  build	...
57
Loca$on	  of	  build	  reports/path/to/project  /application  /library  /public  /tests  /build    /api                -> ...
Integra$on	  of	  tools                            59
Ini$al	  Phing	  build	  script<?xml version=”1.0” encoding=”UTF-8”?><!--  $Id: jenkins.xml 123 2011-06-08 07:00:00Z miche...
define	  our	  filesets<fileset id=”php-files” dir=”${project.basedir}”>    <include name=”**/*.php” />    <exclude name=”li...
clean	  build	  path<target name=”clean” description=”Clean build path”>    <delete dir=”${project.basedir}/build” />    <...
lint	  checking<target name=”phplint” description=”Syntax checking of code”>    <phplint haltonfailure=”true”>        <fil...
unit	  tes$ng<target name=”PHPUnit” description=”Running unit tests”>    <exec      passthru=”${passthru}”      dir=”${pro...
documenta$on<target name="phpdoc" description="Generate API documentation">    <phpdoc        title="${project.name} API D...
coding	  standards<target name="phpcs" description="Coding Standards Analysis">  <exec    passthru="${passthru}"    comman...
copy-­‐paste	  detec$on<target name="phpcpd" description="Copy/Paste detection">  <phpcpd>    <fileset refid="php-files"/>...
lines	  of	  code<target name="phploc" description="Generate phploc.csv">  <exec    passthru="${passthru}"    command="php...
code	  browser<target name="phpcb" description="Source code browser"  depends="phpunit, phpcs">  <exec    passthru="${pass...
depend	  metric	  calcula$ons<target name="pdepend" description="Calculate dependencies">  <exec    passthru="${passthru}"...
mess	  detec$on<target name="phpmd" description="Mess Detection">  <phpmd>    <fileset refid="php-files"/>    <formatter  ...
default	  target:	  build<target name="build" description="Start analyzing our app">  <phingCall target="clean" />  <phing...
phing	  in	  ac$on                       73
build	  all               74
phing	  usage• developers	  can	  run	  at	  call   -­‐ all	  targets   -­‐ specific	  targets	  (like	  unit	  tests,	  st...
perfect	  for	  CI	  !!!                              76
Con$nuous	  Integra$on                          77
Con$nuous	  Integra$on?• automated	  process• tools	  for	  code  -­‐   test  -­‐   document  -­‐   validate  -­‐   packag...
Jenkins-­‐CI  hPp://jenkins-­‐ci.org/   79
A	  project	  in	  CI                           80
Overview	  of	  reports• unit	  tests• code	  coverage• coding	  standards	  viola$ons• mess	  detec$on• dependency	  calc...
Unit	  Tests                82
83
84
85
Code	  Coverage                   86
87
88
89
CheckStyle             90
91
92
93
94
Mess	  detec$on                   95
96
97
98
99
100
101
Dependency	  Calcula$ons                            102
103
104
105
API	  Documenta$on                      106
107
108
Viola$ons            109
110
111
Round	  up              112
With	  CI• con$nuous	  inspec$on	  of	  code  -­‐ errors	  are	  detected	  early  -­‐ warnings	  are	  reported  -­‐ area...
CI	  &	  PHP• all	  the	  tools	     -­‐   to	  improve	  development	  skills   -­‐   to	  deliver	  quality	  code   -­‐...
Recommended	  reading• the	  PHP	  QA	  book  -­‐ Sebas$an	  Bergmann  -­‐ Stefan	  Priebsch                              ...
Recommended	  reading                                 Free• OOD	  Quality	  Metrics  -­‐ Robert	  Cecil	  Mar$n           ...
Sources	  and	  Code• slides:  hPp://www.slideshare.net/DragonBe• sources:  hPp://github.com/DragonBe/wingz• contact:  -­‐...
Upcoming SlideShare
Loading in...5
×

Continuous Quality Assurance

6,866

Published on

Presentation of all PHP tools you can use to improve QA on your projects, combining them in phing and use them in jenkins-ci

Published in: Technology
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,866
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
43
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide

Transcript of "Continuous Quality Assurance"

  1. 1. Con$nuous  QA Michelangelo  van  Dam Macq  NV
  2. 2. Michelangelo  van  Dam• independent  contractor• president  PHPBenelux• conference  speaker• community  animal ZEND FRAMEWORK PHP . 2
  3. 3. Overview• introduc$on• overview  of  tools• con$nuous  integra$on -­‐ interpreta$on  of  reports• roundup 3
  4. 4. Introduc$on 4
  5. 5. What  is  quality  assurance?• safeguarding  source  code• applica$on  behaves  as  expected• bugs  discovered  before  becoming  an  issue• tracking  progress  of  a  project -­‐ development  of  features -­‐ health  of  the  codebase 5
  6. 6. Why  invest  in  QA?• improving  development  code• improving  development  team• saving  $me  in  aJer  sales  maintenance• con$nuous  repor$ng• ready  to  deploy  code  (“builds”) 6
  7. 7. Overview  of  tools 7
  8. 8. php  -­‐l  (lint)hPp://www.php.net/manual/en/features.commandline.op$ons.php 8
  9. 9. PHP  Lint TIP:  pre-­‐commit  hook• checks  the  syntax  of  code• build  in  PHP  core• is  used  per  file -­‐ pre-­‐commit  hook  for  version  control  system -­‐ batch  processing  of  files• can  provide  reports -­‐ but  if  something  fails  -­‐>  the  build  fails 9
  10. 10. Execu$on 10
  11. 11. Parse  error 11
  12. 12. Fatal  error 12
  13. 13. PHPUnithPp://www.phpunit.de/manual/current/en/ 13
  14. 14. PHPUnit• tes$ng  framework  for  PHP  projects• port  of  xUnit  unit  test  frameworks -­‐ compa$ble  with  JUnit,  NUnit,  etc...• produces  generic  test  results -­‐ compa$ble  with  the  other  xUnit  frameworks• produces  code  coverage  reports -­‐ to  indicate  what  part  of  code  is  tested 14
  15. 15. Execu$on  of  phpunit 15
  16. 16. PHPDocumentor hPp://www.phpdoc.org 16
  17. 17. PHPDoc• uses  in  code  docblocks• parses  API  documenta$on 17
  18. 18. PHPDoc  in  ac$on 18
  19. 19. API  documenta$on 19
  20. 20. PHP_CodeSniffer hPp://pear.php.net/package/PHP_CodeSniffer/ 20
  21. 21. PHP_CodeSniffer• checks  source  code  on  coding  standards• reports  viola$ons  on  a  given  standard• ensures  a  consistent  way  code  is  wriPen -­‐ as  though  one  developer  wrote  all  the  code 21
  22. 22. Report  types• full:  all  details  of  viola$ons• summary:  total  of  errors  and  warnings• source:  targeted  sources  with  viola$ons• xml:  a  full  report  in  XML  format• checkstyle:  XML  report  on  style  viola$ons• csv:  a  full  report  in  CSV  format• emacs:  a  full  report  in  EMACS  format• blame:  a  list  of  responsible  viola$ng  devs 22
  23. 23. Example  Full  reportFILE: /path/to/file.php-------------------------------------------------------------------------------FOUND 2 ERROR(S) AND 4 WARNING(S) AFFECTING 4 LINE(S)------------------------------------------------------------------------------- 111 | ERROR | Arguments with default values must be at the end of the | | argument list 111 | WARNING | Line exceeds 80 characters; contains 88 characters 118 | WARNING | Line exceeds 80 characters; contains 89 characters 121 | WARNING | Line exceeds 80 characters; contains 84 characters 130 | WARNING | Line exceeds 80 characters; contains 94 characters 176 | ERROR | Spaces must be used to indent lines; tabs are not allowed------------------------------------------------------------------------------- 23
  24. 24. Example  Summary  reportPHP CODE SNIFFER REPORT SUMMARY--------------------------------------------------------------------------------FILE ERRORS WARNINGS--------------------------------------------------------------------------------/path/to/file.php 1 4--------------------------------------------------------------------------------A TOTAL OF 1 ERROR(S) AND 4 WARNING(S) WERE FOUND IN 1 FILE(S)-------------------------------------------------------------------------------- 24
  25. 25. Example  Source  reportPHP CODE SNIFFER VIOLATION SOURCE SUMMARY--------------------------------------------------------------------------------STANDARD CATEGORY SNIFF COUNT--------------------------------------------------------------------------------Generic Files Line length too long 4PEAR Functions Valid default value not at end 1--------------------------------------------------------------------------------A TOTAL OF 5 SNIFF VIOLATION(S) WERE FOUND IN 2 SOURCE(S)-------------------------------------------------------------------------------- Although specified Zend as coding standard, there’s a relation to underlying standards like PEAR and the General coding standards 25
  26. 26. Example  XML  report<?xml version="1.0" encoding="UTF-8"?><phpcs version="1.3.0"> <file name="/path/to/file.php" errors="1" warnings="4"> <error line="111" column="83" source="PEAR.Functions.ValidDefaultValue.NotAtEnd" s everity="5">Arguments with default values must be at the end of the argumentlist</error> <warning line="111" column="89" source="Generic.Files.LineLength.TooLong" severity="5">Line exceeds 80 characters; contains 88 characters</warning> <warning line="118" column="90" source="Generic.Files.LineLength.TooLong" severity="5">Line exceeds 80 characters; contains 89 characters</warning> <warning line="121" column="85" source="Generic.Files.LineLength.TooLong" severity="5">Line exceeds 80 characters; contains 84 characters</warning> <warning line="130" column="95" source="Generic.Files.LineLength.TooLong" severity="5">Line exceeds 80 characters; contains 94 characters</warning> </file></phpcs> 26
  27. 27. Example  CheckStyle  report<?xml version="1.0" encoding="UTF-8"?><checkstyle version="1.3.0"> <file name="/path/to/file.php"> <error line="111" column="83" severity="error" message="Arguments with default values must be at the end of the argument list" source="PEAR.Functions.ValidDefaultValue.NotAtEnd"/> <error line="111" column="89" severity="warning" message="Line exceeds 80 characters; contains 88 characters" source="Generic.Files.LineLength.TooLong"/> <error line="118" column="90" severity="warning" message="Line exceeds 80 characters; contains 89 characters" source="Generic.Files.LineLength.TooLong"/> <error line="121" column="85" severity="warning" message="Line exceeds 80 characters; contains 84 characters" source="Generic.Files.LineLength.TooLong"/> <error line="130" column="95" severity="warning" message="Line exceeds 80 characters; contains 94 characters" source="Generic.Files.LineLength.TooLong"/> </file></checkstyle> 27
  28. 28. Example  CSV  reportFile,Line,Column,Type,Message,Source,Severity"/path/to/file.php",111,83,error,"Arguments with default values must be at the endof the argument list",PEAR.Functions.ValidDefaultValue.NotAtEnd,5"/path/to/file.php",111,89,warning,"Line exceeds 80 characters; contains 88characters",Generic.Files.LineLength.TooLong,5"/path/to/file.php",118,90,warning,"Line exceeds 80 characters; contains 89characters",Generic.Files.LineLength.TooLong,5"/path/to/file.php",121,85,warning,"Line exceeds 80 characters; contains 84characters",Generic.Files.LineLength.TooLong,5"/path/to/file.php",130,95,warning,"Line exceeds 80 characters; contains 94characters",Generic.Files.LineLength.TooLong,5 28
  29. 29. Example  Blame  reportPHP CODE SNIFFER SVN BLAME SUMMARY--------------------------------------------------------------------------------AUTHOR (Author %) (Overall %) COUNT--------------------------------------------------------------------------------michelangelo (2.26) (100) 5--------------------------------------------------------------------------------A TOTAL OF 5 SNIFF VIOLATION(S) WERE COMMITTED BY 1 AUTHOR(S)-------------------------------------------------------------------------------- 29
  30. 30. Execu$on  of  phpcs 30
  31. 31. PHPCPDhPps://github.com/sebas$anbergmann/phpcpd 31
  32. 32. Copy/Paste  Detec$on TIP:  pre-­‐commit  hook• detects  duplicate  or  similar  lines  of  code -­‐ copied  code -­‐ code  that’s  similar 32
  33. 33. phpcpd  in  ac$on 33
  34. 34. Pdepend hPp://pdepend.org 34
  35. 35. Pdepend  in  ac$on 35
  36. 36. pdepend  pyramid 36
  37. 37. • CYCLO:  Cycloma$c  Complexity• LOC:  Lines  of  Code• NOM:  Number  of  Methods• NOC:  Number  of  Classes• NOP:  Number  of  Packages• AHH:  Average  Hierarchy  Height• ANDC:  Average  Number  of  Derived  Classes• FANOUT:  Number  of  Called  Classes• CALLS:  Number  of  Opera$on  Calls 37
  38. 38. Cycloma$c  Complexity• metric  calcula$on• execu$on  paths• independent  control  structures -­‐ if,  else,  for,  foreach,  switch  case,  while,  do,  …• within  a  single  method  or  func$on• more  info -­‐ hPp://en.wikipedia.org/wiki/Cycloma$c_complexity 38
  39. 39. Average  Hierarchy  HeightThe  average  of  the  maximum  length  from  a   root  class  to  its  deepest  subclass 39
  40. 40. pdepend  pyramid 40
  41. 41. pdepend-­‐graphgraph  about  stability:  a  mix  between  abstract  and  concrete  classes 41
  42. 42. 42
  43. 43. 43
  44. 44. PHPMD  (Mess  detec$on) hPp://phpmd.org 44
  45. 45. PHPMD• iden$fy  poten$al  problems  in  source  code -­‐ possible  bugs -­‐ subop$mal  code -­‐ overcomplicated  expressions -­‐ unused  parameters,  methods,  proper$es 45
  46. 46. PHPMD  in  ac$on 46
  47. 47. PHPMD  repor$ng 47
  48. 48. PHP  Code  Browser hPps://github.com/mayflowergmbh/PHP_CodeBrowser 48
  49. 49. phpcb• code  browser  for  php  sources -­‐ syntax  highligh$ng -­‐ colored  error  sec$ons• designed  for  usage  of  QA  tools -­‐ PHPUnit -­‐ PHP_CodeSniffer 49
  50. 50. phpcb  example 50
  51. 51. PHPLOChPps://github.com/sebas$anbergmann/phploc 51
  52. 52. Lines  of  Code• calculates  the  size  of  a  project -­‐ gives  a  brief  detail  on  quality  of  source  code -­‐ comparable  to  sumaries  of ‣ phpcs ‣ phpmd ‣ pdepend 52
  53. 53. phploc  in  ac$on 53
  54. 54. Overview  of  outputphploc 1.6.1 by Sebastian Bergmann.Directories: 547Files: 2503Lines of Code (LOC): 482423 Cyclomatic Complexity / Lines of Code: 0.11Comment Lines of Code (CLOC): 224721Non-Comment Lines of Code (NCLOC): 257702Namespaces: 0Interfaces: 124Classes: 2352 Abstract: 199 (8.46%) Concrete: 2153 (91.54%) Average Class Length (NCLOC): 112Methods: 16121 Scope: Non-Static: 15016 (93.15%) Static: 1105 (6.85%) Visibility: Public: 12712 (78.85%) Non-Public: 3409 (21.15%) Average Method Length (NCLOC): 16 Cyclomatic Complexity / Number of Methods: 2.78Anonymous Functions: 2Functions: 0Constants: 3802 Global constants: 8 Class constants: 3794Tests: Classes: 22 Methods: 43 54
  55. 55. PhinghPp://www.phing.info/docs/guide/stable 55
  56. 56. Phing’s  purpose• build  tool  wriPen  in  PHP -­‐ comparable  to  Ant  or  make• used  to  automate  build  process -­‐ build  =  all  steps  to  produce  reports• provides  targets  and  variable  proper$es -­‐ for  targeted  execu$on  of  tools  (e.g.  only  unit  tes$ng) 56
  57. 57. 57
  58. 58. Loca$on  of  build  reports/path/to/project /application /library /public /tests /build /api -> location for API documentation /cache -> used by CI for caching /code-browser -> browsable source code /coverage -> unit test code coverage /logs -> location for all report logs /junit.xml /jdepend.xml /pmd.xml /pmd-cpd.xml /phploc.csv /checkstyle.xml /pdepend -> dependency graphics and pyramid 58
  59. 59. Integra$on  of  tools 59
  60. 60. Ini$al  Phing  build  script<?xml version=”1.0” encoding=”UTF-8”?><!-- $Id: jenkins.xml 123 2011-06-08 07:00:00Z michelangelo $--><project name=”My Project” default=”build”> <!-- a property file (key/value) to store project specific data like paths, property values and passwords --> <property file=”jenkins.properties” /> <!-- list of targets, each with their own php tool --></project> 60
  61. 61. define  our  filesets<fileset id=”php-files” dir=”${project.basedir}”> <include name=”**/*.php” /> <exclude name=”library/Zend/**” /> <exclude name=”library/ZendX/**” /> <exclude name=”tests/**” /></fileset> 61
  62. 62. clean  build  path<target name=”clean” description=”Clean build path”> <delete dir=”${project.basedir}/build” /> <mkdir dir=”${project.basedir}/build” /> <mkdir dir=”${project.basedir}/build/api” /> <mkdir dir=”${project.basedir}/build/cache” /> <mkdir dir=”${project.basedir}/build/code-browser” /> <mkdir dir=”${project.basedir}/build/coverage” /> <mkdir dir=”${project.basedir}/build/logs” /> <mkdir dir=”${project.basedir}/build/pdepend” /></target> 62
  63. 63. lint  checking<target name=”phplint” description=”Syntax checking of code”> <phplint haltonfailure=”true”> <fileset refid=”php-files” /> </phplint></target> 63
  64. 64. unit  tes$ng<target name=”PHPUnit” description=”Running unit tests”> <exec passthru=”${passthru}” dir=”${project.basedir}/tests” command=”phpunit --log-junit=${project.basedir}/build/logs/junit.xml --coverage-clover=${project.basedir}/build/logs/clover.xml --coverage-html=${project.basedir}/build/coverage --stop-on-error --stop-on-failure”/></target> 64
  65. 65. documenta$on<target name="phpdoc" description="Generate API documentation"> <phpdoc title="${project.name} API Documentation" target="${project.basedir}/build/api" output="HTML:frames:earthli" quiet="true"> <fileset refid="php-files"/> </phpdoc></target> 65
  66. 66. coding  standards<target name="phpcs" description="Coding Standards Analysis"> <exec passthru="${passthru}" command="phpcs --report=checkstyle --report-file=${project.basedir}/build/logs/checkstyle.xml --standard=Zend --ignore=library/Zend,library/ZendX,tests,docs,scripts --extensions=php ${project.basedir}"/></target> 66
  67. 67. copy-­‐paste  detec$on<target name="phpcpd" description="Copy/Paste detection"> <phpcpd> <fileset refid="php-files"/> <formatter type="pmd" outfile="${project.basedir}/build/logs/pmd-cpd.xml"/> </phpcpd></target> 67
  68. 68. lines  of  code<target name="phploc" description="Generate phploc.csv"> <exec passthru="${passthru}" command="phploc --log-csv ${project.basedir}/build/logs/phploc.csv ${project.basedir}"/></target> 68
  69. 69. code  browser<target name="phpcb" description="Source code browser" depends="phpunit, phpcs"> <exec passthru="${passthru}" command="phpcb --ignore build,library/Zend,library/ZendX,tests,docs --log ${project.basedir}/build/logs --source ${project.basedir} --output ${project.basedir}/build/code-browser"/></target> 69
  70. 70. depend  metric  calcula$ons<target name="pdepend" description="Calculate dependencies"> <exec passthru="${passthru}" dir="${project.basedir}" command="pdepend --configuration=${project.basedir}/pdepend.xml --jdepend-chart=${project.basedir}/build/pdepend/dependencies.svg --jdepend-xml=${project.basedir}/build/logs/jdepend.xml --overview-pyramid=${project.basedir}/build/pdepend/overview-pyramid.svg --suffix=php --ignore=library/Zend,library/ZendX,tests ${project.basedir}"/></target> 70
  71. 71. mess  detec$on<target name="phpmd" description="Mess Detection"> <phpmd> <fileset refid="php-files"/> <formatter type="xml" outfile="${project.basedir}/build/logs/pmd.xml"/> </phpmd></target> 71
  72. 72. default  target:  build<target name="build" description="Start analyzing our app"> <phingCall target="clean" /> <phingCall target="phplint" /> <phingCall target="phpdoc" /> <phingCall target="phpcs" /> <phingCall target="phpunit" /> <phingCall target="phpcpd" /> <phingCall target="phpmd" /> <phingCall target="pdepend" /> <phingCall target="phploc" /> <phingCall target="phpcb" /></target> 72
  73. 73. phing  in  ac$on 73
  74. 74. build  all 74
  75. 75. phing  usage• developers  can  run  at  call -­‐ all  targets -­‐ specific  targets  (like  unit  tests,  style  checking,  …)• unified  way  of  execu$ng  processes 75
  76. 76. perfect  for  CI  !!! 76
  77. 77. Con$nuous  Integra$on 77
  78. 78. Con$nuous  Integra$on?• automated  process• tools  for  code -­‐ test -­‐ document -­‐ validate -­‐ package• triggered -­‐ by  code  change  in  version  control  system -­‐ on  fixed  intervals  (e.g.  every  weekday  at  1am) 78
  79. 79. Jenkins-­‐CI hPp://jenkins-­‐ci.org/ 79
  80. 80. A  project  in  CI 80
  81. 81. Overview  of  reports• unit  tests• code  coverage• coding  standards  viola$ons• mess  detec$on• dependency  calcula$ons• copy/paste  detec$on• code  analysis• API  documenta$on 81
  82. 82. Unit  Tests 82
  83. 83. 83
  84. 84. 84
  85. 85. 85
  86. 86. Code  Coverage 86
  87. 87. 87
  88. 88. 88
  89. 89. 89
  90. 90. CheckStyle 90
  91. 91. 91
  92. 92. 92
  93. 93. 93
  94. 94. 94
  95. 95. Mess  detec$on 95
  96. 96. 96
  97. 97. 97
  98. 98. 98
  99. 99. 99
  100. 100. 100
  101. 101. 101
  102. 102. Dependency  Calcula$ons 102
  103. 103. 103
  104. 104. 104
  105. 105. 105
  106. 106. API  Documenta$on 106
  107. 107. 107
  108. 108. 108
  109. 109. Viola$ons 109
  110. 110. 110
  111. 111. 111
  112. 112. Round  up 112
  113. 113. With  CI• con$nuous  inspec$on  of  code -­‐ errors  are  detected  early -­‐ warnings  are  reported -­‐ areas  of  improvement  are  pointed  out 113
  114. 114. CI  &  PHP• all  the  tools   -­‐ to  improve  development  skills -­‐ to  deliver  quality  code -­‐ to  detect  issues  early -­‐ to  document  and  analyze  code  base 114
  115. 115. Recommended  reading• the  PHP  QA  book -­‐ Sebas$an  Bergmann -­‐ Stefan  Priebsch 115
  116. 116. Recommended  reading Free• OOD  Quality  Metrics -­‐ Robert  Cecil  Mar$n hPp://www.objectmentor.com/publica$ons/oodmetrc.pdf 116
  117. 117. Sources  and  Code• slides: hPp://www.slideshare.net/DragonBe• sources: hPp://github.com/DragonBe/wingz• contact: -­‐ mail:  michelangelo@in2it.be -­‐ twiPer:  @DragonBe -­‐ facebook:  DragonBe 117
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×