Sonar: Move constants to a class or enum I found one project on Internet and after I downloaded it, I got this message from SonarQube:

Move constants to a class or enum.

But, when I downloaded SonarLint, it did not report any code smell.
This is the code:
@Repository
public interface TaskRepository extends JpaRepository&lt;Task, Long&gt; {

    String QUERY = &quot;update Task t set t.isDeleted = true where t.id = :taskId&quot;;

    @Modifying
    @Query(QUERY)
    void deleteTaskById(@Param(value = &quot;taskId&quot;) long taskId);
}

My question is: Should I remove constant QUERY and write it directly into @Query or I can leave it like this?
Note: This is a short query and it can easily be put inside @Query. But I am also interested what would be the best practice if this query was longer(ex. if it had 300 characters or more).
Personally, I do not see the reason why this needs to be a variable in the first place. If I were you I would either move this into the @Query annotation or better yet I would create a @NamedQuery under your Task entity class.
Also on a side note, I would avoid naming the repository method deleteTaskById as this name implies that a matching object will be deleted from the database. Since this is not the case here, I would rename the method to markTaskAsDeleted to avoid ambiguity.