Code quality tools


Published on

This presentation provides participants with an overview of
the most popular tools for code quality control in Flex. Among them: Sonar with Flex plugin, FlexPMD & FlexPMD Eclipse plugin, SWFScan from HP and FlexFormatting Eclipse plugin.
In this presentation will be presented the basic information about each of the mentioned tools, information how to configure some of these tools, how to use them and How to interpret results of their work.

Sonar with Flex plugin
-What is FlexPMD
-How does it work
FlexPMD plugin
-Supported workflows
-FlexCPD integration
-FlexPMD Ruleset Creator
SwfScan from HP

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Code quality tools

  1. 1. Tools for code quality control in Flex Lena Petsenchuk 19.08.2011 <ul><ul><ul><ul><ul><li>“ Any fool can write code that a computer can understand. </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Good programmers write code that humans can understand.” </li></ul></ul></ul></ul></ul><ul><li>~Martin Fowler </li></ul>
  2. 2. Agenda <ul><li>Sonar with Flex plugin </li></ul><ul><li>FlexPMD </li></ul><ul><ul><li>What is FlexPMD </li></ul></ul><ul><ul><li>How does it work </li></ul></ul><ul><li>FlexPMD plugin </li></ul><ul><ul><li>Configuration </li></ul></ul><ul><ul><li>Supported workflows </li></ul></ul><ul><ul><li>FlexCPD integration </li></ul></ul><ul><ul><li>FlexPMD Ruleset Creator </li></ul></ul><ul><ul><li>SwfScan from HP </li></ul></ul><ul><ul><li>FlexCover </li></ul></ul><ul><ul><li>ItDepends </li></ul></ul><ul><ul><li>FlexFormatting </li></ul></ul>
  3. 3. Sonar with Flex Plugin <ul><li>Sonar is a tool for code quality analysis. </li></ul><ul><li>It helps improving software quality using static analysis tools. </li></ul><ul><li>It targets Java code, but there are plugins for Flex, C, PHP, .Net and other languages. </li></ul><ul><li>The Flex plug-in specifically uses FlexPMD , FlexMet rics , FlexCPD and FlexMojos . </li></ul>
  4. 4. Sonar's Results Dashboard Violations drilldown
  5. 5. Sonar’s Results Hotspots Radiator Time machine
  6. 6. Sonar’s Results Motion Chart
  7. 7. What is FlexPMD <ul><li>FlexPMD is a tool that helps to improve code quality by auditing any AS3/Flex source directory and detecting common bad practices. </li></ul><ul><li> </li></ul><ul><ul><li>FlexPMD can detect: </li></ul></ul><ul><ul><li>Coding standards violations </li></ul></ul><ul><ul><li>Code duplication </li></ul></ul><ul><ul><li>Unused code (functions, variables, constants, etc.) </li></ul></ul><ul><ul><li>Over-complex code (nested loops, too many conditionals, etc.) </li></ul></ul><ul><ul><li>Over-long code (classes, methods, etc.) </li></ul></ul><ul><ul><li>Unhandled exceptions </li></ul></ul><ul><ul><li>Incorrect use of the Flex component lifecycle (commitProperties, etc.) </li></ul></ul>
  8. 8. How to invoke <ul><li>FlexPMD can currently be invoked from: </li></ul><ul><li>The command line </li></ul><ul><li>Maven </li></ul><ul><li>Ant </li></ul><ul><li>Automator on Mac OS X </li></ul><ul><li>Eclipse </li></ul><ul><li>FlexBuilder </li></ul><ul><li>TextMate on Mac OS X </li></ul><ul><li>FlashDevelop </li></ul>
  9. 9. How does it work <ul><li>FlexPMD is delivered with a set of standard rules for Flex/AS development. Each source file that is processed is checked against every rule. </li></ul><ul><li>Currently, FlexPMD produces a XML report by default, plus an HTML report when invoked by the Maven site plugin. </li></ul>
  10. 10. FlexPMD Plugin <ul><li>The FlexPMD Plugin is a plugin to streamline the development process in regards to FlexPMD violations </li></ul><ul><li>Update site </li></ul><ul><ul><li> </li></ul></ul><ul><li>It analyses the code and marks the violations inline in the code so that developers can see them as they develop </li></ul><ul><li>It allows easy navigation between the list of violations and the associated code </li></ul>
  11. 11. Configure FlexPMD plugin <ul><li>Download FlexPMD command line tools ( ) </li></ul><ul><li>FlexPMD command line . This is a mandatory field. You have to select the flex-pmd-command-line.jar from your hard drive. </li></ul><ul><li>FlexPMD custom ruleset . You can leave this field empty, if so a default ruleset will be used. </li></ul><ul><li>FlexCPD command line . You have to select the flex-pmd-cpd-command-line.jar you wish from your hard drive. </li></ul>
  12. 12. Supported workflows – Code review workflow <ul><li>Code review workflow : As a code reviewer I want to be able to audit and review the quality of an entire project or any given functional area in terms of PMD violations. </li></ul><ul><li>Ideal for </li></ul><ul><li>Projects that didn’t use FlexPMD from the very beginning </li></ul><ul><li>Projects where not all developers use FlexPMD </li></ul><ul><li>Audit specific functional areas </li></ul><ul><li>Benefits </li></ul><ul><li>FlexPMD recommendations are displayed in a specific panel and can be sorted attending its relevance or violation type </li></ul>
  13. 13. Code Review workflow <ul><li>Select any source folder in a project </li></ul><ul><li>Right click on it </li></ul><ul><li>Select FlexPMD > Run FlexPMD </li></ul>
  14. 14. Supported workflows – Development workflow <ul><li>Development workflow : As a developer I want to see PMD violations in the files I'm working in. If a file changes the violations should be updated immediately. </li></ul><ul><li>Ideal for </li></ul><ul><li>Projects that start using FlexPMD from the very beginning </li></ul><ul><li>Teams that proactively want to promote collective code and team best practices </li></ul><ul><li>Benefits </li></ul><ul><li>FlexPMD execute automatically on every compilation </li></ul>
  15. 15. Development workflow <ul><li>Right click in a project </li></ul><ul><li>Select FlexPMD > Add FlexPMD Nature </li></ul><ul><li>Note: If at any point you want to remove the nature you can select FlexPMD > Remove FlexPMD Nature </li></ul>
  16. 16. FlexPMD Outline <ul><li>In the FlexPMD Outline View you'll see the violations in the currently opened editor. </li></ul><ul><li>If the arrows button is toggled, whenever the file is saved FlexPMD will be re-executed on it and the Outline will be updated providing always up-to-date information to the developer with very little delay and without having to compile the entire project. </li></ul>
  17. 17. FlexCPD integration <ul><li>FlexCPD can detect suspect copy/paste sections of code in your project. </li></ul><ul><li>Executes on demand </li></ul><ul><li>You can execute FlexCPD by right-click in a source folder and select FlexPMD > Find suspect cut & paste. </li></ul><ul><li>Creates a list of snippets of duplicated code </li></ul><ul><li>You can navigate to the source code file by double clicking on the item </li></ul>
  18. 18. FlexPMD Ruleset Creator <ul><li> </li></ul>
  19. 19. SwfScan from HP <ul><li>HP SWFScan , a free tool developed by HP Web Security Research Group, will automatically find security vulnerabilities in applications built on the Flash platform. </li></ul><ul><li>How SWFScan works and what vulnerabilities it finds: </li></ul><ul><li>Decompiles applications built on the Adobe Flash platform to extract the ActionScript code and statically analyzes it to identify security issues such as information disclosure. (The tool couldn’t decompile flash files protected with SWFEncrypt.) </li></ul>
  20. 20. SwfScan from HP – Settings <ul><li>It looks for about 75 known security vulnerabilities that are targeted by malicious hackers. </li></ul><ul><li>This includes unprotected confidential data, cross-site scripting, cross-domain privilege escalation, and user input that does not get validated. </li></ul>
  21. 21. SwfScan from HP – Results
  22. 22. FlexCover <ul><li>Flexcover - a tool that measures how much of your Flex, AIR or AS3 application code actually runs when tested. </li></ul><ul><li> </li></ul><ul><li>Install FlexCover </li></ul><ul><li>Create a copy of the Flex SDK that you will customize for Flexcover </li></ul><ul><li>Modify this custom SDK to use the Flexcover compilers and libraries. </li></ul><ul><li>Modify your own build tools to use the custom Flexcover SDK </li></ul><ul><li>Install the CoverageViewer AIR Application </li></ul>
  23. 23. FlexCover <ul><li>Run Tests </li></ul><ul><li>The .cvm file will be generated </li></ul>
  24. 24. FlexCover <ul><li>Launch the Coverage Viewer , then click the Load File... button; in the resulting dialog, locate the xxx.cvm file and click Open . </li></ul>
  25. 25. ItDepends <ul><li>ItDepends is a tool for visually exploring the dependencies between classes and packages in an Adobe Flex application, with the aim of making it easy for developers to understand how their application can be made smaller and/or broken up into dynamically loadable modules </li></ul><ul><li> </li></ul><ul><li>ItDepends works with an XML link report file generated by the MXMLC compiler's -link-report option. This file describes all the classes in the application and their dependencies and code sizes. </li></ul>
  26. 26. ItDepends
  27. 27. FlexFormatting <ul><li>Eclipse plugin that provides mxml/actionscript source code formatting </li></ul><ul><li>Update site - </li></ul>Settings
  28. 28. FlexFormatting Example – Before & After
  29. 29. Questions