aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/qualitymodel/RatingGrid.java17
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UserGroupUpdater.java11
-rw-r--r--sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/user/UserGroupValidation.java2
6 files changed, 10 insertions, 30 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/qualitymodel/RatingGrid.java b/server/sonar-server/src/main/java/org/sonar/server/computation/qualitymodel/RatingGrid.java
index 4b9c7e8f3e4..8cf286e04bb 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/qualitymodel/RatingGrid.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/qualitymodel/RatingGrid.java
@@ -23,15 +23,15 @@ import com.google.common.annotations.VisibleForTesting;
import java.util.Arrays;
import org.sonar.api.utils.MessageException;
-public class RatingGrid {
+class RatingGrid {
private final double[] gridValues;
- public RatingGrid(double[] gridValues) {
+ RatingGrid(double[] gridValues) {
this.gridValues = Arrays.copyOf(gridValues, gridValues.length);
}
- public Rating getRatingForDensity(double density) {
+ Rating getRatingForDensity(double density) {
for (Rating rating : Rating.values()) {
double lowerBound = getGradeLowerBound(rating);
if (density >= lowerBound) {
@@ -53,7 +53,7 @@ public class RatingGrid {
return gridValues;
}
- public enum Rating {
+ enum Rating {
E(5),
D(4),
C(3),
@@ -69,15 +69,6 @@ public class RatingGrid {
public int getIndex() {
return index;
}
-
- public static Rating createForIndex(int index) {
- for (Rating rating : values()) {
- if (rating.getIndex() == index) {
- return rating;
- }
- }
- throw new IllegalArgumentException("A maintainability rating must be in the range [1..5].");
- }
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java
index 59dc5ec67b8..a043e4f73dc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java
@@ -30,9 +30,9 @@ import org.sonar.db.DbSession;
import org.sonar.db.user.GroupDto;
import org.sonar.server.user.UserSession;
+import static org.sonar.api.user.UserGroupValidation.GROUP_NAME_MAX_LENGTH;
import static org.sonar.db.MyBatis.closeQuietly;
import static org.sonar.server.usergroups.ws.UserGroupUpdater.DESCRIPTION_MAX_LENGTH;
-import static org.sonar.server.usergroups.ws.UserGroupUpdater.NAME_MAX_LENGTH;
import static org.sonar.server.usergroups.ws.UserGroupUpdater.PARAM_DESCRIPTION;
import static org.sonar.server.usergroups.ws.UserGroupUpdater.PARAM_NAME;
@@ -59,7 +59,7 @@ public class CreateAction implements UserGroupsWsAction {
action.createParam(PARAM_NAME)
.setDescription(String.format("Name for the new group. A group name cannot be larger than %d characters and must be unique. " +
- "The value 'anyone' (whatever the case) is reserved and cannot be used.", NAME_MAX_LENGTH))
+ "The value 'anyone' (whatever the case) is reserved and cannot be used.", GROUP_NAME_MAX_LENGTH))
.setExampleValue("sonar-users")
.setRequired(true);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java
index 9affad21269..d427ec3cded 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java
@@ -32,9 +32,9 @@ import org.sonar.db.user.GroupDto;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.user.UserSession;
+import static org.sonar.api.user.UserGroupValidation.GROUP_NAME_MAX_LENGTH;
import static org.sonar.db.MyBatis.closeQuietly;
import static org.sonar.server.usergroups.ws.UserGroupUpdater.DESCRIPTION_MAX_LENGTH;
-import static org.sonar.server.usergroups.ws.UserGroupUpdater.NAME_MAX_LENGTH;
import static org.sonar.server.usergroups.ws.UserGroupUpdater.PARAM_DESCRIPTION;
import static org.sonar.server.usergroups.ws.UserGroupUpdater.PARAM_ID;
import static org.sonar.server.usergroups.ws.UserGroupUpdater.PARAM_NAME;
@@ -67,7 +67,7 @@ public class UpdateAction implements UserGroupsWsAction {
action.createParam(PARAM_NAME)
.setDescription(String.format("New name for the group. A group name cannot be larger than %d characters and must be unique. " +
- "The value 'anyone' (whatever the case) is reserved and cannot be used.", NAME_MAX_LENGTH))
+ "The value 'anyone' (whatever the case) is reserved and cannot be used.", GROUP_NAME_MAX_LENGTH))
.setExampleValue("sonar-users");
action.createParam(PARAM_DESCRIPTION)
diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UserGroupUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UserGroupUpdater.java
index ae2e10adaed..de2e7bd5960 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UserGroupUpdater.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UserGroupUpdater.java
@@ -20,7 +20,6 @@
package org.sonar.server.usergroups.ws;
import com.google.common.base.Preconditions;
-import org.sonar.api.security.DefaultGroups;
import org.sonar.api.server.ServerSide;
import org.sonar.api.user.UserGroupValidation;
import org.sonar.api.utils.text.JsonWriter;
@@ -39,7 +38,6 @@ public class UserGroupUpdater {
// Database column size should be 500 (since migration #353),
// but on some instances, column size is still 255,
// hence the validation is done with 255
- static final int NAME_MAX_LENGTH = 255;
static final int DESCRIPTION_MAX_LENGTH = 200;
private final DbClient dbClient;
@@ -52,15 +50,6 @@ public class UserGroupUpdater {
UserGroupValidation.validateGroupName(name);
}
- private static void checkNameLength(String name) {
- Preconditions.checkArgument(!name.isEmpty(), "Name cannot be empty");
- Preconditions.checkArgument(name.length() <= NAME_MAX_LENGTH, String.format("Name cannot be longer than %d characters", NAME_MAX_LENGTH));
- }
-
- private static void checkNameNotAnyone(String name) {
- Preconditions.checkArgument(!DefaultGroups.isAnyone(name), String.format("Name '%s' is reserved (regardless of case)", DefaultGroups.ANYONE));
- }
-
protected void checkNameIsUnique(String name, DbSession session) {
// There is no database constraint on column groups.name
// because MySQL cannot create a unique index
diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java
index 4624d3cf94d..d37fcd7da7b 100644
--- a/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java
@@ -56,7 +56,7 @@ public class ResourceDao extends AbstractDao {
}
@CheckForNull
- private ResourceDto selectResource(ResourceQuery query, DbSession session) {
+ private static ResourceDto selectResource(ResourceQuery query, DbSession session) {
List<ResourceDto> resources = getResources(query, session);
if (!resources.isEmpty()) {
return resources.get(0);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/user/UserGroupValidation.java b/sonar-plugin-api/src/main/java/org/sonar/api/user/UserGroupValidation.java
index 98c2d594c0f..d3297231b3e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/user/UserGroupValidation.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/user/UserGroupValidation.java
@@ -26,7 +26,7 @@ import static com.google.common.base.Strings.isNullOrEmpty;
public class UserGroupValidation {
- private static final int GROUP_NAME_MAX_LENGTH = 255;
+ public static final int GROUP_NAME_MAX_LENGTH = 255;
private UserGroupValidation() {
// Only static methods