spring-bootspring-data-jpasonarqubesonarqube-scanspring-repositories

SonarQube complains about JpaRepository method name


How everybody solve code smells related to method name on interfaces that extends JpaRepository? In my case I have an CpoWorkflowStepExecution entity and I want to find by id and date.

CpoWorkflowStepExecution:

@Entity
@Table(name = "cpo_workflow_step_execution", catalog = "cup_orchestrator")
public class CpoWorkflowStepExecution implements java.io.Serializable { 
    private Integer workflowStepExecutionId;
    private CpoWorkflowExecution cpoWorkflowExecution;
    private CpoWorkflowStep cpoWorkflowStep;
    private LocalDateTime startDate;
    private LocalDateTime finishDate;
    private String outcome;
    ...

WorkflowStepExecRep:

@Repository
public interface WorkflowStepExecRep extends JpaRepository<CpoWorkflowStepExecution, Integer>{

   Optional<CpoWorkflowStepExecution> findByCpoWorkflowStep_WorkflowStepIdAndFinishDateIsNull(String workflowStepId);

SonarQube: Rename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.


Solution

  • I've changed the method name by removing _ character and it worked perfectly with SonarQube and JpaRepository:

    findByCpoWorkflowStepWorkflowStepIdAndFinishDateIsNull