From 14d0b6ce03f0cef45e5c83a4290b948ee9cfa6e6 Mon Sep 17 00:00:00 2001 From: Insee - Domaine Outils Transverses Date: Tue, 29 Jun 2021 08:32:25 +0000 Subject: [PATCH] =?UTF-8?q?[BUG]=20=F0=9F=90=9B=20fix=20some=20sonar/compi?= =?UTF-8?q?lation=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédric Couralet --- .github/workflows/tag.yml | 1 + pom.xml | 2 ++ .../core/service/impl/PermissionServiceImpl.java | 11 ++++------- .../fr/insee/sugoi/app/cucumber/glue/WhoamiGlue.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index e6212a55..4522b8da 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -31,6 +31,7 @@ jobs: echo -e "\n\n" >> changelog.tmp cat CHANGELOG.md >> changelog.tmp mv changelog.tmp CHANGELOG.md + mvn -B spotless:apply git add . git commit -sm "[REL] :rocket: release version ${{ github.event.inputs.version }}" git push origin release-${{ github.event.inputs.version }} -f diff --git a/pom.xml b/pom.xml index d3d59a43..9169c7a2 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,7 @@ 1.8 2.27.2 2.3.31 + 4.0.5 @@ -339,6 +340,7 @@ pl.project13.maven git-commit-id-plugin + ${git-commit-id-plugin.version} validate diff --git a/sugoi-api-core/src/main/java/fr/insee/sugoi/core/service/impl/PermissionServiceImpl.java b/sugoi-api-core/src/main/java/fr/insee/sugoi/core/service/impl/PermissionServiceImpl.java index 68961e97..478ac849 100644 --- a/sugoi-api-core/src/main/java/fr/insee/sugoi/core/service/impl/PermissionServiceImpl.java +++ b/sugoi-api-core/src/main/java/fr/insee/sugoi/core/service/impl/PermissionServiceImpl.java @@ -14,11 +14,11 @@ package fr.insee.sugoi.core.service.impl; import fr.insee.sugoi.core.model.SugoiUser; -import fr.insee.sugoi.core.realm.RealmProvider; import fr.insee.sugoi.core.service.PermissionService; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,7 +26,6 @@ import org.apache.commons.lang.text.StrSubstitutor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -48,9 +47,7 @@ public class PermissionServiceImpl implements PermissionService { @Value("${fr.insee.sugoi.api.regexp.role.application.manager:}") private List applicationManagerRoleList; - @Autowired private RealmProvider realmProvider; - - public static final Logger logger = LoggerFactory.getLogger(PermissionService.class); + public static final Logger logger = LoggerFactory.getLogger(PermissionServiceImpl.class); @Override public boolean isReader(SugoiUser sugoiUser, String realm, String userStorage) { @@ -106,7 +103,7 @@ private boolean checkIfUserGetRoles(SugoiUser sugoiUser, List rolesSearc return true; } for (String role : roles) { - if (role.toUpperCase().matches(roleSearch.replaceAll("\\*", ".*").toUpperCase())) { + if (role.toUpperCase().matches(roleSearch.replace("*", ".*").toUpperCase())) { return true; } } @@ -181,7 +178,7 @@ private List getUserRightList(SugoiUser sugoiUser, List regexpLi } return null; }) - .filter(role -> role != null) + .filter(Objects::nonNull) .collect(Collectors.toList()); return roles; } diff --git a/sugoi-api-test/src/test/java/fr/insee/sugoi/app/cucumber/glue/WhoamiGlue.java b/sugoi-api-test/src/test/java/fr/insee/sugoi/app/cucumber/glue/WhoamiGlue.java index 0a82f7cd..6f2ff146 100644 --- a/sugoi-api-test/src/test/java/fr/insee/sugoi/app/cucumber/glue/WhoamiGlue.java +++ b/sugoi-api-test/src/test/java/fr/insee/sugoi/app/cucumber/glue/WhoamiGlue.java @@ -42,7 +42,7 @@ public WhoamiGlue(StepData stepData) { public void expect_to_receive_his_rights() { ObjectMapper mapper = new ObjectMapper(); try { - WhoamiView view = mapper.readValue(stepData.getLatestResponse().getBody(), WhoamiView.class); + mapper.readValue(stepData.getLatestResponse().getBody(), WhoamiView.class); assertThat("Data receive is a whoamiView", true, is(true)); } catch (JsonProcessingException e) { assertThat("Data receive is a whoamiView", false, is(true));