Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Static Code Analyzers  (Read 1766 times)
0 Members and 2 Guests are viewing this topic.
Offline fletchergames

JGO Ninja
***

Posts: 553



« on: 2011-05-17 17:34:30 »

I'm trying to use static code analyzers to streamline my code and make it more readable.  The code's supposed to be open source, and I want it to actually be useable.

This isn't about performance so much as usability, but I wasn't sure where else to put this.

I've been getting my static code analyzers in the form of eclipse plug-ins.

First, I tried Unnecessary Code Detector (http://www.ucdetector.org/).  This worked pretty well.  I shut off all the warnings about changing visibility because most of them seemed unimportant, but I found the plug-in useful for removing unused code.  It also helped me find a few class stubs that I had created with the intention of implementing specific features.  I now have these specific features listed on my todo list so that I can implement them.

It also has the ability to check for dependency cycles (where class A calls class B and class B also calls class A).  Limiting dependencies is desireable, though I didn't do much with this.  It simply wasn't worth the time sorting out the mess.  Some of the cycles are perfectly acceptable for various reasons.

Second, I tried PMD (http://pmd.sourceforge.net/).  This found a ridiculous number of problems, most of which seem to be about obscure code style issues that seem somewhat arbitrary to me.  I am changing some of my code to match their naming conventions and such, but many of the warnings appear to be unimportant.

Does anyone have any advice about any other static code analyzer plug-ins to use or any comments about their experiences with static code analysis?
Offline ra4king

JGO Kernel
*****

Posts: 3160
Medals: 196


I'm the King!


« Reply #1 on: 2011-05-17 18:13:51 »

Haha I have never had any code problems. I usually set rules for what my naming and code style should be when I work on something so my code is always neat and tidy when I look back Cheesy

Offline zammbi

JGO Strike Force
***

Posts: 963
Medals: 9



« Reply #2 on: 2011-05-17 21:15:01 »

I used pmd but found it too annoying.

I basically just use findbugs.

Current project - Rename and Sort
Games published by our own members! Go get 'em!
Offline fletchergames

JGO Ninja
***

Posts: 553



« Reply #3 on: 2011-05-18 14:28:11 »

I'm installing Find Bugs and will try it out tomorrow or Friday.  Even if it just catches a couple of things I want to change, it's worth trying out.

Thanks!
Offline Spasi

JGO Ninja
***

Posts: 589
Medals: 26


Molon Lave


« Reply #4 on: 2011-05-18 15:01:29 »

The community edition of IntelliJ IDEA has everything you need, except duplicate code detection. Everything's configurable too, so for example you can automatically format your code the way you like, use only the inspections that are interesting to you, etc.
Offline zammbi

JGO Strike Force
***

Posts: 963
Medals: 9



« Reply #5 on: 2011-05-18 21:11:09 »

Oh yes IntelliJ IDEA also was quite good in picking things that findbugs missed.

Current project - Rename and Sort
Offline fletchergames

JGO Ninja
***

Posts: 553



« Reply #6 on: 2011-05-22 23:47:20 »

Find Bugs appears to be working out ok.  It isn't going to change anything drastically, but I'm rearranging some of my code.  It's relatively easy to locate problems with all these tools unless they find a superabundance of warnings about nothing.  Fortunately, you can turn most of that stuff off.

I don't think I want to go so far as to switch to a different IDE to get better static code analyzers.  It looks like I can use the IntelliJ IDEA for free because I'm making an open source game, but I don't want to encounter problems if I suddenly decide to use the same engine to make a shareware game.  I could just buy the IDE, but I don't want it badly enough.
Offline Spasi

JGO Ninja
***

Posts: 589
Medals: 26


Molon Lave


« Reply #7 on: 2011-05-23 04:42:10 »

It looks like I can use the IntelliJ IDEA for free because I'm making an open source game, but I don't want to encounter problems if I suddenly decide to use the same engine to make a shareware game.  I could just buy the IDE, but I don't want it badly enough.

That only applies to the Ultimate edition, which is really targeted to web/enterprise development. You can use the Community edition just like you use Eclipse. Going all the way and switching IDEs is very hard for any developer and a personal matter really, bu in this case I highly recommended giving IDEA a try. You could at least use it on the side just for its inspection and quick-fix features.
Offline Cero

JGO Neuromancer
****

Posts: 1050
Medals: 18



« Reply #8 on: 2011-08-15 23:21:58 »

eclipse warnings -> Find Bugs -> PMD

generally I have no eclipse or find bugs warnings
having no PMD warnings should be impossible, I think its a great tool, just don't take it too seriously

although find bugs has a problem with java 7, in that every System.out or .err are null pointer for it
kinda annoying

Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.079 seconds with 19 queries.