diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-09-02 14:37:28 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-09-02 22:22:13 +0200 |
commit | 91496e1aff8cd5d8037aeca1fce944dd4fd8bc61 (patch) | |
tree | dfe8871e7508dc60d0dcba31b3bc85588ab0c7bf /sonar-db | |
parent | 5c07e5e99a1fc9ec6b0a4db8fddc785a1e885b79 (diff) | |
download | sonarqube-91496e1aff8cd5d8037aeca1fce944dd4fd8bc61.tar.gz sonarqube-91496e1aff8cd5d8037aeca1fce944dd4fd8bc61.zip |
Fix quality flaws
Diffstat (limited to 'sonar-db')
12 files changed, 153 insertions, 9 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/MyBatis.java b/sonar-db/src/main/java/org/sonar/db/MyBatis.java index fc6308269ce..dbd1dba7bc4 100644 --- a/sonar-db/src/main/java/org/sonar/db/MyBatis.java +++ b/sonar-db/src/main/java/org/sonar/db/MyBatis.java @@ -284,7 +284,7 @@ public class MyBatis { return newScrollingSelectStatement(session, sql, fetchSize); } - private PreparedStatement newScrollingSelectStatement(DbSession session, String sql, int fetchSize) { + private static PreparedStatement newScrollingSelectStatement(DbSession session, String sql, int fetchSize) { try { PreparedStatement stmt = session.getConnection().prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(fetchSize); diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceDto.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceDto.java index 769ee2376fc..d82928f386a 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ResourceDto.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceDto.java @@ -207,11 +207,11 @@ public class ResourceDto { } public Date getCreatedAt() { - return createdAt;// NOSONAR May expose internal representation by returning reference to mutable object + return createdAt; } public ResourceDto setCreatedAt(Date date) { - this.createdAt = date;// NOSONAR May expose internal representation by incorporating reference to mutable object + this.createdAt = date; return this; } diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java index 2e6e4ad79e4..dd7103504ec 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java @@ -176,14 +176,14 @@ public class ResourceIndexDao extends AbstractDao { return indexed; } - private void insertIndexEntries(String key, long resourceId, String qualifier, long rootId, int nameLength, ResourceIndexMapper mapper) { + private static void insertIndexEntries(String key, long resourceId, String qualifier, long rootId, int nameLength, ResourceIndexMapper mapper) { ResourceIndexDto dto = new ResourceIndexDto() .setResourceId(resourceId) .setQualifier(qualifier) .setRootProjectId(rootId) .setNameSize(nameLength); - int maxPosition = key.length() == SINGLE_INDEX_SIZE ? 0 : key.length() - MINIMUM_KEY_SIZE; + int maxPosition = (key.length() == SINGLE_INDEX_SIZE ? 0 : key.length() - MINIMUM_KEY_SIZE); for (int position = 0; position <= maxPosition; position++) { dto.setPosition(position); dto.setKey(StringUtils.substring(key, position)); @@ -196,7 +196,7 @@ public class ResourceIndexDao extends AbstractDao { * If the resource is indexed with a different key, then this index is dropped and the * resource must be indexed again. */ - private boolean sanitizeIndex(long resourceId, String key, ResourceIndexMapper mapper) { + private static boolean sanitizeIndex(long resourceId, String key, ResourceIndexMapper mapper) { ResourceIndexDto masterIndex = mapper.selectMasterIndexByResourceId(resourceId); if (masterIndex != null && !StringUtils.equals(key, masterIndex.getKey())) { // resource has been renamed -> drop existing indexes diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterDao.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterDao.java index 1ec320febf5..5c452b74bd0 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterDao.java @@ -145,7 +145,7 @@ public class ResourceKeyUpdaterDao implements Dao { return modules; } - private void checkNewNameOfAllModules(Set<ResourceDto> modules, String stringToReplace, String replacementString, ResourceKeyUpdaterMapper mapper) { + private static void checkNewNameOfAllModules(Set<ResourceDto> modules, String stringToReplace, String replacementString, ResourceKeyUpdaterMapper mapper) { for (ResourceDto module : modules) { String newName = computeNewKey(module, stringToReplace, replacementString); if (mapper.countResourceByKey(newName) > 0) { diff --git a/sonar-db/src/main/java/org/sonar/db/deprecated/ClusterAction.java b/sonar-db/src/main/java/org/sonar/db/deprecated/ClusterAction.java index d6bfb3b30ab..2f392ed020a 100644 --- a/sonar-db/src/main/java/org/sonar/db/deprecated/ClusterAction.java +++ b/sonar-db/src/main/java/org/sonar/db/deprecated/ClusterAction.java @@ -24,5 +24,5 @@ import java.util.concurrent.Callable; public interface ClusterAction<K> extends Callable<K> { @Override - public K call() throws Exception; + K call() throws Exception; } diff --git a/sonar-db/src/main/java/org/sonar/db/property/package-info.java b/sonar-db/src/main/java/org/sonar/db/property/package-info.java new file mode 100644 index 00000000000..a1cbdbeaaa7 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/property/package-info.java @@ -0,0 +1,24 @@ +/* + * 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.db.property; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeProfiler.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeProfiler.java index c68c8dfa2cc..a5e07c43e5e 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeProfiler.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeProfiler.java @@ -82,7 +82,7 @@ public class PurgeProfiler { } } - private List<Entry<String, Long>> truncateList(List<Entry<String, Long>> sortedFullList) { + private static List<Entry<String, Long>> truncateList(List<Entry<String, Long>> sortedFullList) { int maxSize = 10; List<Entry<String, Long>> result = new ArrayList<>(maxSize); int i = 0; diff --git a/sonar-db/src/main/java/org/sonar/db/qualitygate/package-info.java b/sonar-db/src/main/java/org/sonar/db/qualitygate/package-info.java new file mode 100644 index 00000000000..07cbdd99ea9 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/qualitygate/package-info.java @@ -0,0 +1,24 @@ +/* + * 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.db.qualitygate; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-db/src/main/java/org/sonar/db/qualityprofile/package-info.java b/sonar-db/src/main/java/org/sonar/db/qualityprofile/package-info.java new file mode 100644 index 00000000000..34262afd87d --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/qualityprofile/package-info.java @@ -0,0 +1,24 @@ +/* + * 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.db.qualityprofile; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-db/src/main/java/org/sonar/db/rule/package-info.java b/sonar-db/src/main/java/org/sonar/db/rule/package-info.java new file mode 100644 index 00000000000..c8a566ef4e0 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/rule/package-info.java @@ -0,0 +1,24 @@ +/* + * 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.db.rule; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-db/src/main/java/org/sonar/db/source/package-info.java b/sonar-db/src/main/java/org/sonar/db/source/package-info.java new file mode 100644 index 00000000000..818667cbceb --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/source/package-info.java @@ -0,0 +1,24 @@ +/* + * 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.db.source; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-db/src/main/java/org/sonar/db/user/package-info.java b/sonar-db/src/main/java/org/sonar/db/user/package-info.java new file mode 100644 index 00000000000..2f52b2e7eee --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/user/package-info.java @@ -0,0 +1,24 @@ +/* + * 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.db.user; + +import javax.annotation.ParametersAreNonnullByDefault; + |