Can I dynamically calculate technical debt?
Asked Answered
S

3

10

I have a large number of individual, unrelated Java programs in a "Programs" folder, and I'd really like to be able to calculate a technical debt score automatically for each individual program. I understand that SonarQube can allow you to do this (kind of) with Sonar-Runner, however I would really like a way to do this dynamically, so I can have a script analyze and write technical debt scores of all the programs within the "Programs" folder into a csv.

I am perfectly willing and happy to try any other sort of technical debt software (or quality for that matter) if it can do this for me. I would just really appreciate any input, or thoughts about if this would even be possible?

Sillimanite answered 24/11, 2013 at 22:40 Comment(2)
Do they all use the same project structure? Like maybe they all use Maven and it's associated conventions? If not it's nearly impossible to have one tool to dynamically detect things like source code folders, unit test folders, which Java compiler version to use etc. etc..Rattlebrain
+1 for a very interesting question. I do wonder however whether the lower limit on error for automated TD estimation is so high that meaningful results are elusiveMackinnon
T
4

Yes you can, Sonar is a code analysis tool and has plugins that can even estimate technical debt in man hours or dollars. Really easy to setup and run, you just download it, extract it and start (comes with an internal DB, so no extra dependencies of configurations required). Then if you use maven, you add this to your pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
    <version>2.0</version>
</plugin>

and run:

maven sonar:sonar

Sonar will then show you all sorts of useful info about your code, include technical debt.

------ Update 1 ------

If you have multiple projects (assuming they are maven), you can make them all children of one parent project and run mvn sonar:sonar on the parent, it will analyze all the children for you. Here is an example of multiple projects.

Trying answered 3/12, 2013 at 22:58 Comment(1)
The example is now blocked by Sonar's "paywall" :(Massarelli
R
0

The Eclipse Metrics plugin may get you close to what you're looking for. It'll give you a health check on your projects by reporting on different types of complexity (coupling, cyclomatic complexity, cohesion, length of methods and so on).

From their page:

This Eclipse plugin calculates various metrics for your code during build cycles and warns you, via the Problems view, of 'range violations' for each metric. This allows you to stay continuously aware of the health of your code base. You may also export the metrics to HTML for public display or to CSV or XML format for further analysis. This export can be performed from within Eclipse or using an Ant task.

http://eclipse-metrics.sourceforge.net/

Rusch answered 27/11, 2013 at 23:57 Comment(0)
S
0

These answers were all great, but not exactly what I was looking for. I was able to create my own work around:

  1. When I'm creating the java projects, I have a java class that automatically writes a sonar-properties.properties file to each individual project.

  2. I then start the sonar server (through command prompt)

  3. I then wrote a script that drills through directories looking for the sonar-properties.properties files. When if finds one, it launches sonar-runner.

Note, The properties file has a project key that corresponds to the project (so each project I'm trying to analyze has it's own project key) - and so then I can simply go to localhost and see a link for each properties file I created.

Sillimanite answered 31/1, 2014 at 22:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.