*/
package org.sonar.batch.rule;
-import com.google.common.collect.Maps;
import org.sonar.api.batch.Decorator;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.batch.DependsUpon;
return;
}
- // Load current profiles
- Measure currentMeasure = context.getMeasure(CoreMetrics.QUALITY_PROFILES);
- Map<String, QProfile> currentProfiles = UsedQProfiles.fromJson(currentMeasure.getData()).profilesByKey();
-
// Load previous profiles
- Map<String, QProfile> previousProfiles = Maps.newHashMap();
Measure previousMeasure = getPreviousMeasure(resource, CoreMetrics.QUALITY_PROFILES);
- if (previousMeasure != null && previousMeasure.getData() != null) {
- previousProfiles = UsedQProfiles.fromJson(previousMeasure.getData()).profilesByKey();
+ if (previousMeasure == null || previousMeasure.getData() == null) {
+ // first analysis -> do not generate events
+ return;
}
+ Map<String, QProfile> previousProfiles = UsedQProfiles.fromJson(previousMeasure.getData()).profilesByKey();
+
+ // Load current profiles
+ Measure currentMeasure = context.getMeasure(CoreMetrics.QUALITY_PROFILES);
+ Map<String, QProfile> currentProfiles = UsedQProfiles.fromJson(currentMeasure.getData()).profilesByKey();
// Detect new profiles or updated profiles
for (QProfile profile : currentProfiles.values()) {
private boolean isLast;
public Date getDate() {
- return date;//NOSONAR May expose internal representation by returning reference to mutable object
+ return date;
}
public long getSnapshotId() {
}
public PurgeableSnapshotDto setDate(Date date) {
- this.date = date;//NOSONAR May expose internal representation by incorporating reference to mutable object
+ this.date = date;
return this;
}
*/
package org.sonar.api.batch.rules;
+import com.google.common.base.Objects;
+
public class QProfile {
private final String key, name, language;
public int hashCode() {
return key.hashCode();
}
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("key", key)
+ .add("name", name)
+ .add("language", language)
+ .toString();
+ }
}