What is a Good Open Source Code Analysis Tool?
carlmenezes asks: "I volunteer when I can to help a poor educational institution in India with their computing needs. As you can imagine, most computers are from donations and very little money (if any) can be spent on software licensing. Therefore, the installed software is all Open Source and I do all of the software installation by myself. I have already installed Linux on 16 PCs, with Firefox. The default desktop is KDE and the kdeedu package (klettres in particular) has several loyal fans. Incidentally, the kids don't find it hard to use at all and the lack of 3D doesn't bother them in the least :) I would like to ask the community about a good source code analysis tool. I have already installed Source Navigator. Is there any other comparable open source tool?"
"The analysis tools would be for those students that show more interest than the others in programming. There is a lot of source code in there for them to look at it if they want to. I'm looking more at C/C++ than anything else. There are some very bright students and I would like them to be able to move beyond ordinary school programming if they feel like it. No, there is no Internet connection. I bring in the software on CDs and install it."
You want us to help you to turn out another generation of cheap Indian IT workers to put us out of jobs? How stupid do you think we are?
The following posts will answer the last question.
There are two very good open source IDEs for Java, NetBeans and Eclipse (I personally prefer Eclipse).
If you're teaching beginners how to program, Java is simpler anyway. You don't have to understand memory allocation and pointers because it's all taken care of for you. Also you can write non-object-oriented programs to start with by making all functions static.
This way you can start with very simple programs and work your way up to introducing more advanced concepts, like object-oriented, or memory allocation etc.
If you insist on learning with C/C++, I would lobby with the executives at a company like Borland. They usually have the power to throw a few copies your way, as long as they're convinced that it is a philanthropic effort (it makes them look good).
There are 2 kinds of people in this world. Those that can keep their train of thought,
seriously, pick an application everyone like, bring in the source, and have the students give it a new feature or fix a bug. Any text editor should be sufficient.
Maybe I didn't fully understand your question, so please correct me if I am mistaken.
But what about popular C/C++ IDE's as KDevelop and Anjuta? Are those not the sort of tools you're looking for?
I find that snavigator is quite good for source analysis. If you want a "lighter" tool, cscope can be used. But snavigator also support fortran, cobol &etc "out of the box".
So, I think that its a fine tool for teaching. Most other "IDE"s tie you in to a particular system or language, which snavigator doesn't. I've used it for the Linux kernel, Solaris, and Windows (among other things).
Its a bit slow building its cross-reference database, though, so for larger source bases you do want access to a "big" machine. You can share the results after the xref is built (the same is possible with cscope).
Good luck with your project!
Ratboy.
Just another "Cubible(sic) Joe" 2 17 3061
From the Split (a modern version of Lint) web site:
-73, de n1ywb
www.n1ywb.com
P.
If you didn't understand it, I didn't either. But I think you're correct.
Source-Navigator's "analysis" seems to be to "display relationships between classes and functions and members, and display call trees." Most IDEs will have this functionality, including KDevelop and Anjuta. I'm partial to Anjuta myself, but they are already using KDE. KDevelop would be the natural choice.
Just do the following:
...)
:]
p iness:)
1) Learn how to program.
-- nuf said.
2) Write clean code
-- Proper indenting **
-- sufficient commenting
3) Less code is more
-- More lines is more intimidating that less
-- However, there is a limits (ie Perl)
-- More you can fit on one screen the easier to debug
4) Be a structured programmer
-- It should not matter what language you are programming in. The structures should always be the same.
5) Learn and use language level error handling
-- This will enable you to fully understand how to debug your code
-- Stack traces are a must for any procedural or OO code
6) Make your programs chatty
-- Log files are good but make sure there is a way to easily turn off logging features so that you can speed up programs when you are happy.
7) Learn how to tail log files
-- tail is available on every operating system
--- GNUUtils for win32
--- *nix (Linux, Unix, OSX
8) Write blind code as much as possible
-- IDE's are very powerful but I always write all my code in a text editor totally blind (no compilation, syntax validation...)
-- If you become dependant on the system to tell you what is wrong, you will not learn to SEE the problem.
--- Often times, when I get an error and I know I just changed a piece of code I will not even read the error. I'll just look at the line of code that I changed and visually look for the error. If you don't learn how to do this, then programming probably is not for you.
9) Got errors, don't worry
-- All coders get errors.
-- Only a few times I have written dozens of lines of blind code and not gotten at least one error. I was amazed when I did.
-- Don't get stressed out. Just be pragmatic and move being objective with the error.
That's probably a good start.
Personally I would not trust programs in telling me where coding problems are anyhow. I find it akin to using anti-spyware programs on a win32 box where it would be easier to just not use IE and be more concious of the operating system we use. The latter takes a little more understanding but in the end all will be better
JsD
(Java+Python+ObjC-on-BSD-with-firefox==hap
valgrind and associated add-ons, are absolutely amazing and quite useful for C and C++ programming.
Nobody should be caught dead writing C++ programming without at least knowing about Boost's libraries. Not really analysis tools but useful nevertheless.
Oceania has always been at war with Eastasia.
lxr (http://lxr.linux.no/) was dveloped with the kernel in mind, but now it works with any C, C++, python, perl and other laguajes (those supported by exuberant-ctags). I used it in several projects and, in conjunction with tabbed browsing, I think it's all I need. Dependencies are: mysql, perl, apache, exuberant-ctags.
If you're using Java... "PMD is a Java source code analyzer. It finds unused variables, empty catch blocks, unnecessary object creation, and so forth. "
http://sourceforge.net/projects/pmd/
The friendliest digital photography forums on the net!
http://home.comcast.net/~jyavner/myer/
When you're afraid to download music illegally in your own home, then the terrorists have won!
LXR (or linux cross reference) was originally designed to cross reference the Linux kernel, but does C code in general. Check it out at their website.
Joshua J. Kugler
CPD from the same place provides some of the facilities for C code. I have used it on OpenOffice.org.
The gcc compiler has quite a number of checks built into it. For example uninitialised variables checks if you use -Wuninitialise. A good first pass on code is to compile -Wall and clean up the problems reported.
You might want to read Steve McConnell on writing solid code to see a full explanation as to why.
If your students want to examine existing code, AutoDia will generate UML class diagrams from source code in a variety of languages. Output is normally in Dia format but others are supported as well.
It's written as a set of Perl scripts so you'll need a perl installation on the machine.
- Blah blah blah, missing scientist. Blah blah blah, atomic bomb. -
ncc which is a static analyser. It is very interesting because it also analyses pointers to functions and the values assigned to them!
I was sceptical at first (it looked too much like a 'toy'), but jGRASP has proven surprisingly useful for getting to grips with legacy C code (reams and reams of 1000+ line functions with nested ifs and cases). It should be useful for teaching purposes too, since it allows collapsing bits of code to show the underlying structure, and handles block exits better than a folding editor would
Great for browsing someone elses sloppy code:
http://www.stack.nl/~dimitri/doxygen/
Begone foul troll!! Java is the work of the devil!! And eclipse is its dark whore, complete with multiple blasphemous plugins! Repent! Install perl and ye may yet be saved. Turn back now from the dark path of restricted languages and walk the path of the true believers.
In short, I disagree that Java is easier to teach to beginners. Not only must they immendiatly grasp object orientation and functions, they must also work with Java's quite restrictive language constructs. I do agree that C++ is not a very good languages for beginners. C maybe, with some STL added. I would still be of the opinion that beginners are best starting off with BASIC or perl(without mentioning regular expressions). They need a language that starts very simple so they can wrap ther heads around programming and start spitting out a few programs, without getting bogged down by advanced concepts.
May the Maths Be with you!
Doxygen is fantastic for source code browsing. http://www.doxygen.org
There\'s no place like ~
I agree Java is a bad language to teach beginners, tho.
"Avoid employing unlucky people - throw half of the pile of CVs in the bin without reading them." -- David Brent
see: http://spinroot.com/uno/ for an overview of similar tools, see also: http://spinroot.com/static/