Author Topic: C++ code analyzer  (Read 13850 times)

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
C++ code analyzer
« on: March 19, 2011, 09:47:10 AM »
There was this one, but I didn't like how it created bunch of files in the project directory. I'd like to find a program that counts the number of lines, possibly the number of classes, functions etc. but doesn't fill the project directory with shit.

dephbokks

  • Newcomer
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: C++ code analyzer
« Reply #1 on: March 19, 2011, 12:07:57 PM »
In the past, I thought I remember you saying that you used Visual Studio for C++. I assume you are still using that. In that case, there is a pretty simple and free one: http://www.techinceptions.com/codemetrics.html. It counts lines as well as many other meaningless metrics.

The only problem is that it works for VS 2008 and not 2010. I am at the half way point: new projects are started in 2010. Old projects are still developed in 2008.

I suppose one could just take your 2010 project and create a 2008 project and add the files; although it could be a pain in the ass. But usually line counting is done over a cigarette and a glass of bourbon on those very special once in a blue moon situations so maybe porting the 2010 project to 2008 could all be part of the ritual.

Hopefully, these people will make an update for VS 2010 since their software is simple and doesn't pollute yr directory structure.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: C++ code analyzer
« Reply #2 on: March 19, 2011, 03:50:15 PM »
I have VC 2010 and not going to change project settings just for that. It's annoying that VC (at least Express) doesn't have any kind of summary of the project. Even old DevC++ had, although I remember it was only per file summary.

dephbokks

  • Newcomer
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: C++ code analyzer
« Reply #3 on: March 19, 2011, 09:32:33 PM »
I found one that works with VS 2010. It has an addin mode and a stand alone mode. I only used the stand alone program with VS 2010 since I felt that had the higher probability of working. All it does, as far as I can tell, is to count lines of code.

http://archive.msdn.microsoft.com/LOCCounter/

I think the regular VS 2010 has the feature of counting lines; at that very least an add-in would be available. But the express addition has neither line counting nor support for using add-ins.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: C++ code analyzer
« Reply #4 on: March 19, 2011, 10:02:07 PM »
All right.. I need to do one myself. Fuck this shit.

dephbokks

  • Newcomer
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: C++ code analyzer
« Reply #5 on: March 20, 2011, 10:30:22 AM »
That's the spirit.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: C++ code analyzer
« Reply #6 on: March 20, 2011, 12:16:11 PM »
Already started it. I let VC create a Windows program stub. It's nice, but my Windows programming skills are bit rusty... besides, there is no resource editing in VC Express, but you can edit the .rc file with a text editor. I guess there is not much to do in gui part, just figuring out how to display stuff and load files.

Z

  • Rogueliker
  • ***
  • Posts: 905
  • Karma: +0/-0
    • View Profile
    • Z's Roguelike Stuff
Re: C++ code analyzer
« Reply #7 on: March 20, 2011, 12:47:52 PM »
Just looking at the sizes of files is enough for me :) And you don't need any tool for that. Maybe you should learn how to use Unix-like tools (also available in Windows from Cygwin or MinGW)? In this case, "wc" is a very simple tool which counts characters, lines, and words for each file; it does not do more complicated things like counting classes, but probably you could use "grep" for that; and there are lots of other helpful tools.

willraman

  • Newcomer
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: C++ code analyzer
« Reply #8 on: March 20, 2011, 08:27:52 PM »
Personally, I'd open up python or some other scripting language I'd need practice with. I think my powershell in windows is getting a little rusty. Implement a regex expression search and count the lines (or lack off). Have it put the results into a MySQL database, then have PHP read and display that. I love a good challenge.

Maybe that is what I'll do when I get my game to beta stage.




Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: C++ code analyzer
« Reply #9 on: March 21, 2011, 08:24:18 AM »
I was reading about text box you should use to display some text, but couldn't find any information how to create one in native API. You get lot of that .NET code showing in searches. I guess a child window should be good also? I don't know.

willraman

  • Newcomer
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: C++ code analyzer
« Reply #10 on: March 26, 2011, 01:07:51 AM »
nm... already mentioned above.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: C++ code analyzer
« Reply #11 on: March 27, 2011, 03:51:43 PM »
Loc Metrics actually works nicely and you can direct the output files to one directory so it doesn't leave stuff in the project directory.

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Re: C++ code analyzer
« Reply #12 on: March 27, 2011, 08:54:32 PM »
My question would be why?  What is it that you hope to learn about the code by counting total number of lines/classes/ect?  I did that when I was a teaching assistant because I needed a way of catching cheaters ;) but I don't see why you would care outside of that scenario.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: C++ code analyzer
« Reply #13 on: March 28, 2011, 06:33:44 AM »
The speed of progress of course. It's not always 1:1 to actual source code size, because sometimes code is removed, but it's accurate enough. Also, I think it's interesting to compare source code sizes to other roguelikes when the project is ready.