rethianita / spring-book

Local variables should not be assigned in return statements JAVA-W1037
Anti-pattern
Major
a year agoa year old
user is assigned in this return statement
20      var authentication = SecurityContextHolder.getContext().getAuthentication();
21      User user = null;
22      if (authentication != null && authentication.getPrincipal() instanceof User) {
23        user = (User) authentication.getPrincipal();24      }
25      return ofNullable(user).map(User::getId);
26    };