public class DefaultDecoratorContext implements DecoratorContext {
private static final String SAVE_MEASURE_METHOD = "saveMeasure";
- private SonarIndex index;
+ private SonarIndex sonarIndex;
private Resource resource;
private MeasurementFilters measurementFilters;
private boolean readOnly = false;
SonarIndex index,
List<DecoratorContext> childrenContexts,
MeasurementFilters measurementFilters, MeasureCache measureCache, MetricFinder metricFinder) {
- this.index = index;
+ this.sonarIndex = index;
this.resource = resource;
this.childrenContexts = childrenContexts;
this.measurementFilters = measurementFilters;
}
public Project getProject() {
- return index.getProject();
+ return sonarIndex.getProject();
}
public List<DecoratorContext> getChildren() {
* {@inheritDoc}
*/
public List<Violation> getViolations(ViolationQuery violationQuery) {
- return index.getViolations(violationQuery);
+ return sonarIndex.getViolations(violationQuery);
}
/**
* {@inheritDoc}
*/
public List<Violation> getViolations() {
- return index.getViolations(resource);
+ return sonarIndex.getViolations(resource);
}
public Dependency saveDependency(Dependency dependency) {
checkReadOnly("addDependency");
- return index.addDependency(dependency);
+ return sonarIndex.addDependency(dependency);
}
public Set<Dependency> getDependencies() {
- return index.getDependencies();
+ return sonarIndex.getDependencies();
}
public Collection<Dependency> getIncomingDependencies() {
- return index.getIncomingEdges(resource);
+ return sonarIndex.getIncomingEdges(resource);
}
public Collection<Dependency> getOutgoingDependencies() {
- return index.getOutgoingEdges(resource);
+ return sonarIndex.getOutgoingEdges(resource);
}
public List<Event> getEvents() {
- return index.getEvents(resource);
+ return sonarIndex.getEvents(resource);
}
public Event createEvent(String name, String description, String category, Date date) {
- return index.addEvent(resource, name, description, category, date);
+ return sonarIndex.addEvent(resource, name, description, category, date);
}
public void deleteEvent(Event event) {
- index.deleteEvent(event);
+ sonarIndex.deleteEvent(event);
}
public DefaultDecoratorContext saveViolation(Violation violation, boolean force) {
if (violation.getResource() == null) {
violation.setResource(resource);
}
- index.addViolation(violation, force);
+ sonarIndex.addViolation(violation, force);
return this;
}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 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.batch.events;
+
+import javax.annotation.ParametersAreNonnullByDefault;
}
private List<ResourceModel> loadEnabledResources(int moduleId, StringBuilder hql) {
- List<ResourceModel> resources = session.createQuery(hql.toString())
+ return session.createQuery(hql.toString())
.setParameter("rootId", moduleId)
.setParameter("enabled", true)
.getResultList();
- return resources;
}
private Map<String, ResourceModel> loadDisabledResources(int moduleId, StringBuilder hql) {
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 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.batch.index;
+
+import javax.annotation.ParametersAreNonnullByDefault;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 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.batch.language;
+
+import javax.annotation.ParametersAreNonnullByDefault;
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+@javax.annotation.ParametersAreNonnullByDefault
package org.sonar.batch.languages;
\ No newline at end of file
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 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.batch;
+
+import javax.annotation.ParametersAreNonnullByDefault;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 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.batch.phases;
+
+import javax.annotation.ParametersAreNonnullByDefault;
}
public boolean shouldExecuteOnProject(Project project) {
- return project.getModules().size() > 0;
+ return !project.getModules().isEmpty();
}
@Override
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 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.batch.scan.maven;
+
+import javax.annotation.ParametersAreNonnullByDefault;
@Override
public boolean update(Connection connection) throws SQLException {
- if (ids.size() > 0) {
- String deleteSql = new StringBuilder().append("DELETE FROM measure_data WHERE id IN (")
- .append(StringUtils.repeat("?", ",", ids.size())).append(")").toString();
- PreparedStatement s = connection.prepareStatement(deleteSql);
- int i = 1;
- for (Long id : ids) {
- s.setLong(i++, id);
- }
+ if (!ids.isEmpty()) {
+ PreparedStatement s = prepareDeleteQuery(ids, connection);
s.executeUpdate();
s.close();
ids.clear();
}
return false;
}
+ });
+ }
- }
- );
+ private PreparedStatement prepareDeleteQuery(final List<Long> ids, Connection connection) throws SQLException {
+ String deleteSql = new StringBuilder()
+ .append("DELETE FROM measure_data WHERE id IN (")
+ .append(StringUtils.repeat("?", ",", ids.size()))
+ .append(")").toString();
+ PreparedStatement s = connection.prepareStatement(deleteSql);
+ int i = 1;
+ for (Long id : ids) {
+ s.setLong(i, id);
+ i++;
+ }
+ return s;
}
private static class Row {