Code analysis tools
Tools that we consider•   PHP Copy/Paste Detector•   PHP Mess Detector•   PHP_CodeSniffer•   PHP Depend
PHP Copy/Paste DetectorAllows to search for duplicate source code fragments in   projects.Usage example:
PHP Mess DetectorTakes a given PHP source code base and look for  several potential problems within that source.These prob...
PHP Mess Detector (cont.)PHPMD uses so called rule sets that configure/define a   set of rules which will be applied again...
PHP Mess Detector (cont.)Usage example:You can pass a filename or a directory name containingPHP source code to PHPMD.
PHP_CodeSnifferPHP5 script that tokenizes and "sniffs" PHP, Javascript  and CSS files to detect violations of a defined co...
PHP_CodeSniffer (cont.)Sample PHP_CodeSniffer output:
PHP_CodeSniffer (cont.)Sample PHP_CodeSniffer full report with source codes:Both the full and summary reports can addition...
PHP_CodeSniffer (cont.)Sample PHP_CodeSniffer summary report with source  codes:
PHP DependA small program that performs static code  analysis on a given code base.Static code analysis:•   takes the sour...
PHP Depend (cont.)         Usage example:This    command       hasproduced one xml-reportnamed summary.xml thatcontains a ...
PHP Depend (cont.)XML Report (summary.xml):
PHP Depend (cont.)Shows the inter package   Shows a visual summary of thedependencies              analyzed project source...
Thank you!        by Karlen Kishmiryan (Sourcio CJSC)
Upcoming SlideShare
Loading in …5
×

Code analysis tools (for PHP)

3,230 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
3,230
On SlideShare
0
From Embeds
0
Number of Embeds
21
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Code analysis tools (for PHP)

  1. 1. Code analysis tools
  2. 2. Tools that we consider• PHP Copy/Paste Detector• PHP Mess Detector• PHP_CodeSniffer• PHP Depend
  3. 3. PHP Copy/Paste DetectorAllows to search for duplicate source code fragments in projects.Usage example:
  4. 4. PHP Mess DetectorTakes a given PHP source code base and look for several potential problems within that source.These problems can be things like:• Possible bugs• Suboptimal code• Over complicated expressions• Unused parameters, methods, properties
  5. 5. PHP Mess Detector (cont.)PHPMD uses so called rule sets that configure/define a set of rules which will be applied against the source under test. It only provides a set of predefined rules.List of rule sets:• Code size rules• Controversial rules• Design rules• Naming rules
  6. 6. PHP Mess Detector (cont.)Usage example:You can pass a filename or a directory name containingPHP source code to PHPMD.
  7. 7. PHP_CodeSnifferPHP5 script that tokenizes and "sniffs" PHP, Javascript and CSS files to detect violations of a defined coding standard.A coding standard in PHP_CodeSniffer is a collection of sniff files. Each sniff file checks one part of the coding standard only.The default coding standard used by PHP_CodeSniffer is the PEAR coding standard.
  8. 8. PHP_CodeSniffer (cont.)Sample PHP_CodeSniffer output:
  9. 9. PHP_CodeSniffer (cont.)Sample PHP_CodeSniffer full report with source codes:Both the full and summary reports can additionally show informationabout the source of errors and warnings.
  10. 10. PHP_CodeSniffer (cont.)Sample PHP_CodeSniffer summary report with source codes:
  11. 11. PHP DependA small program that performs static code analysis on a given code base.Static code analysis:• takes the source code and parses it into an easily processable internal data structure (Abstract Syntax Tree)• takes the generated AST and measures several values, the so called software metricsSoftware metrics are the sum of some statements or code fragments found in the analyzed source.
  12. 12. PHP Depend (cont.) Usage example:This command hasproduced one xml-reportnamed summary.xml thatcontains a summary of allmetrics collected for theanalyzed php sourcecode.
  13. 13. PHP Depend (cont.)XML Report (summary.xml):
  14. 14. PHP Depend (cont.)Shows the inter package Shows a visual summary of thedependencies analyzed project source code
  15. 15. Thank you! by Karlen Kishmiryan (Sourcio CJSC)

×