Access the duplication data

14 views
Skip to first unread message

hannes.t...@gmail.com

unread,
Apr 12, 2016, 7:48:05 AM4/12/16
to SonarQube
Hello,
i am currently working on a plugin that offers extended capabilities for duplications on Sonarqube 5.4.
This includes new metrics as graphs for which i need access to the real results of the CPD (duplication data).

I have tried three ways but miserably failed, mostly because of deprecations (and missing redirections to replacements) or missing documentation on the new modules. 

First approach was to use the internally used PMD CPD by providing the wrapper and accessing the DUPLICATION_DATA metric later in a measure computer -> deprecated but no redirection to alternatives

As i did not find a way to overcome the problem and peeking at the next version of sonarqube revealed that PMD CPD will be deprecated, i decided to use an external tool to stay flexible and mostly independent of big API changes.
Therefore i tried to use the ReportPublisher to report the duplication's and to reuse everything else, nevertheless it cannot be injected (even though it has @BatchSide).

After that i found out the web service api offers access to the duplications which works obviously but can only be applied file-wise. Furthermore it has to happen in a measure computer to guarantee that the CPD run already (or can the order be defined?).

Is there no direct clean way to access the duplication data? 
The preferred way would be an external CPD as CPD tools have great differences in their capabilities results and this would offer full control, but how can i report my results such that they are reused by the remainder?

Thanks,
Hannes

Julien HENRY

unread,
Apr 12, 2016, 8:48:52 AM4/12/16
to SonarQube, hannes.t...@gmail.com
Hi Hannes,

The current duplication implementation is not extensible. We have plans to introduce an API that would let sensors provide different duplication based on their own algorithm.

But this is not scheduled yet.

++

Julien

hannes.t...@gmail.com

unread,
Apr 12, 2016, 8:52:44 AM4/12/16
to SonarQube, hannes.t...@gmail.com
Thank you for the reply.

Is it possible to access the data via injection or is the web service the only way?

Julien HENRY

unread,
Apr 12, 2016, 9:05:26 AM4/12/16
to SonarQube, hannes.t...@gmail.com
Accessing data using WS is for post processing only (analysis was already processed and stored in database).

If you want to do some processing/aggregation while still being part of the analysis you can't use a WS. But I don't think there is an API to access duplication data (it used to be stored in a measure but as you noticed it was an abuse of the concept of measure and so was deprecated).

Hannes Thaller

unread,
Apr 12, 2016, 9:36:44 AM4/12/16
to Julien HENRY, SonarQube
Ok, thanks for the clarification and the fast support.
--

Hannes Thaller
Student Researcher
Institute for Software Systems Engineering

JOHANNES KEPLER
UNIVERSITY LINZ

Altenberger Straße 69
Science Park 3, 0245
4040 Linz, Austria
+43 732 2468 4396

hannes....@jku.at
www.jku.at

Reply all
Reply to author
Forward
0 new messages