import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
public class CoverageMeasurementFilter implements MeasurementFilter {
+ private static final Logger LOG = LoggerFactory.getLogger(CoverageMeasurementFilter.class);
+
private final Settings settings;
private final ImmutableSet<Metric> coverageMetrics;
private Collection<WildcardPattern> resourcePatterns;
public CoverageMeasurementFilter(Settings settings,
- CoverageDecorator coverageDecorator,
- LineCoverageDecorator lineCoverageDecorator,
- BranchCoverageDecorator branchCoverageDecorator) {
+ CoverageDecorator coverageDecorator,
+ LineCoverageDecorator lineCoverageDecorator,
+ BranchCoverageDecorator branchCoverageDecorator) {
this.settings = settings;
this.coverageMetrics = ImmutableSet.<Metric>builder()
.addAll(coverageDecorator.generatedMetrics())
@VisibleForTesting
final void initPatterns() {
Builder<WildcardPattern> builder = ImmutableList.builder();
- for (String pattern : settings.getStringArray("sonar.coverage.exclusions")) {
+ for (String pattern : settings.getStringArray(CoreProperties.PROJECT_COVERAGE_EXCLUSIONS_PROPERTY)) {
builder.add(WildcardPattern.create(pattern));
}
resourcePatterns = builder.build();
+ log("Excluded sources for coverage: ", resourcePatterns);
+ }
+
+ private void log(String title, Collection<WildcardPattern> patterns) {
+ if (!patterns.isEmpty()) {
+ LOG.info(title);
+ for (WildcardPattern pattern : patterns) {
+ LOG.info(" " + pattern);
+ }
+ }
}
}
import org.sonar.api.scan.filesystem.FileExclusions;
public class ExclusionFilters implements BatchComponent {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ExclusionFilters.class);
+
private final FileExclusions exclusionSettings;
private PathPattern[] mainInclusions;
private void log(String title, PathPattern[] patterns) {
if (patterns.length > 0) {
- Logger log = LoggerFactory.getLogger(ExclusionFilters.class);
- log.info(title);
+ LOG.info(title);
for (PathPattern pattern : patterns) {
- log.info(" " + pattern);
+ LOG.info(" " + pattern);
}
}
}
String PROJECT_DATE_PROPERTY = "sonar.projectDate";
/**
- * @deprecated since 4.2 project are now multi-language
+ * @deprecated since 4.2 projects are now multi-language
*/
@Deprecated
String PROJECT_LANGUAGE_PROPERTY = "sonar.language";
String PROJECT_INCLUSIONS_PROPERTY = "sonar.inclusions";
String PROJECT_EXCLUSIONS_PROPERTY = "sonar.exclusions";
+ /* Coverage exclusions */
+ String PROJECT_COVERAGE_EXCLUSIONS_PROPERTY = "sonar.coverage.exclusions";
+
/**
* @since 3.3
*/