4

Another title might be: determine strongest candidates for 100% test coverage. I'm looking for a tool that will display the methods/functions that are most depended on by my code base. To be clear, I'm looking for internal dependencies, not external. The idea is to ensure that the most depended-on code written has full test coverage, or at least high priority for testing.

I believe this is related to cyclomatic complexity. I presume a tool that is checking code paths should be able to compute which code shows up in the most paths. But I haven't seen a tool that does this. Java/JVM preferred, but curious for any language.

  • What do you expect from those tools? Can you provide such the tool's report example? What valuable and measurable metrics do you expect? – Alexey R. Mar 20 '18 at 9:39
  • Am I correct in thinking you are looking for a tool that will report that for example function abc() is called in 50 classes where function xyz() is called in 10 classes? – Kate Paulk Mar 20 '18 at 11:50
  • @KatePaulk is has the gist of it, although having the number of 2nd, 3rd, etc. level calls is important, too. Maybe it's only called by one function, but the caller is heavily depended upon. – Philip Mar 20 '18 at 18:01
1

Since you mention cyclomatic complexity, I'm assuming you are looking for some kind of static code call path analyzer.

Code in any language is tough to do path analysis on, especially static. Following call paths needs, as a simple example, to take into account imported modules so the correct method with a given name (that can appear in many modules) is analyzed for its calls.

Path analysis on running coding trips over having to actually traverse paths that you may be interested in.

I've been on the hunt for such a tool myself for Python. Haven't found one that fills my needs, static or dynamic. Still looking.

1

Tag 'em

Develop a tag schema that can be applied to the classes and methods and scripts in the various codebases and leaves evidence in artifacts such as logs from production.

Then analyze that data to know what's called when and how often.

You could do this for a subset of traffic and/or a subset of time to get a good sample.

Not a complete answer to 'number of dependencies' but will provide data that will help you get there, actions will depend on results of your analysis.

0

Why do you think that goal of coverage is 100%? Due to law of Diminishing returns, increasing coverage in other modules is more beneficial that 100% coverage in few.

Also, cyclomatic complexity cannot guesstimate which code is used most by your users.

You need to collect the usage info, and aim for higher coverage for most often used modules (determined not by guess, but by profiling). Example: 90% coverage (excluding exception handling) for top 10% of modules by usage, 80% for next 20%, and 60-70% for the rest. And of course track and note if code change decreased the coverage.

There cannot be a tool, because too many guesses are involved. So do your best guesses, using expert opinion.

  • Good answer but I don't see how it is answering the question – Rsf Aug 19 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.