From e4c5970f42097fccb0948be068c3f4dda2352b78 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 5 Feb 2016 10:15:06 +0100 Subject: [PATCH] Fix quality gates --- .../sonar/server/issue/IssueBulkChangeQuery.java | 2 +- .../issue/actionplan/ActionPlanService.java | 2 +- .../sonar/colorizer/JavaConstantTokenizer.java | 4 ++-- .../org/sonar/db/dashboard/DashboardDao.java | 16 ++++++++-------- .../main/java/org/sonar/db/user/GroupDao.java | 1 - .../v52/MoveProjectProfileAssociation.java | 9 +++++---- .../java/org/sonar/api/batch/rule/Checks.java | 4 +--- .../sonar/api/checks/AnnotationCheckFactory.java | 4 +--- 8 files changed, 19 insertions(+), 23 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeQuery.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeQuery.java index 56c9f601689..3df31d3a8ac 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeQuery.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeQuery.java @@ -80,7 +80,7 @@ public class IssueBulkChangeQuery { } } - private List sanitizeList(@Nullable List list) { + private static List sanitizeList(@Nullable List list) { if (list == null || list.isEmpty()) { return Collections.emptyList(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/ActionPlanService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/ActionPlanService.java index da1203291a6..4ee93f6ded3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/ActionPlanService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/ActionPlanService.java @@ -167,7 +167,7 @@ public class ActionPlanService { return !actionPlanDao.selectByNameAndProjectId(name, findProject(projectKey).getId()).isEmpty(); } - private List toActionPlans(List actionPlanDtos) { + private static List toActionPlans(List actionPlanDtos) { return newArrayList(Iterables.transform(actionPlanDtos, ToActionPlan.INSTANCE)); } diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java index cb10364604b..03222f0c67c 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaConstantTokenizer.java @@ -70,11 +70,11 @@ public class JavaConstantTokenizer extends Tokenizer { } } - private boolean isJavaConstantStart(int character) { + private static boolean isJavaConstantStart(int character) { return Character.isUpperCase(character); } - private boolean isJavaConstantPart(int character) { + private static boolean isJavaConstantPart(int character) { return Character.isUpperCase(character) || character == '_' || character == '-' || Character.isDigit(character); } diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java b/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java index fd283b3d181..7dc94a8ecdf 100644 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java +++ b/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java @@ -48,15 +48,15 @@ public class DashboardDao implements Dao { DashboardMapper dashboardMapper = session.getMapper(DashboardMapper.class); WidgetMapper widgetMapper = session.getMapper(WidgetMapper.class); WidgetPropertyMapper widgetPropertyMapper = session.getMapper(WidgetPropertyMapper.class); - dashboardMapper.insert(dashboardDto); - for (WidgetDto widgetDto : dashboardDto.getWidgets()) { - widgetDto.setDashboardId(dashboardDto.getId()); - widgetMapper.insert(widgetDto); - for (WidgetPropertyDto widgetPropertyDto : widgetDto.getWidgetProperties()) { - widgetPropertyDto.setWidgetId(widgetDto.getId()); - widgetPropertyMapper.insert(widgetPropertyDto); - } + dashboardMapper.insert(dashboardDto); + for (WidgetDto widgetDto : dashboardDto.getWidgets()) { + widgetDto.setDashboardId(dashboardDto.getId()); + widgetMapper.insert(widgetDto); + for (WidgetPropertyDto widgetPropertyDto : widgetDto.getWidgetProperties()) { + widgetPropertyDto.setWidgetId(widgetDto.getId()); + widgetPropertyMapper.insert(widgetPropertyDto); } + } } public void insert(DashboardDto dashboardDto) { diff --git a/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java b/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java index a10ffd71f27..db5e428cc14 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java +++ b/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java @@ -35,7 +35,6 @@ import org.sonar.db.WildcardPosition; public class GroupDao implements Dao { - private static final String SQL_WILDCARD = "%"; private System2 system; public GroupDao(System2 system) { diff --git a/sonar-db/src/main/java/org/sonar/db/version/v52/MoveProjectProfileAssociation.java b/sonar-db/src/main/java/org/sonar/db/version/v52/MoveProjectProfileAssociation.java index 21451eb8fb8..bbfdd267962 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v52/MoveProjectProfileAssociation.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v52/MoveProjectProfileAssociation.java @@ -79,6 +79,11 @@ public class MoveProjectProfileAssociation extends BaseDataChange { update.setLong(1, id); return true; } + + private static String extractLanguage(String propertyKey) { + return propertyKey.substring("sonar.profile.".length()); + } + } private static final Logger LOGGER = Loggers.get(MoveProjectProfileAssociation.class); @@ -111,10 +116,6 @@ public class MoveProjectProfileAssociation extends BaseDataChange { } } - private static String extractLanguage(String propertyKey) { - return propertyKey.substring("sonar.profile.".length()); - } - private Table getProfileKeysByLanguageThenName(final Context context) throws SQLException { final Table profilesByLanguageAndName = HashBasedTable.create(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java index 3566f57db81..09bb71d7f66 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java @@ -162,9 +162,7 @@ public class Checks { } configureFields(activeRule, check); return check; - } catch (InstantiationException e) { - throw failToInstantiateCheck(activeRule, checkClassOrInstance, e); - } catch (IllegalAccessException e) { + } catch (InstantiationException | IllegalAccessException e) { throw failToInstantiateCheck(activeRule, checkClassOrInstance, e); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java b/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java index a677bf45b9c..c5303b05c86 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java @@ -83,11 +83,9 @@ public final class AnnotationCheckFactory extends CheckFactory { configureFields(activeRule, check); return check; - } catch (InstantiationException e) { + } catch (InstantiationException | IllegalAccessException e) { throw new SonarException(CAN_NOT_INSTANTIATE_THE_CHECK_RELATED_TO_THE_RULE + activeRule, e); - } catch (IllegalAccessException e) { - throw new SonarException(CAN_NOT_INSTANTIATE_THE_CHECK_RELATED_TO_THE_RULE + activeRule, e); } } -- 2.39.5