define constant instead of duplicating 3 times

I’m fairly new to Node.js and I am having some issues. I received error in sonarqube as define a constant instead of duplicating 3 times for "Invalid Password". how can i resolved this issue. export const MessageCodeMapping = { REQUEST_COMPLETED_SUCCESSFULLY: { code: "1", description: "REQUEST_COMPLETED_SUCCESSFULLY", detailedDescription: "REQUEST_COMPLETED_SUCCESSFULLY", }, INVALID_CREATE_PASSWORD: { code: "4", description: "Invalid Password",… Read More define constant instead of duplicating 3 times

How to remove Sonar issue on Java stream "Refactor the code so this stream pipeline is used"

I’m working on a project (Java 17) where I have a list of object with two properties, actionId (String) and right (boolean). I’m trying to get the actionId for object with right = true and store the result as List of String. This is my code: List<String> usserValidActionsArray = userActionGatewayDTO.stream().filter(UserActionGatewayDTO::getRight) .map(UserActionGatewayDTO::getActionId).toList(); My code works fine,… Read More How to remove Sonar issue on Java stream "Refactor the code so this stream pipeline is used"

SonarQube Java – Boolean literals should not be redundant – True/Null

I have the followin snippet inside a method: public void foo(Bar bar){ this.setSomeField(bar.equals(somePredefinedObject) ? null : true); } Sonarqube complains about using the literal true in there. I feel like I can’t just get rid of it so easily, because if that expression evaluates to false, I don’t pass in false but rather pass in… Read More SonarQube Java – Boolean literals should not be redundant – True/Null

"Optional value should only be accessed after calling isPresent()" although checked in if for multiple values

I receive a Customer object which contains lastName and firstName. In the conversion I check if both values are not empty and then pass them into the DTO: if (customer.getFirstName().isPresent() && customer.getLastName().isPresent()) { final String firstName = customer.getFirstName().get(); final String lastName = customer.getLastName().get(); // do assignment } But I still get the Sonar message Optional… Read More "Optional value should only be accessed after calling isPresent()" although checked in if for multiple values