Tuesday, April 17, 2012

Code Pro Analytics - A Must Have Tool


Today we all developers keep writing code, and try to write robust code as much as possible. But, due to lack of time and crunch time we never be able to maintain our coding standards. I often thought to hire an assistant for me to just to verify the code I have written is according to standards or not or just mark the code with problems. Anyway after such a long thought processing I started googling the solution to my problem.

I found CodePro in google's java dev tools library.

https://developers.google.com/java-dev-tools/codepro/

How to Install

For the installation of Code Pro you must need eclipse 3.4 or greater version.

Go to this site
https://developers.google.com/java-dev-tools/download-codepro
and copy the URL for installation according to the eclipse version you have on your machine. Once you have copied the URL simply go to my eclipse help menu and click on 'Install new software...' menu item. Once you will click on that, a new window will be appeared on your screen.

Copy the URL into Work with field. Once you will click on add button just followed by the URL field. You will see a list of projects. Select all the projects by checking out the checkboxes and just press 'next' button, which will start the installation.


Once the installation will be finished you will see a dialog box that will ask you to apply the changes or restart the eclipse to apply the changes. At that point of time you should better restart your eclipse to apply the changes.

Once your eclipse restarted, you will see a new menubar item 'CodePro'. Just click on that and you will see a number of submenu items in menu item 'Views'.
As so many features were in that tool but which I found the best, were:

  1. Code Auditing and Code Marking
  2. Code Metrics
  3. Library Dependency Analyzer
  4. Similar Code Finder
Code Auditing & Code Marking

Let's start with the first one, Code Auditing and Code Marking; as I have already told you about the problem that we often face in coding is that what exactly we wrote is according to coding standards or not. Because most of the time we find it messy when we try to figure out a problem after few months of writing code. That what exactly I wrote and what the blunders I have done here it could be better in this way, these are all the thoughts that start bubbling up in our mind once we review our own code after months of writing that.

Code Pro made our lives easier by just giving a view of code audit. You just click on 'Audit' from CodePro's 'Views' menu. A new tab will appear at the console panel of your eclipse, titles as 'Audit'. Click on 'Select Project', a list of all open projects will be available on your screen. Select any of the project you want to audit. I have selected a project already available in my workspace as 'WSClient'. And just after clicking that project I got a complete list of recommendations from the CodePro auditor.




We can directly fix all those problems by just making a right click on the suggestion or even can also see the recommended solution and the reason behind, not to use that.

CodePro auditor give one more favor to the developers that it divides the problems on the basis of severity. Red, Blue and Yellow; Red means high, Yellow means low and Blue flag means trivial. Anyway you will be able to explore more once you will start using it.

Code Metrics
Code Metrics is a feature which gives you the graphical representation of the code you have written and also provides you the quality indicators with a detailed report with graphs about your source code. The best thing I found in that and probably you will find that too is just the separation in the form of groups.
Each group contains detailed information about it's members and also help you in order to identify the line of codes, number of private members, public members, static or non static variables.





Library Dependency Analyzer
When I just saw the result of this view I was simply WOW, a feature I have been waiting since long. Reason being I include too many libraries in my project, but after time I realize that the project doesn't require that much libraries. So, in order to get a dependencies of my code in libraries can be easily seen by this view. As it shows you a complete map of libraries with the project with the number of usage from specific library.



Similar Code Finder
Last but not the least, this is the best way to find the similar code written in classes in over all project. Once, it shows you the result, it gives you a complete overview of code too that you have written similar code more then once. In order to remove the duplicated code you can easily track the code and create common methods to reduce the LOC of project


Weaknesses

This tool is awesome but, I found few places where this place doesn't do well, like it doesn't identify missing comments and annotations and class level comments. I am not sure about as I didn't explore it that well but, these are my thought on experience as till now I didn't find the following stuff in that.

No comments:

Post a Comment