@Override
public void setJarScanFilter(JarScanFilter jarScanFilter) {
-
+ // no need to filter
}
}
configureLogbackAccess(tomcat, props);
}
- private void configureLogbackAccess(Tomcat tomcat, Props props) {
+ private static void configureLogbackAccess(Tomcat tomcat, Props props) {
if (props.valueAsBoolean(PROPERTY_ENABLE, true)) {
ProgrammaticLogbackValve valve = new ProgrammaticLogbackValve();
LogbackHelper helper = new LogbackHelper();
*/
package org.sonar.server.charts.deprecated;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.Map;
+import java.util.StringTokenizer;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.RectangleInsets;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.util.Map;
-import java.util.StringTokenizer;
-
public class BarChart extends BaseChartWeb implements DeprecatedChart {
private BarRenderer renderer = null;
*/
package org.sonar.server.charts.deprecated;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.encoders.KeypointPNGEncoderAdapter;
-import org.jfree.chart.title.LegendTitle;
-import org.jfree.chart.title.TextTitle;
-import org.jfree.ui.RectangleEdge;
-
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.encoders.KeypointPNGEncoderAdapter;
+import org.jfree.chart.title.LegendTitle;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.ui.RectangleEdge;
public abstract class BaseChart {
*/
package org.sonar.server.charts.deprecated;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.renderer.AbstractRenderer;
-
import java.awt.*;
import java.util.Map;
import java.util.StringTokenizer;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.renderer.AbstractRenderer;
public abstract class BaseChartWeb extends BaseChart {
*/
package org.sonar.server.charts.deprecated;
-import org.jfree.chart.plot.CategoryPlot;
-import org.jfree.data.category.DefaultCategoryDataset;
-import org.jfree.ui.RectangleInsets;
-
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Map;
import java.util.StringTokenizer;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.data.category.DefaultCategoryDataset;
+import org.jfree.ui.RectangleInsets;
public class CustomBarChart extends BarChart {
*/
package org.sonar.server.charts.deprecated;
-import org.jfree.chart.renderer.category.BarRenderer;
-
import java.awt.*;
+import org.jfree.chart.renderer.category.BarRenderer;
public class CustomBarRenderer extends BarRenderer {
*/
package org.sonar.server.charts.deprecated;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.plot.PiePlot;
-import org.jfree.chart.title.TextTitle;
-import org.jfree.data.general.DefaultPieDataset;
-import org.jfree.ui.RectangleInsets;
-
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Map;
import java.util.StringTokenizer;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PiePlot;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.general.DefaultPieDataset;
+import org.jfree.ui.RectangleInsets;
public class PieChart extends BaseChartWeb implements DeprecatedChart {
*/
package org.sonar.server.charts.deprecated;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.Map;
+import java.util.StringTokenizer;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.DateTickUnit;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.RectangleInsets;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.util.Map;
-import java.util.StringTokenizer;
-
public class SparkLinesChart extends BaseChartWeb implements DeprecatedChart {
private XYSeriesCollection dataset = null;
executorService.scheduleAtFixedRate(new ComputationThread(queue, sqContainer, containerFactory), delayForFirstStart, delayBetweenTasks, timeUnit);
}
- private ThreadFactory newThreadFactory() {
+ private static ThreadFactory newThreadFactory() {
return new ThreadFactoryBuilder()
.setNameFormat(THREAD_NAME_PREFIX + "%d").setPriority(Thread.MIN_PRIORITY).build();
}
public interface Select extends SqlStatement<Select> {
- static class Row {
+ class Row {
private final ResultSet rs;
Row(ResultSet rs) {
}
}
- static interface RowReader<T> {
+ interface RowReader<T> {
T read(Row row) throws SQLException;
}
- static class LongReader implements RowReader<Long> {
+ class LongReader implements RowReader<Long> {
private LongReader() {
}
}
}
- static final RowReader<Long> LONG_READER = new LongReader();
+ RowReader<Long> LONG_READER = new LongReader();
- static class StringReader implements RowReader<String> {
+ class StringReader implements RowReader<String> {
private StringReader() {
}
}
}
- static final RowReader<String> STRING_READER = new StringReader();
+ RowReader<String> STRING_READER = new StringReader();
- static interface RowHandler<T> {
+ interface RowHandler {
void handle(Row row) throws SQLException;
}
@Override
public void deliver(Notification notification, String username) {
User user = userFinder.findByLogin(username);
- if (StringUtils.isBlank(user.email())) {
- LOG.debug("Email not defined for user: " + username);
+ if (user == null || StringUtils.isBlank(user.email())) {
+ LOG.debug("User does not exist or has no email: {}", username);
return;
}
EmailMessage emailMessage = format(notification);
}
private void send(EmailMessage emailMessage) throws EmailException {
- // Trick to correctly initilize javax.mail library
+ // Trick to correctly initialize javax.mail library
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
*/
package org.sonar.application;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.LoggerFactory;
-import org.sonar.process.MessageException;
-import org.sonar.process.ProcessProperties;
-import org.sonar.process.Props;
-
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.process.MessageException;
+import org.sonar.process.ProcessProperties;
+import org.sonar.process.Props;
public class JdbcSettings {
Pattern pattern = Pattern.compile("jdbc:(\\w+):.+");
Matcher matcher = pattern.matcher(url);
if (!matcher.find()) {
- throw new MessageException(String.format("Bad format of JDBC URL: " + url));
+ throw new MessageException(String.format("Bad format of JDBC URL: %s", url));
}
String key = matcher.group(1);
try {
return Provider.valueOf(StringUtils.upperCase(key));
} catch (IllegalArgumentException e) {
- throw new MessageException(String.format(String.format("Unsupported JDBC driver provider: %s", key)));
+ throw new MessageException(String.format("Unsupported JDBC driver provider: %s", key));
}
}
private void checkRecommendedParameter(String url, String val) {
if (!url.contains(val)) {
- LoggerFactory.getLogger(getClass()).warn(String.format("JDBC URL is recommended to have the property '%s'", val));
+ Loggers.get(getClass()).warn("JDBC URL is recommended to have the property '{}'", val);
}
}
}
return unregisteredNames;
}
- private Set<Driver> registeredDrivers() {
+ private static Set<Driver> registeredDrivers() {
Set<Driver> registeredDrivers = new HashSet<>();
Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
}
}
- private double calculateCoverage(final long coveredLines, final long lines) {
+ private static double calculateCoverage(final long coveredLines, final long lines) {
return (100.0 * coveredLines) / lines;
}
// Check if the file was cached by another process during download
if (!rename && !targetFile.exists()) {
log.warn(String.format("Unable to rename %s to %s", sourceFile.getAbsolutePath(), targetFile.getAbsolutePath()));
- log.warn(String.format("A copy/delete will be tempted but with no garantee of atomicity"));
+ log.warn("A copy/delete will be tempted but with no guarantee of atomicity");
try {
Files.move(sourceFile.toPath(), targetFile.toPath());
} catch (IOException e) {
}
ProjectDefinition that = (ProjectDefinition) o;
String key = getKey();
- return !(key != null ? !key.equals(that.getKey()) : that.getKey() != null);
+ return !((key != null) ? !key.equals(that.getKey()) : (that.getKey() != null));
}
return toDir;
}
+ public static File unzip(InputStream zip, File toDir) throws IOException {
+ unzip(zip, toDir, TrueZipEntryFilter.INSTANCE);
+ return toDir;
+ }
+
private enum TrueZipEntryFilter implements ZipEntryFilter {
INSTANCE;
-
@Override
public boolean accept(ZipEntry entry) {
return true;
}
}
- public static File unzip(InputStream zip, File toDir) throws IOException {
- unzip(zip, toDir, TrueZipEntryFilter.INSTANCE);
- return toDir;
- }
-
public static File unzip(InputStream stream, File toDir, ZipEntryFilter filter) throws IOException {
if (!toDir.exists()) {
FileUtils.forceMkdir(toDir);