Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Static Code Analyzers  (Read 2675 times)
0 Members and 1 Guest are viewing this topic.
Offline fletchergames

Senior Duke





« Posted 2011-05-17 21: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


Medals: 350
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2011-05-17 22: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 Coder


Medals: 4



« Reply #2 - Posted 2011-05-18 01: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! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline fletchergames

Senior Duke





« Reply #3 - Posted 2011-05-18 18: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
« Reply #4 - Posted 2011-05-18 19: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 Coder


Medals: 4



« Reply #5 - Posted 2011-05-19 01:11:09 »

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

Current project - Rename and Sort
Offline fletchergames

Senior Duke





« Reply #6 - Posted 2011-05-23 03: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
« Reply #7 - Posted 2011-05-23 08: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
« Reply #8 - Posted 2011-08-16 03: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]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (36 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (27 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (77 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!