From 7cff3b0b66694aea1186d33816882fc5c3ce8fe9 Mon Sep 17 00:00:00 2001 From: Sébastien Lesaint Date: Thu, 18 Jun 2015 18:30:50 +0200 Subject: Revert "Fix quality flaws" This reverts commit 47bad47ae07d3ffc895f3e76261d637073c57981 which breaks the compiltation of SQ --- .../email/EmailNotificationChannel.java | 4 ++-- .../java/org/sonar/application/JdbcSettings.java | 11 ++++------- .../org/sonar/core/notification/package-info.java | 23 ++++++++++++++++++++++ .../sonar/core/qualityprofile/package-info.java | 23 ++++++++++++++++++++++ .../main/java/org/sonar/home/cache/FileCache.java | 2 +- .../main/java/org/sonar/api/utils/ZipUtils.java | 15 ++++++-------- 6 files changed, 59 insertions(+), 19 deletions(-) create mode 100644 sonar-core/src/main/java/org/sonar/core/notification/package-info.java create mode 100644 sonar-core/src/main/java/org/sonar/core/qualityprofile/package-info.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java b/server/sonar-server/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java index 5a08ed9718e..5e004e69b2b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java +++ b/server/sonar-server/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java @@ -95,8 +95,8 @@ public class EmailNotificationChannel extends NotificationChannel { @Override public void deliver(Notification notification, String username) { User user = userFinder.findByLogin(username); - if (user == null || StringUtils.isBlank(user.email())) { - LOG.debug("User does not exist or has no email: {}", username); + if (StringUtils.isBlank(user.email())) { + LOG.debug("Email not defined for user: " + username); return; } EmailMessage emailMessage = format(notification); diff --git a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java index 8684bf06e82..cbfbf4d6265 100644 --- a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java +++ b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java @@ -22,7 +22,6 @@ package org.sonar.application; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.LoggerFactory; -import org.sonar.api.utils.log.Loggers; import org.sonar.process.MessageException; import org.sonar.process.ProcessProperties; import org.sonar.process.Props; @@ -33,8 +32,6 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static java.lang.String.format; - public class JdbcSettings { enum Provider { @@ -76,13 +73,13 @@ public class JdbcSettings { Pattern pattern = Pattern.compile("jdbc:(\\w+):.+"); Matcher matcher = pattern.matcher(url); if (!matcher.find()) { - throw new MessageException(format("Bad format of JDBC URL: %s", url)); + throw new MessageException(String.format("Bad format of JDBC URL: " + url)); } String key = matcher.group(1); try { return Provider.valueOf(StringUtils.upperCase(key)); } catch (IllegalArgumentException e) { - throw new MessageException(format("Unsupported JDBC driver provider: %s", key)); + throw new MessageException(String.format(String.format("Unsupported JDBC driver provider: %s", key))); } } @@ -97,13 +94,13 @@ public class JdbcSettings { private static void checkRequiredParameter(String url, String val) { if (!url.contains(val)) { - throw new MessageException(format("JDBC URL must have the property '%s'", val)); + throw new MessageException(String.format("JDBC URL must have the property '%s'", val)); } } private void checkRecommendedParameter(String url, String val) { if (!url.contains(val)) { - Loggers.get(getClass()).warn("JDBC URL is recommended to have the property '{}'", val); + LoggerFactory.getLogger(getClass()).warn(String.format("JDBC URL is recommended to have the property '%s'", val)); } } } diff --git a/sonar-core/src/main/java/org/sonar/core/notification/package-info.java b/sonar-core/src/main/java/org/sonar/core/notification/package-info.java new file mode 100644 index 00000000000..c53b6d4b186 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/notification/package-info.java @@ -0,0 +1,23 @@ +/* + * 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.core.notification; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/package-info.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/package-info.java new file mode 100644 index 00000000000..0f09c0fc850 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/package-info.java @@ -0,0 +1,23 @@ +/* + * 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.core.qualityprofile; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java b/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java index 5998b97a2c5..3b681edcff1 100644 --- a/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java +++ b/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java @@ -106,7 +106,7 @@ public class FileCache { // 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("A copy/delete will be tempted but with no guarantee of atomicity"); + log.warn(String.format("A copy/delete will be tempted but with no garantee of atomicity")); try { Files.move(sourceFile.toPath(), targetFile.toPath()); } catch (IOException e) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java index 66da90e88ae..45903251411 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java @@ -65,18 +65,15 @@ public final class ZipUtils { } public static File unzip(InputStream zip, File toDir) throws IOException { - unzip(zip, toDir, TrueZipEntryFilter.INSTANCE); + unzip(zip, toDir, new ZipEntryFilter() { + @Override + public boolean accept(ZipEntry entry) { + return true; + } + }); return toDir; } - private enum TrueZipEntryFilter implements ZipEntryFilter { - INSTANCE; - @Override - public boolean accept(ZipEntry entry) { - return true; - } - } - public static File unzip(InputStream stream, File toDir, ZipEntryFilter filter) throws IOException { if (!toDir.exists()) { FileUtils.forceMkdir(toDir); -- cgit v1.2.3