SlideShare a Scribd company logo
Con$nuous	
  QA
 Michelangelo	
  van	
  Dam
          Macq	
  NV
Michelangelo	
  van	
  Dam


•   independent	
  contractor
•   president	
  PHPBenelux
•   conference	
  speaker
•   community	
  animal




              ZEND
              FRAMEWORK   PHP   .



                                      2
Overview


• introduc$on
• overview	
  of	
  tools
• con$nuous	
  integra$on
  -­‐ interpreta$on	
  of	
  reports
• roundup



                                       3
Introduc$on



              4
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
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
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	
  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
Execu$on




           10
Parse	
  error




                 11
Fatal	
  error




                 12
PHPUnit




hPp://www.phpunit.de/manual/current/en/   13
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
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	
  a	
  consistent	
  way	
  code	
  is	
  wriPen
   -­‐ as	
  though	
  one	
  developer	
  wrote	
  all	
  the	
  code



                                                                         21
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
Example	
  Full	
  report
FILE: /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
Example	
  Summary	
  report
PHP 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
Example	
  Source	
  report
PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
--------------------------------------------------------------------------------
STANDARD CATEGORY             SNIFF                                        COUNT
--------------------------------------------------------------------------------
Generic   Files               Line length too long                         4
PEAR      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
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 argument
list</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
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
Example	
  CSV	
  report
File,Line,Column,Type,Message,Source,Severity
"/path/to/file.php",111,83,error,"Arguments with default values must be at the end
of the argument list",PEAR.Functions.ValidDefaultValue.NotAtEnd,5
"/path/to/file.php",111,89,warning,"Line exceeds 80 characters; contains 88
characters",Generic.Files.LineLength.TooLong,5
"/path/to/file.php",118,90,warning,"Line exceeds 80 characters; contains 89
characters",Generic.Files.LineLength.TooLong,5
"/path/to/file.php",121,85,warning,"Line exceeds 80 characters; contains 84
characters",Generic.Files.LineLength.TooLong,5
"/path/to/file.php",130,95,warning,"Line exceeds 80 characters; contains 94
characters",Generic.Files.LineLength.TooLong,5




                                                                                     28
Example	
  Blame	
  report
PHP 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
Execu$on	
  of	
  phpcs




                          30
PHPCPD




hPps://github.com/sebas$anbergmann/phpcpd   31
Copy/Paste	
  Detec$on
                                              TIP:	
  pre-­‐commit	
  hook



• detects	
  duplicate	
  or	
  similar	
  lines	
  of	
  code
   -­‐ copied	
  code
   -­‐ code	
  that’s	
  similar




                                                                             32
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
• 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
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
Average	
  Hierarchy	
  Height



The	
  average	
  of	
  the	
  maximum	
  length	
  from	
  a	
  
        root	
  class	
  to	
  its	
  deepest	
  subclass




                                                                    39
pdepend	
  pyramid




                     40
pdepend-­‐graph




graph	
  about	
  stability:	
  a	
  mix	
  between	
  abstract	
  and	
  concrete	
  classes

                                                                                                41
42
43
PHPMD	
  (Mess	
  detec$on)




          hPp://phpmd.org     44
PHPMD


• iden$fy	
  poten$al	
  problems	
  in	
  source	
  code
  -­‐   possible	
  bugs
  -­‐   subop$mal	
  code
  -­‐   overcomplicated	
  expressions
  -­‐   unused	
  parameters,	
  methods,	
  proper$es




                                                            45
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	
  usage	
  of	
  QA	
  tools
   -­‐ PHPUnit
   -­‐ PHP_CodeSniffer


                                                  49
phpcb	
  example




                   50
PHPLOC




hPps://github.com/sebas$anbergmann/phploc   51
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
phploc	
  in	
  ac$on




                        53
Overview	
  of	
  output
phploc 1.6.1 by Sebastian Bergmann.

Directories:                                      547
Files:                                           2503

Lines of Code (LOC):                           482423
  Cyclomatic Complexity / Lines of Code:         0.11
Comment Lines of Code (CLOC):                  224721
Non-Comment Lines of Code (NCLOC):             257702

Namespaces:                                         0
Interfaces:                                       124
Classes:                                         2352
  Abstract:                                       199 (8.46%)
  Concrete:                                      2153 (91.54%)
  Average Class Length (NCLOC):                   112
Methods:                                        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.78

Anonymous Functions:                                2
Functions:                                          0

Constants:                                       3802
  Global constants:                                 8
  Class constants:                               3794

Tests:
  Classes:                                         22
  Methods:                                         43


                                                                 54
Phing




hPp://www.phing.info/docs/guide/stable   55
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
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
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 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
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
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
lint	
  checking
<target name=”phplint” description=”Syntax checking of code”>
    <phplint haltonfailure=”true”>
        <fileset refid=”php-files” />
    </phplint>
</target>




                                                                63
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
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
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
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
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
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
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
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
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
phing	
  in	
  ac$on




                       73
build	
  all




               74
phing	
  usage


• developers	
  can	
  run	
  at	
  call
   -­‐ all	
  targets
   -­‐ specific	
  targets	
  (like	
  unit	
  tests,	
  style	
  checking,	
  …)
• unified	
  way	
  of	
  execu$ng	
  processes


                                                                                   75
perfect	
  for	
  CI	
  !!!



                              76
Con$nuous	
  Integra$on



                          77
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
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	
  calcula$ons
• copy/paste	
  detec$on
• code	
  analysis
• API	
  documenta$on
                                     81
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
  -­‐ areas	
  of	
  improvement	
  are	
  pointed	
  out




                                                            113
CI	
  &	
  PHP


• all	
  the	
  tools	
  
   -­‐   to	
  improve	
  development	
  skills
   -­‐   to	
  deliver	
  quality	
  code
   -­‐   to	
  detect	
  issues	
  early
   -­‐   to	
  document	
  and	
  analyze	
  code	
  base




                                                            114
Recommended	
  reading



• the	
  PHP	
  QA	
  book
  -­‐ Sebas$an	
  Bergmann
  -­‐ Stefan	
  Priebsch




                                115
Recommended	
  reading
                                 Free



• OOD	
  Quality	
  Metrics
  -­‐ Robert	
  Cecil	
  Mar$n




               hPp://www.objectmentor.com/publica$ons/oodmetrc.pdf   116
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

More Related Content

What's hot (20)

PDF
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf Conference
 
PPTX
Zephir - A Wind of Change for writing PHP extensions
Mark Baker
 
PDF
Api Design
sumithra jonnalagadda
 
PDF
Zend Framework 2 Components
Shawn Stratton
 
PDF
PHP 良好實踐 (Best Practice)
Win Yu
 
PDF
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
PDF
Flask SQLAlchemy
Eueung Mulyana
 
PDF
Codeigniter4の比較と検証
ME iBotch
 
PPTX
CakePHP
Robert Blomdalen
 
PPTX
PHP from soup to nuts Course Deck
rICh morrow
 
ODP
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
King Foo
 
PDF
Make your application expressive
Christian Varela
 
PDF
Rest API using Flask & SqlAlchemy
Alessandro Cucci
 
PPTX
PHP7 Presentation
David Sanchez
 
PDF
Browser Serving Your We Application Security - ZendCon 2017
Philippe Gamache
 
PDF
エラー時にログに出力する情報と画面に表示する情報を分ける #LaravelTokyo
Shohei Okada
 
PPTX
Laravel5 Introduction and essentials
Pramod Kadam
 
KEY
Zend Framework Study@Tokyo #2
Shinya Ohyanagi
 
PPT
ZFConf 2012: Dependency Management в PHP и Zend Framework 2 (Кирилл Чебунин)
ZFConf Conference
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf Conference
 
Zephir - A Wind of Change for writing PHP extensions
Mark Baker
 
Zend Framework 2 Components
Shawn Stratton
 
PHP 良好實踐 (Best Practice)
Win Yu
 
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
Flask SQLAlchemy
Eueung Mulyana
 
Codeigniter4の比較と検証
ME iBotch
 
PHP from soup to nuts Course Deck
rICh morrow
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
King Foo
 
Make your application expressive
Christian Varela
 
Rest API using Flask & SqlAlchemy
Alessandro Cucci
 
PHP7 Presentation
David Sanchez
 
Browser Serving Your We Application Security - ZendCon 2017
Philippe Gamache
 
エラー時にログに出力する情報と画面に表示する情報を分ける #LaravelTokyo
Shohei Okada
 
Laravel5 Introduction and essentials
Pramod Kadam
 
Zend Framework Study@Tokyo #2
Shinya Ohyanagi
 
ZFConf 2012: Dependency Management в PHP и Zend Framework 2 (Кирилл Чебунин)
ZFConf Conference
 

Similar to Continuous Quality Assurance (20)

PDF
Joomla Code Quality Control and Automation Testing
Shyam Sunder Verma
 
PDF
SVN Hook
Thomas Weinert
 
PDF
PHP QA Tools
rjsmelo
 
PPTX
Code analysis tools (for PHP)
Karlen Kishmiryan
 
PDF
Continuous Integration In Php
Wilco Jansen
 
PDF
Tool up your lamp stack
AgileOnTheBeach
 
PDF
Tool Up Your LAMP Stack
Lorna Mitchell
 
PDF
20 PHP Static Analysis and Documentation Generators #burningkeyboards
Denis Ristic
 
PPTX
Listen afup 2010
Gabriele Santini
 
ODP
PHP Code Quality
Usman Zafar
 
PDF
Code review workshop
Damien Seguy
 
PDF
Living With Legacy Code
Rowan Merewood
 
PPTX
4-chapter-File & Directores.pptx debre CTABOUR UNIversit
alemunuruhak9
 
KEY
Continuous Integration Step-by-step
Michelangelo van Dam
 
PPTX
Php core. get rid of bugs and contribute
Pierre Joye
 
PDF
Best Practices with Zend Framework - Matthew Weier O'Phinney
dpc
 
KEY
Let's creating your own PHP (tejimaya version)
Kousuke Ebihara
 
PDF
Preparing code for Php 7 workshop
Damien Seguy
 
PPSX
DIWE - File handling with PHP
Rasan Samarasinghe
 
PDF
Analysis of-quality-of-pkgs-in-packagist-univ-20171024
Clark Everetts
 
Joomla Code Quality Control and Automation Testing
Shyam Sunder Verma
 
SVN Hook
Thomas Weinert
 
PHP QA Tools
rjsmelo
 
Code analysis tools (for PHP)
Karlen Kishmiryan
 
Continuous Integration In Php
Wilco Jansen
 
Tool up your lamp stack
AgileOnTheBeach
 
Tool Up Your LAMP Stack
Lorna Mitchell
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
Denis Ristic
 
Listen afup 2010
Gabriele Santini
 
PHP Code Quality
Usman Zafar
 
Code review workshop
Damien Seguy
 
Living With Legacy Code
Rowan Merewood
 
4-chapter-File & Directores.pptx debre CTABOUR UNIversit
alemunuruhak9
 
Continuous Integration Step-by-step
Michelangelo van Dam
 
Php core. get rid of bugs and contribute
Pierre Joye
 
Best Practices with Zend Framework - Matthew Weier O'Phinney
dpc
 
Let's creating your own PHP (tejimaya version)
Kousuke Ebihara
 
Preparing code for Php 7 workshop
Damien Seguy
 
DIWE - File handling with PHP
Rasan Samarasinghe
 
Analysis of-quality-of-pkgs-in-packagist-univ-20171024
Clark Everetts
 
Ad

More from Michelangelo van Dam (20)

PDF
GDPR Art. 25 - Privacy by design and default
Michelangelo van Dam
 
PDF
Moving from app services to azure functions
Michelangelo van Dam
 
PDF
Privacy by design
Michelangelo van Dam
 
PDF
DevOps or DevSecOps
Michelangelo van Dam
 
PDF
Privacy by design
Michelangelo van Dam
 
PDF
Continuous deployment 2.0
Michelangelo van Dam
 
PDF
Let your tests drive your code
Michelangelo van Dam
 
PDF
General Data Protection Regulation, a developer's story
Michelangelo van Dam
 
PDF
Leveraging a distributed architecture to your advantage
Michelangelo van Dam
 
PDF
The road to php 7.1
Michelangelo van Dam
 
PDF
Open source for a successful business
Michelangelo van Dam
 
PDF
Decouple your framework now, thank me later
Michelangelo van Dam
 
PDF
Deploy to azure in less then 15 minutes
Michelangelo van Dam
 
PDF
Azure and OSS, a match made in heaven
Michelangelo van Dam
 
PDF
Getting hands dirty with php7
Michelangelo van Dam
 
PDF
Zf2 how arrays will save your project
Michelangelo van Dam
 
PDF
Create, test, secure, repeat
Michelangelo van Dam
 
PDF
The Continuous PHP Pipeline
Michelangelo van Dam
 
PDF
PHPUnit Episode iv.iii: Return of the tests
Michelangelo van Dam
 
PDF
Easily extend your existing php app with an api
Michelangelo van Dam
 
GDPR Art. 25 - Privacy by design and default
Michelangelo van Dam
 
Moving from app services to azure functions
Michelangelo van Dam
 
Privacy by design
Michelangelo van Dam
 
DevOps or DevSecOps
Michelangelo van Dam
 
Privacy by design
Michelangelo van Dam
 
Continuous deployment 2.0
Michelangelo van Dam
 
Let your tests drive your code
Michelangelo van Dam
 
General Data Protection Regulation, a developer's story
Michelangelo van Dam
 
Leveraging a distributed architecture to your advantage
Michelangelo van Dam
 
The road to php 7.1
Michelangelo van Dam
 
Open source for a successful business
Michelangelo van Dam
 
Decouple your framework now, thank me later
Michelangelo van Dam
 
Deploy to azure in less then 15 minutes
Michelangelo van Dam
 
Azure and OSS, a match made in heaven
Michelangelo van Dam
 
Getting hands dirty with php7
Michelangelo van Dam
 
Zf2 how arrays will save your project
Michelangelo van Dam
 
Create, test, secure, repeat
Michelangelo van Dam
 
The Continuous PHP Pipeline
Michelangelo van Dam
 
PHPUnit Episode iv.iii: Return of the tests
Michelangelo van Dam
 
Easily extend your existing php app with an api
Michelangelo van Dam
 
Ad

Recently uploaded (20)

PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PDF
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PPTX
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 

Continuous Quality Assurance

  • 1. Con$nuous  QA Michelangelo  van  Dam Macq  NV
  • 2. Michelangelo  van  Dam • independent  contractor • president  PHPBenelux • conference  speaker • community  animal ZEND FRAMEWORK PHP . 2
  • 3. Overview • introduc$on • overview  of  tools • con$nuous  integra$on -­‐ interpreta$on  of  reports • roundup 3
  • 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. 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
  • 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. Execu$on 10
  • 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
  • 16. PHPDocumentor hPp://www.phpdoc.org 16
  • 17. PHPDoc • uses  in  code  docblocks • parses  API  documenta$on 17
  • 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. 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. Example  Full  report FILE: /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. Example  Summary  report PHP 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. Example  Source  report PHP CODE SNIFFER VIOLATION SOURCE SUMMARY -------------------------------------------------------------------------------- STANDARD CATEGORY SNIFF COUNT -------------------------------------------------------------------------------- Generic Files Line length too long 4 PEAR 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. 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 argument list</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. 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. Example  CSV  report File,Line,Column,Type,Message,Source,Severity "/path/to/file.php",111,83,error,"Arguments with default values must be at the end of the argument list",PEAR.Functions.ValidDefaultValue.NotAtEnd,5 "/path/to/file.php",111,89,warning,"Line exceeds 80 characters; contains 88 characters",Generic.Files.LineLength.TooLong,5 "/path/to/file.php",118,90,warning,"Line exceeds 80 characters; contains 89 characters",Generic.Files.LineLength.TooLong,5 "/path/to/file.php",121,85,warning,"Line exceeds 80 characters; contains 84 characters",Generic.Files.LineLength.TooLong,5 "/path/to/file.php",130,95,warning,"Line exceeds 80 characters; contains 94 characters",Generic.Files.LineLength.TooLong,5 28
  • 29. Example  Blame  report PHP 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
  • 32. Copy/Paste  Detec$on TIP:  pre-­‐commit  hook • detects  duplicate  or  similar  lines  of  code -­‐ copied  code -­‐ code  that’s  similar 32
  • 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. 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. Average  Hierarchy  Height The  average  of  the  maximum  length  from  a   root  class  to  its  deepest  subclass 39
  • 41. pdepend-­‐graph graph  about  stability:  a  mix  between  abstract  and  concrete  classes 41
  • 42. 42
  • 43. 43
  • 44. PHPMD  (Mess  detec$on) hPp://phpmd.org 44
  • 45. PHPMD • iden$fy  poten$al  problems  in  source  code -­‐ possible  bugs -­‐ subop$mal  code -­‐ overcomplicated  expressions -­‐ unused  parameters,  methods,  proper$es 45
  • 48. PHP  Code  Browser hPps://github.com/mayflowergmbh/PHP_CodeBrowser 48
  • 49. phpcb • code  browser  for  php  sources -­‐ syntax  highligh$ng -­‐ colored  error  sec$ons • designed  for  usage  of  QA  tools -­‐ PHPUnit -­‐ PHP_CodeSniffer 49
  • 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
  • 54. Overview  of  output phploc 1.6.1 by Sebastian Bergmann. Directories: 547 Files: 2503 Lines of Code (LOC): 482423 Cyclomatic Complexity / Lines of Code: 0.11 Comment Lines of Code (CLOC): 224721 Non-Comment Lines of Code (NCLOC): 257702 Namespaces: 0 Interfaces: 124 Classes: 2352 Abstract: 199 (8.46%) Concrete: 2153 (91.54%) Average Class Length (NCLOC): 112 Methods: 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.78 Anonymous Functions: 2 Functions: 0 Constants: 3802 Global constants: 8 Class constants: 3794 Tests: Classes: 22 Methods: 43 54
  • 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
  • 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
  • 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. 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. 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. lint  checking <target name=”phplint” description=”Syntax checking of code”> <phplint haltonfailure=”true”> <fileset refid=”php-files” /> </phplint> </target> 63
  • 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. 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. 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. 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. 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. 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. 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. 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. 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
  • 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. perfect  for  CI  !!! 76
  • 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
  • 80. A  project  in  CI 80
  • 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
  • 83. 83
  • 84. 84
  • 85. 85
  • 87. 87
  • 88. 88
  • 89. 89
  • 91. 91
  • 92. 92
  • 93. 93
  • 94. 94
  • 96. 96
  • 97. 97
  • 98. 98
  • 99. 99
  • 100. 100
  • 101. 101
  • 103. 103
  • 104. 104
  • 105. 105
  • 107. 107
  • 108. 108
  • 109. Viola$ons 109
  • 110. 110
  • 111. 111
  • 112. Round  up 112
  • 113. With  CI • con$nuous  inspec$on  of  code -­‐ errors  are  detected  early -­‐ warnings  are  reported -­‐ areas  of  improvement  are  pointed  out 113
  • 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. Recommended  reading • the  PHP  QA  book -­‐ Sebas$an  Bergmann -­‐ Stefan  Priebsch 115
  • 116. Recommended  reading Free • OOD  Quality  Metrics -­‐ Robert  Cecil  Mar$n hPp://www.objectmentor.com/publica$ons/oodmetrc.pdf 116
  • 117. Sources  and  Code • slides: hPp://www.slideshare.net/DragonBe • sources: hPp://github.com/DragonBe/wingz • contact: -­‐ mail:  [email protected] -­‐ twiPer:  @DragonBe -­‐ facebook:  DragonBe 117