private double sumXPower2;
private double sumYPower2;
private double sumXY;
- private double yIntercept; // not used today
+ // not used today
+ private double yIntercept;
private Double slope;
private Double correlationRate;
import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
-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.batch.TimeMachine;
-import org.sonar.api.batch.TimeMachineQuery;
+import org.sonar.api.batch.*;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
import org.sonar.api.measures.MetricFinder;
protected TimeMachineQuery initQuery(Project project) {
int days = configuration.getTendencyPeriodInDays();
- query = new TimeMachineQuery(null) // resource is set after
+ // resource is set after
+ query = new TimeMachineQuery(null)
.setFrom(DateUtils.addDays(project.getAnalysisDate(), -days))
.setToCurrentAnalysis(true)
.setMetrics(metrics);
checkCurrentAnalysisIsTheLatestOne(project.getKey(), analysisDate);
project
- .setConfiguration(new PropertiesConfiguration()) // will be populated by ProjectSettings
+ // will be populated by ProjectSettings
+ .setConfiguration(new PropertiesConfiguration())
.setAnalysisDate(analysisDate)
.setAnalysisVersion(loadAnalysisVersion())
.setAnalysisType(loadAnalysisType());
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.ResourceModel;
import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.Library;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.ResourceUtils;
-import org.sonar.api.resources.Scopes;
+import org.sonar.api.resources.*;
import org.sonar.api.security.ResourcePermissions;
import org.sonar.api.utils.SonarException;
project.setEffectiveKey(project.getKey());
ResourceModel model = findOrCreateModel(project);
- model.setLanguageKey(project.getLanguageKey());// ugly, only for projects
+ // ugly, only for projects
+ model.setLanguageKey(project.getLanguageKey());
// For views
if (project instanceof ResourceCopy) {
private Snapshot persistLibrary(Project project, Library library) {
ResourceModel model = findOrCreateModel(library);
model = session.save(model);
- library.setId(model.getId()); // TODO to be removed
+ // TODO to be removed
+ library.setId(model.getId());
library.setEffectiveKey(library.getKey());
Snapshot snapshot = findLibrarySnapshot(model.getId(), library.getVersion());
private MeasureModel model(Measure measure) {
MeasureModel model = new MeasureModel();
- model.setMetricId(measure.getMetric().getId()); // we assume that the index has updated the metric
+ // we assume that the index has updated the metric
+ model.setMetricId(measure.getMetric().getId());
model.setDescription(measure.getDescription());
model.setData(measure.getData());
model.setAlertStatus(measure.getAlertStatus());
import org.sonar.batch.index.ResourcePersister;
import javax.persistence.Query;
+
import java.util.List;
public class UpdateStatusJob implements BatchComponent {
private DatabaseSession session;
private ServerClient server;
- private Snapshot snapshot; // TODO remove this component
+ // TODO remove this component
+ private Snapshot snapshot;
private ResourcePersister resourcePersister;
private Settings settings;
private Project project;
} else {
if (this.countBag.add(value, count)) {
- this.countBag.add(value, 1);//hack
+ //hack
+ this.countBag.add(value, 1);
}
}
return this;
*/
public Measure build(boolean allowEmptyData) {
if (!isEmpty() || allowEmptyData) {
- return new Measure(metric, KeyValueFormat.format(countBag, -1)); //-1 is a hack to include zero values
+ //-1 is a hack to include zero values
+ return new Measure(metric, KeyValueFormat.format(countBag, -1));
}
return null;
}
*/
public static final int DEFAULT_PRECISION = 1;
- private Long id; // for internal use
+ // for internal use
+ private Long id;
protected String metricKey;
protected Metric metric;
protected Double value;
*/
public class ComponentContainer implements BatchComponent, ServerComponent {
- ComponentContainer parent, child; // no need for multiple children
+ // no need for multiple children
+ ComponentContainer parent, child;
MutablePicoContainer pico;
PropertyDefinitions propertyDefinitions;
* @since 2.7
*/
public static <K> Multiset<K> parseMultiset(String data, Converter<K> keyConverter) {
- Multiset<K> multiset = LinkedHashMultiset.create();// to keep the same order
+ // to keep the same order
+ Multiset<K> multiset = LinkedHashMultiset.create();
if (data != null) {
String[] pairs = StringUtils.split(data, PAIR_SEPARATOR);
for (String pair : pairs) {
protected void configureCategoryPlot() {
CategoryPlot plot = jfreechart.getCategoryPlot();
plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA);
- plot.setInsets(RectangleInsets.ZERO_INSETS); // To remove inner space around chart
+ // To remove inner space around chart
+ plot.setInsets(RectangleInsets.ZERO_INSETS);
plot.setDataset(dataset);
plot.setDomainAxis(categoryAxis);
plot.setRenderer(renderer);
protected void configureCategoryPlot() {
CategoryPlot plot = jfreechart.getCategoryPlot();
plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA);
- plot.setInsets(RectangleInsets.ZERO_INSETS); // To remove inner space around chart
+ // To remove inner space around chart
+ plot.setInsets(RectangleInsets.ZERO_INSETS);
plot.setDataset(dataset);
plot.setDomainAxis(categoryAxis);
plot.setRenderer(renderer);
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
Metric unmarshalled = (Metric) builtIn.unmarshal(reader, context);
- unmarshalled.setId(null); // See http://jira.codehaus.org/browse/SONAR-1819
+ // See http://jira.codehaus.org/browse/SONAR-1819
+ unmarshalled.setId(null);
unmarshalled.setUserManaged(true);
unmarshalled.setEnabled(true);
return unmarshalled;
} else {
oldActiveRule.setInheritance(ActiveRule.OVERRIDES);
getSession().saveWithoutFlush(oldActiveRule);
- return; // no need to change in children
+ // no need to change in children
+ return;
}
}
ActiveRule newActiveRule = (ActiveRule) parentActiveRule.clone();
} else {
activeRule.setInheritance(null);
getSession().saveWithoutFlush(activeRule);
- return; // no need to change in children
+ // no need to change in children
+ return;
}
for (RulesProfile child : getChildren(profile)) {
public final class Platform {
private static final Platform INSTANCE = new Platform();
- private ComponentContainer rootContainer;// level 1 : only database connectors
- private ComponentContainer coreContainer;// level 2 : level 1 + core components
- private ComponentContainer servicesContainer;// level 3 : level 2 + plugin extensions + core components that depend on plugin extensions
+ // level 1 : only database connectors
+ private ComponentContainer rootContainer;
+ // level 2 : level 1 + core components
+ private ComponentContainer coreContainer;
+ // level 3 : level 2 + plugin extensions + core components that depend on plugin extensions
+ private ComponentContainer servicesContainer;
private boolean connected = false;
private boolean started = false;
servicesContainer.addSingleton(UpdateCenterMatrixFactory.class);
servicesContainer.addSingleton(PluginDownloader.class);
servicesContainer.addSingleton(ServerIdGenerator.class);
- servicesContainer.addSingleton(DefaultModelFinder.class); // depends on plugins
+ // depends on plugins
+ servicesContainer.addSingleton(DefaultModelFinder.class);
servicesContainer.addSingleton(DefaultModelManager.class);
servicesContainer.addSingleton(ChartFactory.class);
servicesContainer.addSingleton(Languages.class);
private static Properties openWarProperties() {
try {
InputStream input = SonarHome.class.getResourceAsStream("/sonar-war.properties");
- return ConfigurationUtils.readInputStream(input); // it closes the stream
+ // it closes the stream
+ return ConfigurationUtils.readInputStream(input);
} catch (IOException e) {
throw new IllegalStateException("Fail to load the file sonar-war.properties", e);
}
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
+
import java.io.File;
import java.io.IOException;
import java.net.URL;
if (StringUtils.substringAfterLast(rootPath, "/").indexOf('.') >= 0) {
rootDirectory = StringUtils.substringBeforeLast(rootPath, "/");
}
- jarPath = root.getPath().substring(5, root.getPath().indexOf("!")); //strip out only the JAR file
+ //strip out only the JAR file
+ jarPath = root.getPath().substring(5, root.getPath().indexOf("!"));
jar = new JarFile(URLDecoder.decode(jarPath, CharEncoding.UTF_8));
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
defaultValue = "true",
name = "Enable Update Center",
project = false,
- global = false, // hidden from UI
+ // hidden from UI
+ global = false,
category = "Update Center",
type = PropertyType.BOOLEAN),
@Property(
defaultValue = "http://update.sonarsource.org/update-center.properties",
name = "Update Center URL",
project = false,
- global = false, // hidden from UI
+ // hidden from UI
+ global = false,
category = "Update Center")
})
public class UpdateCenterClient implements ServerComponent {
@Override
boolean matchWithEndOfLine(Line line, StringBuilder pendingLine) {
- return true; //see http://jira.codehaus.org/browse/SONAR-1555
+ //see http://jira.codehaus.org/browse/SONAR-1555
+ return true;
}
}
content.append("\r\n");
break;
default:
- throw new IllegalStateException(); // should never happen
+ // should never happen
+ throw new IllegalStateException();
}
}
}