*/
package org.sonar.plugins.core.issue;
-import org.sonar.api.measures.FileLinesContextFactory;
-
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.FileLinesContext;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
-import org.sonar.api.batch.*;
+import org.sonar.api.batch.Decorator;
+import org.sonar.api.batch.DecoratorBarriers;
+import org.sonar.api.batch.DecoratorContext;
+import org.sonar.api.batch.DependedUpon;
+import org.sonar.api.batch.DependsUpon;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.issue.Issuable;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.api.issue.internal.IssueChangeContext;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.FileLinesContext;
+import org.sonar.api.measures.FileLinesContextFactory;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
private FileLinesContextFactory fileLineContextFactory;
public IssueTrackingDecorator(IssueCache issueCache, InitialOpenIssuesStack initialOpenIssues, IssueTracking tracking,
- IssueHandlers handlers, IssueWorkflow workflow,
- IssueUpdater updater,
- Project project,
- ResourcePerspectives perspectives,
- RulesProfile rulesProfile,
- RuleFinder ruleFinder,
- FileLinesContextFactory fileLineContextFactory) {
+ IssueHandlers handlers, IssueWorkflow workflow,
+ IssueUpdater updater,
+ Project project,
+ ResourcePerspectives perspectives,
+ RulesProfile rulesProfile,
+ RuleFinder ruleFinder,
+ FileLinesContextFactory fileLineContextFactory) {
this.issueCache = issueCache;
this.initialOpenIssues = initialOpenIssues;
this.tracking = tracking;
if (ResourceUtils.isFile(resource)) {
FileLinesContext fileLineContext = fileLineContextFactory.createFor(resource);
for (DefaultIssue issue : newIssues) {
- if (issue.line() != null) {
+ Integer line = issue.line();
+ if (line != null) {
// TODO When issue is on line 0 then who is the author?
- String scmAuthorLogin = fileLineContext.getStringValue(CoreMetrics.SCM_AUTHORS_BY_LINE_KEY, issue.line());
+ String scmAuthorLogin = fileLineContext.getStringValue(CoreMetrics.SCM_AUTHORS_BY_LINE_KEY, line);
if (scmAuthorLogin != null) {
issue.setAuthorLogin(scmAuthorLogin);
}
*/
package org.sonar.api.measures;
-import java.util.Collection;
-
import org.apache.commons.lang.StringUtils;
+import javax.annotation.Nullable;
+
+import java.util.Collection;
+
/**
* An utility class to manipulate measures
*
* @return <code>defaultValue</code> if measure is null or has no values.
*/
- public static Double getValue(Measure measure, Double defaultValue) {
+ public static Double getValue(Measure measure, @Nullable Double defaultValue) {
if (MeasureUtils.hasValue(measure)) {
return measure.getValue();
}
return getVariation(measure, periodIndex, null);
}
- public static Double getVariation(Measure measure, int periodIndex, Double defaultValue) {
+ public static Double getVariation(Measure measure, int periodIndex, @Nullable Double defaultValue) {
Double result = null;
if (measure != null) {
result = measure.getVariation(periodIndex);
return getVariationAsLong(measure, periodIndex, null);
}
- public static Long getVariationAsLong(Measure measure, int periodIndex, Long defaultValue) {
+ public static Long getVariationAsLong(Measure measure, int periodIndex, @Nullable Long defaultValue) {
Double result = null;
if (measure != null) {
result = measure.getVariation(periodIndex);
import org.sonar.api.ServerExtension;
import org.sonar.api.batch.InstantiationStrategy;
+import javax.annotation.Nullable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
* @deprecated since 2.7 use the {@link Builder} factory.
*/
@Deprecated
- public Metric(String key, String name, String description, ValueType type, Integer direction, Boolean qualitative, String domain,
+ public Metric(String key, String name, String description, ValueType type, Integer direction, Boolean qualitative, @Nullable String domain,
boolean userManaged) {
this.key = key;
this.description = description;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RulePriority;
+import javax.annotation.Nullable;
+
/**
* @since 1.10
*/
/**
* This constructor is for internal use only. Please use static methods createForXXX().
*/
- public RuleMeasure(Metric metric, Rule rule, RulePriority rulePriority, Integer ruleCategory) {
+ public RuleMeasure(Metric metric, @Nullable Rule rule, @Nullable RulePriority rulePriority, @Nullable Integer ruleCategory) {
super(metric);
this.rule = rule;
this.rulePriority = rulePriority;
if (obj == null) {
return false;
}
- if (!(obj.getClass().equals(RuleMeasure.class))) {//NOSONAR should be refactored but kept in the current state
+ if (!(obj.getClass().equals(RuleMeasure.class))) {// NOSONAR should be refactored but kept in the current state
// for the moment.
return false;
}
}
RuleMeasure other = (RuleMeasure) obj;
return new EqualsBuilder()
- .append(getMetric(), other.getMetric())
- .append(personId, other.personId)
- .append(rule, other.rule)
- .isEquals();
+ .append(getMetric(), other.getMetric())
+ .append(personId, other.personId)
+ .append(rule, other.rule)
+ .isEquals();
}
@Override
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
- .append(getMetric())
- .append(personId)
- .append(rule)
- .toHashCode();
+ .append(getMetric())
+ .append(personId)
+ .append(rule)
+ .toHashCode();
}
@Override
public String toString() {
return new ToStringBuilder(this)
- .append("id", getId())
- .append("metric", metric)
- .append("personId", personId)
- .append("rule", rule)
- .append("value", value)
- .append("data", data)
- .append("description", description)
- .append("alertStatus", alertStatus)
- .append("alertText", alertText)
- .append("tendency", tendency)
- .append("severity", rulePriority)
- .toString();
- }
-
- public static RuleMeasure createForRule(Metric metric, Rule rule, Double value) {
+ .append("id", getId())
+ .append("metric", metric)
+ .append("personId", personId)
+ .append("rule", rule)
+ .append("value", value)
+ .append("data", data)
+ .append("description", description)
+ .append("alertStatus", alertStatus)
+ .append("alertText", alertText)
+ .append("tendency", tendency)
+ .append("severity", rulePriority)
+ .toString();
+ }
+
+ public static RuleMeasure createForRule(Metric metric, Rule rule, @Nullable Double value) {
return new RuleMeasure(metric, rule, null, null).setValue(value);
}
- public static RuleMeasure createForPriority(Metric metric, RulePriority priority, Double value) {
+ public static RuleMeasure createForPriority(Metric metric, RulePriority priority, @Nullable Double value) {
return new RuleMeasure(metric, null, priority, null).setValue(value);
}
* @deprecated since 2.5. See SONAR-2007.
*/
@Deprecated
- public static RuleMeasure createForCategory(Metric metric, Integer category, Double value) {
+ public static RuleMeasure createForCategory(Metric metric, Integer category, @Nullable Double value) {
return new RuleMeasure(metric, null, null, category).setValue(value);
}
}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.api.measures;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+