Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Code quality tools for dev

2,089 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Code quality tools for dev

  1. 1. Code Quality Tools for Dev Rejah Rehim
  2. 2. Maintainable code base Code reuse (avoid code repetition) —  avoid complicated nested loops —  Encapsulation (organize code in classes) —  Code Documentation —  Consistent code conventions ( Code consistency)
  3. 3. PHP PHP Mess Detector ●  PHP Copy Paste Detector ●  PHP Code Sniffer
  4. 4. PHP Mess Detector ( PHP MD ) Trying to be equivalent of Java Tool PMD Looks for potential problems such as : •  if your function is too long •  if your function has too many parameters •  variable names too long or too short •  too many nested cycles •  Use of eval() •  Name of covention consistency •  Unused methodes or variables
  5. 5. PHP MD Installation $ pear channel-discover pear.phpmd.org $ pear channel-discover pear.pdepend.org $ pear install --alldeps phpmd/PHP_PMD
  6. 6. PHP MD Usage phpmd [directory name] [format] [rule] directory name = php directory format = xml, text, html rules = any of the available rules http://phpmd.org/rules/index.html
  7. 7. PHP Copy Paste Detector - PHP CPD ●  Find Duplicated Code ( http://en.wikipedia.org/wiki/Duplicate_code) Installing PHP CPD ●  pear config-set auto_discover 1 ●  pear install pear.phpunit.de/phpcpd Usage ●  phpcpd [directoryname]
  8. 8. PHP Code Sniffer PHP 5 script ●  Tokenises your php, javascript, css files ●  Detects violations of a defined set of coding standards
  9. 9. Installation pear install PHP_CodeSniffer-1.5.0RC3 Usage phpcs --extensions=php [directory]
  10. 10. Demo ●  Command line ●  With Sublime Text Module
  11. 11. Thank you

×