From e8e20de39386c2e0ea2b7bb93170f383ecef9b6f Mon Sep 17 00:00:00 2001 From: Renato Lopes Date: Thu, 28 Mar 2024 21:17:39 -0300 Subject: [PATCH] fix: ajustes sonar e code smells. --- pom.xml | 2 +- .../gov/caixa/teia/resource/DesafioResource.java | 15 +++++++++------ .../br/gov/caixa/teia/service/DesafioService.java | 6 +++++- src/main/resources/application.yml | 3 --- src/test/jacoco-report/.gitignore | 6 ------ src/test/jacoco-report/jacoco.xml | 1 - 6 files changed, 15 insertions(+), 18 deletions(-) delete mode 100644 src/test/jacoco-report/.gitignore delete mode 100644 src/test/jacoco-report/jacoco.xml diff --git a/pom.xml b/pom.xml index c56537b..9c77992 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 3.2.5 renatolopescaixa https://sonarcloud.io - src/test/jacoco-report/jacoco.xml + target/jacoco-report/jacoco.xml diff --git a/src/main/java/br/gov/caixa/teia/resource/DesafioResource.java b/src/main/java/br/gov/caixa/teia/resource/DesafioResource.java index 667cd6f..9f12474 100644 --- a/src/main/java/br/gov/caixa/teia/resource/DesafioResource.java +++ b/src/main/java/br/gov/caixa/teia/resource/DesafioResource.java @@ -22,15 +22,18 @@ @Path("/manipulacao-string") public class DesafioResource { - @Inject - Logger log; + private final Logger log; + private final DesafioService service; @Inject - DesafioService service; + public DesafioResource(DesafioService service, Logger log) { + this.service = service; + this.log = log; + } @POST @RunOnVirtualThread - @CacheResult(cacheName = "desafio-cache") + @CacheResult(cacheName = "desafio-cache") @Operation(summary = "Manipular String", description = "Verifica se a string é um palíndromo e conta o número de ocorrências de cada caractere.") @APIResponse(responseCode = "200", description = "Operação bem-sucedida", content = @Content(mediaType = "application/json", schema = @Schema(implementation = DesafioResponseDto.class))) @APIResponse(responseCode = "400", description = "Solicitação inválida") @@ -38,8 +41,8 @@ public class DesafioResource { public RestResponse manipularString(@RequestBody(required = true) DesafioRequestDto request) { String texto = request.getTexto(); log.info("Recebida solicitação para manipular a string: " + texto); - - //Verifica se a string foi passada no Request body + + // Verifica se a string foi passada no Request body service.validaBody(texto); // Verifica se a string é um palíndromo diff --git a/src/main/java/br/gov/caixa/teia/service/DesafioService.java b/src/main/java/br/gov/caixa/teia/service/DesafioService.java index 78c535b..c1f8b82 100644 --- a/src/main/java/br/gov/caixa/teia/service/DesafioService.java +++ b/src/main/java/br/gov/caixa/teia/service/DesafioService.java @@ -12,8 +12,12 @@ @ApplicationScoped public class DesafioService { + private final Logger log; + @Inject - Logger log; + public DesafioService(Logger log) { + this.log = log; + } public void validaBody(String texto) { if (texto == null) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index dc0d682..e04397a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -21,9 +21,6 @@ quarkus: info-contact-url: https://github.com/renatoLopesCaixa info-license-name: MIT License info-license-url: https://www.mit.edu/~amini/LICENSE.md - - jacoco: - report-location: src/test/jacoco-report #para o desafio deixei o swagger-ui habilitado em prod swagger-ui: diff --git a/src/test/jacoco-report/.gitignore b/src/test/jacoco-report/.gitignore deleted file mode 100644 index 94f5257..0000000 --- a/src/test/jacoco-report/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/br.gov.caixa.teia.resource/ -/br.gov.caixa.teia.service/ -/index.html -/jacoco-resources/ -/jacoco-sessions.html -/jacoco.csv diff --git a/src/test/jacoco-report/jacoco.xml b/src/test/jacoco-report/jacoco.xml deleted file mode 100644 index aac0996..0000000 --- a/src/test/jacoco-report/jacoco.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file