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?

Nilesh
  • 3,938
  • 6
  • 35
  • 52
mdoc-2011
  • 1,945
  • 3
  • 17
  • 36
  • 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.. – NickDK Nov 29 '13 at 13:56
  • +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 elusive – Brad Thomas Dec 04 '13 at 14:31

3 Answers3

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.

SergeyB
  • 8,363
  • 3
  • 31
  • 45
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/

Matt Crinklaw-Vogt
  • 10,580
  • 5
  • 39
  • 44
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.

mdoc-2011
  • 1,945
  • 3
  • 17
  • 36