Ignore Duplications within Javadoc

java
maven
scanner

(Tony Lopez) #1

As far as I am aware, there is not great support for preventing the duplication of Javadoc in certain scenarios. The specific use case is that we have custom Java annotations that use similar Javadoc, and these annotations are not supported with an Inheritance model.

Example:

/**
  * <p> Provides support for SampleAnnotation1.
  * <p> Unique Info about SampleAnnotation1.
  * <p> [Duplicated Info 1]
  * <p> [Duplicated Info 2]
  */
public interface SampleAnnotation1 {
    ...
}

/**
  * <p> Provides support for SampleAnnotation2.
  * <p> Unique Info about SampleAnnotation 2.
  * <p> [Duplicated Info 1]
  * <p> [Duplicated Info 2]
  */
public interface SampleAnnotation2 {
    ...
}

When reviewing duplication reports within SonarQube, depending on the amount of duplicated text in [Duplicated Info 1] or [Duplicated Info 2] these lines will be marked as duplicates.

While it is possible to duplications given paths using sonar.cpd.exclusions, this doesn’t quite seem appropriate.

Is it possible to ignore duplications in Javadoc for such an example as provided above?

Notes:
Using SonarQube Scanner for Maven(Maven 3.5.0.1254).