Code metrics and warnings for C++ [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I have a pretty new code base written in C++. Already I'm starting to see some bad practices creeping into the project (class file with 1000+ lines of code, functions with a lot of parameters, ...).
I would like to stop on these right away with some automated tools which can hook into the build and check for poor coding practices. What suggestions do you have for such tools? I'm interested in metrics but really more interested in a stylistic sort of lint which would highlight functions with 37 parameters.

I'm sorry I can't help you with respect to style, but a great metrics tool which supports C++ and is free: SourceMonitor.
In particular, you will get good info like Cyclomatic Complexity (which I find of more value for bad programming practice than number of parameters), as well as lines of code, percentage of comments, longest function, etc.
Give it a try -- and it is very fast as well.

As with the others I'm not sure of a tool that will judge style. But CCCC will produce numerous metrics that can help you find the trouble spots. Metrics like cyclomatic complexity will give you quantitative evidence where the problem spots are. The downside is that you will have to incorporate these metrics with a style guide that you adopt or create on your own.

Metrix++ matches this use case and has got several metrics you are probably interested in. Check it here: http://metrixplusplus.sourceforge.net/

Make sure that you always compile with -Wall compiler option and make it practice that no code is to be checked in if warnings persist.
Find a standard style to follow like this one.

Related

how do I make the jump from understanding C++ as a language to understanding all the acronyms that go with job postings [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Improve this question
This is a difficult question to phrase, but hopefully I can make it more transparent. Basically, I've taught myself (after a couple of grounding classes in college) how to write and compile C++ code. I have written a small handful of actual programs in Visual Studio and learned to compile them as standalone EXEs. I feel competent that if someone came up to me and said "I want you to have a program that does X, Y, and Z within the confines of the standard library," I would be able to figure it out and present something.
However, there appears to be a chasm between this and what I see when I check out Freelancer.com, Craigslist, and other sites for jobs, internships, and gigs. There are acronyms and references to I'm-not-sure-what (example post here: https://www.freelancer.com/projects/Data-Processing-CPlusPlus-Programming/Build-hash-table-using-chaining.html)
Basically, it's fine if everyone agrees there's a chasm here. I just want to know where to look to find the bridge :) Any reading materials / specific online class / etc. that I could look into? Any assistance would be stupendous.
Thanks!
The answer is simple, experience. You don't have a lot yet, and its a lifelong process.
There is no secret, or shortcut, besides reading and participation and doing. Just like learning new vocabulary words, when someone uses a term you don't know, either look it up, or ask them to explain.
Until you are comfortable with those acronyms, you probably want to stay away from a job ad that explicitly requires that particular skillset, because a good interviewer will figure out if you just Googled something last night or if you used it for the past 3 years on a project. Instead, look for junior programming jobs that care more about getting an energetic grad with a good ethic, and low salary requirements than a senior person. Good luck.

finding static scheduling of DAG for multiprocessors - library? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I have a graph of the dependencies of all tasks, and the costs of each task. Now I want to calculate a scheduling for a given amount of CPUs. I've found many papers on scheduling algorithms, optimal schedulers seem to be too expensive for my problem size (around 100 nodes) as it's an NP-hard problem. I'd settle for a heuristic, preferably one that has a bound how close it gets to the optimum. My problem now is: do I really have to code it myself?? This should have been solved many times before, it can be easily applied to project management, maybe there something exists?
If you happen to know a library in python that'd be perfect or the next best thing would be C++, otherwise i'd settle for anything else.
This is a pretty common problem. It also shows up in hardware design.
There has been a lot of work on algorithms to solve it.
If you are going to write something yourself, start by checking out "Hu's Algorithm".
If you just want a solution, these functions are built into architectural synthesis programs.
Look at the Wikipedia pages on high level synthesis and logic synthesis.
There are several professional tools that can handle this, if you can get access to them through school or work.
There are university programs you can often get for free that can also handle this problem.
I'm not up-to-date on what is currently available. An very old one is MIS II from Berkeley. It's scripting language was Tcl, not Python.

Is there any FOSS tool to reliably create a UML model from existing c++ code? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I have tried Umbrello and ArgoUML; and both are unable to generate code from an existing c++ codebase. Though they have limited capabilities in these areas, they both fail spectacularly importing a file with std, boost, SDL and local includes. Is there anything in the FOSS world that will model reasonably complex c++ code. The UML part is optional, generating coherent and accurate visualizations of the code is what matters.
Note: Tools like gprof2dot as well as doxygen can process the source, but their output is so complex as to be equivalently difficult to grasp as the original code.
Note2: Since one cannot ask about tools on SO anymore, let me rephrase the question like this:
How, given a large, old, complex and crufty c++ code base, can one quickly and efficiently perform major refactorings. By major, I mean things like:
extracting entire structs/enums/classes from an existing source/header pair into their own files
adding/deleting namespaces
changing function signatures
etc.
Some things are approachable with grep and sed; however, discovering and managing include dependencies can be overwhelming. I'm currently stuck with the "change-and-fix" method -- try refactoring something and iteratively build and fix errors as the compiler point them out. For widely used objects, this is slow. What is the proper approach?
I used Doxygen for this on a couple of projects.
It wasn't great but it was better than starting from scratch.
This paper from 2005 describes the pilfer tool, which is now included within the srctools project. It's available under a GNU General Public License.

Manual Decompilation References [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm looking for book titles or papers about how to decompile X86 Disassembly into C/C++ code MANUALLY.
Well , I know about many tools that do the job , but I think doing it manually is more efficient even if it's a slow process.
If you are VERY used to looking at disassembly from a particular compiler, you MAY be able to come up with decent C or C++ code. But it's a TERRIBLY slow process even then. Just taking one small function (say a for-loop, a couple of if-statements and some basic math) and reconstructing it back into source code can take half an hour for me, and I don't think I'm terribly bad at it. Of course, one of the main points is identifying commonly used algorithms, such as linked lists, binary trees, string management, vector management, etc.
Doing it by machine will give you a lot of the work done for you, but even then, it can take days to do even a few hundred lines of orginal C++ code into something that is actually readable.

A C++ source code analyzer [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Could you suggest some open source tools that analyze C++ code and checks the following rules:
naming conventions,
file inclusions,
function design,
data types,
flow control,
memory allocation,
file handling,
portable code,
runs under Solaris or SUSE
http://www.google.com/search?q=misra+checker
Of course, if the rules you're trying to enforce don't exactly match someone else's idea of a coding standard, no existing tool is going to work.
It is still in early development (especially for C++) but its improving rapidly and is a really interesting open source project in a vibrant community. So see if the CLang Static Analyzer does what you need.
I have used coverity (http://coverity.com/)in my organization. It does static bug check analysis and I found it to be very useful. It is highly customization and provides a number of checks. I am not entirely sure if it works on solaris or not but I would recommend checking it out.