Saturday, September 21, 2013

FindBug Installation : URL based Installation :


FindBug Installation : URL based Installation :

Step 1 : Go to eclipse Help ---->Install New Software










Step 2 : Use the Url  http://findbugs.cs.umd.edu/eclipse to put into 'Work with'  input field .
Click on  Add Button



Step 3: Fill the Name field with 'Findbug'



Step 4 : Click on Select All option /Or Select the appropriate version and then click next




Step 4: Accept the Agreement





Step 5 : Click Ok




Step 6 : Restart the Eclipse


Thursday, September 19, 2013

Why to Use Findbugs ,PMD and Checkstyle ?


PMD works on source code and therefore finds problems like: violation of naming conventions, lack of curly braces, misplaced null check, long parameter list, unnecessary constructor, missing break in switch, etc. PMD also tells you about the Cyclomatic complexity of your code which I find very helpful (FindBugs doesn't tell you about the Cyclomatic complexity).

FindBugs works on bytecode. Here are some problems FindBugs finds which PMD doesn't: equals() method fails on subtypes, clone method may return null, reference comparison of Boolean values, impossible cast, 32bit int shifted by an amount not in the range of 0-31, a collection which contains itself, equals method always returns true, an infinite loop, etc.
Usually each of them finds a different set of problems. Use both. These tools taught me a lot about how to write good Java code.

Checkstyle : The programming style adopted by a software development project can help to comply with good programming practices which improve the code quality, readability, re-usability, and reduce the cost of development.

Sonar will run CheckStyle, FindBugs and PMD, as well as a few other "plugins" such as Cobertura (code coverage) by default for Java projects. The main advntage is that it stores the history in a database. You can then see the trend

Summery : Conventions (Checkstyle) / Bad practices (PMD) / Potential bugs (FindBugs) .

Monday, September 2, 2013

Creating Finders method and Custom Queries







Creating Finders method and Custom Queries

Process For Finders method
 if you have some Finder methods do the entries like this
After running the service builder build on service.xml
(Copy and paste from XXXLocalServiceUtil ---->  XXXLocalServiceImpl  ) (change accordingly)
Then again  run service builder build .


Copy the finder function from XXXLocalServiceUtil

 public static java.util.List findByN_S(
        java.lang.String name, int status)
        throws com.liferay.portal.kernel.exception.SystemException {
        return getService().findByN_S(name, status);
    }

To XXXLocalServiceImpl after changing in following way

public java.util.List findByN_S(
            java.lang.String name, int status)
            throws com.liferay.portal.kernel.exception.SystemException {
            return ModOrganizationUtil.findByN_S(name, status);
    }

Process For Custom Queries method
Similerly if you have some custom queries for those function do the entries like this
(Copy and paste from XXXFinderImpl  ----->  XXXLocalServiceImpl) (change accordingly)
 Then again  run service builder build .

   public int searchOrg1stLevelCount(String name, String partnerKey, int status,
            java.util.LinkedHashMap searchParams, boolean isAndOperator)
            throws com.liferay.portal.kernel.exception.SystemException {
        return ModOrganizationFinderUtil.searchOrg1stLevelCount(name, partnerKey, status, searchParams, isAndOperator);
    }