Skip to content

Commit

Permalink
fix: ajustes sonar e code smells.
Browse files Browse the repository at this point in the history
  • Loading branch information
Renato Lopes committed Mar 29, 2024
1 parent 66325e1 commit e8e20de
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<surefire-plugin.version>3.2.5</surefire-plugin.version>
<sonar.organization>renatolopescaixa</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.coverage.jacoco.xmlReportPaths>src/test/jacoco-report/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<sonar.coverage.jacoco.xmlReportPaths>target/jacoco-report/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>
<dependencyManagement>
<dependencies>
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/br/gov/caixa/teia/resource/DesafioResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,27 @@
@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")
@APIResponse(responseCode = "500", description = "Erro interno do servidor")
public RestResponse<DesafioResponseDto> 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
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/br/gov/caixa/teia/service/DesafioService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 0 additions & 6 deletions src/test/jacoco-report/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion src/test/jacoco-report/jacoco.xml

This file was deleted.

0 comments on commit e8e20de

Please sign in to comment.