Friday, June 1, 2012

Problem commiting the code

Recently I faced this problem of committing one of the source files which I edited. It was checked-out recently and hadn't done any changes by me before.
I used netbeans as the IDE and when I tried to commit it says the authentication failed and keep asking for the login again and again.
The using Tortoise SVN tried to commit the source file from the folder structure and still got this error message.

Commit
Commit failed (details follow):
Aborting commit: 'D:\level4\final year
project\Project\versionMay28\DHT\src\dhtserverclient\ServerUI.java' remains in conflict

I put lot of time to figure out the error, but at the end it was some piece of cake.
In your google code it clearly says if you are a committer you need to checkout the source using https:// address. For non-members they can use http:// address and this is a read-only copy and you can't commit. My bad I didn't notice this before. So don't waste your time hereafter... :)

Friday, March 9, 2012

Finding Bad Smells in Code

Recently we did an assignment on finding bad smells in code. For this I and my colleagues found couple of tools which we can do this task. This was very useful when your source code is way too big as you don't have to go through each and every bit of code. So for the benefit of the people who is reading I would briefly mention the tools we have used and some references where you can get more information. keep in mind that all of these tools are only applicable for java source codes.

1.) Code bad Smell detector
As the blog describes this can detect five of the bad smells in a Java code. ( Data Clumps, Switch Statements, Speculative Generality, Message Chains, and Middle Man)
I integrated this to Netbeans and used it.
Following steps describes how to integrate this into netbeans.

-download the source files from here.
-open this source in netbeans. New Project -> Java -> Java Project with existing sources. (Here you can add the extracted source folder which you have downloaded to the project)
-add these jar files to the library folder (if you encounter runtime errors you can add the other jar files here apart from the listed below)
junit-4.4.jar , mysql-connector-java-5.0.4-bin.jar , recoder.jar , commons-httpclient-3.1.jar , commons-logging-1.1.1.jar , commons-codec-1.3.jar
-Go to project properties -> Run -> set the main class to "BadSmellDetector". 
-As arguments set these;
1st arg : give the source code path you want to find the bad smell
2nd arg : -x (for XML output) , -g (for JFrame)

2.) JDeodorant 
an eclipse plugin which can detect four types of bad smells in the code. (Feature Envy, Type Checking, Long Method and God Class) visit the site
-download the plugin from this site. 
-put the jar file to eclipse -> dropins -> plugin directory and start the eclipse and you are ready to go. 
-refer this video to get an idea how you can view each bad smell using this.
 
3.) Vanaraha
this is another eclipse plugin where you can detect the duplicate code. 
 visit the site to download the plugin.
Like I mentioned for JDeodorant you can 
Put the jar file to eclipse -> dropins -> plugin directory and start the eclipse and you are ready to go.

4.) FindBugs
this is another tool can be integrated to your favorite IDE. Some of my colleagues successfully integrated this to IDEA. And I tried implementing this to Netbeans. Here is a blog post written how to integrate the plugin to Netbeans 6.0. For some reason I couldn't integrate this to my version of netbeans (7.0.1).