rethianita / spring-book

Undocumented method found JAVA-D1001
Documentation
Minor
92 occurrences in this check
Consider adding a doc comment for loadUserByUsername
 84    return userViewMapper.toUserView(user);
 85  }
 86
 87  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 88    return userRepo 89        .findByUsername(username) 90        .orElseThrow( 91            () -> 92                new UsernameNotFoundException( 93                    format("User with username - %s, not found", username))); 94  } 95
 96  public boolean usernameExists(String username) {
 97    return userRepo.findByUsername(username).isPresent();
Consider adding a doc comment for delete
 72    }
 73  }
 74
 75  @Transactional 76  public UserView delete(ObjectId id) { 77    var user = userRepo.getById(id); 78 79    user.setUsername( 80        user.getUsername().replace("@", String.format("_%s@", user.getId().toString()))); 81    user.setEnabled(false); 82    user = userRepo.save(user); 83 84    return userViewMapper.toUserView(user); 85  } 86
 87  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
 88    return userRepo
Consider adding a doc comment for getUser
 97    return userRepo.findByUsername(username).isPresent();
 98  }
 99
100  public UserView getUser(ObjectId id) {101    return userViewMapper.toUserView(userRepo.getById(id));102  }103
104  public List<UserView> searchUsers(Page page, SearchUsersQuery query) {
105    List<User> users = userRepo.searchUsers(page, query);
Consider adding a doc comment for searchUsers
101    return userViewMapper.toUserView(userRepo.getById(id));
102  }
103
104  public List<UserView> searchUsers(Page page, SearchUsersQuery query) {105    List<User> users = userRepo.searchUsers(page, query);106    return userViewMapper.toUserView(users);107  }108}
Consider adding a doc comment for create
 32  private final UserViewMapper userViewMapper;
 33  private final PasswordEncoder passwordEncoder;
 34
 35  @Transactional 36  public UserView create(CreateUserRequest request) { 37    if (userRepo.findByUsername(request.username()).isPresent()) { 38      throw new ValidationException("Username exists!"); 39    } 40    if (!request.password().equals(request.rePassword())) { 41      throw new ValidationException("Passwords don't match!"); 42    } 43 44    var user = userEditMapper.create(request); 45    user.setPassword(passwordEncoder.encode(request.password())); 46 47    user = userRepo.save(user); 48 49    return userViewMapper.toUserView(user); 50  } 51
 52  @Transactional
 53  public UserView update(ObjectId id, UpdateUserRequest request) {
Consider adding a doc comment for update
 49    return userViewMapper.toUserView(user);
 50  }
 51
 52  @Transactional 53  public UserView update(ObjectId id, UpdateUserRequest request) { 54    var user = userRepo.getById(id); 55    userEditMapper.update(request, user); 56 57    user = userRepo.save(user); 58 59    return userViewMapper.toUserView(user); 60  } 61
 62  @Transactional
 63  public UserView upsert(CreateUserRequest request) {
Consider adding a doc comment for usernameExists
 93                    format("User with username - %s, not found", username)));
 94  }
 95
 96  public boolean usernameExists(String username) { 97    return userRepo.findByUsername(username).isPresent(); 98  } 99
100  public UserView getUser(ObjectId id) {
101    return userViewMapper.toUserView(userRepo.getById(id));
Consider adding a doc comment for upsert
 59    return userViewMapper.toUserView(user);
 60  }
 61
 62  @Transactional 63  public UserView upsert(CreateUserRequest request) { 64    var optionalUser = userRepo.findByUsername(request.username()); 65 66    if (optionalUser.isEmpty()) { 67      return create(request); 68    } else { 69      UpdateUserRequest updateUserRequest = 70          new UpdateUserRequest(request.fullName(), request.authorities()); 71      return update(optionalUser.get().getId(), updateUserRequest); 72    } 73  } 74
 75  @Transactional
 76  public UserView delete(ObjectId id) {
Consider adding a doc comment for getBook
64    return bookViewMapper.toBookView(book);
65  }
66
67  public BookView getBook(ObjectId id) {68    var book = bookRepo.getById(id);69    return bookViewMapper.toBookView(book);70  }71
72  public List<BookView> getBooks(Iterable<ObjectId> ids) {
73    var books = bookRepo.findAllById(ids);
Consider adding a doc comment for getBooks
69    return bookViewMapper.toBookView(book);
70  }
71
72  public List<BookView> getBooks(Iterable<ObjectId> ids) {73    var books = bookRepo.findAllById(ids);74    return bookViewMapper.toBookView(books);75  }76
77  public List<BookView> getAuthorBooks(ObjectId authorId) {
78    var author = authorRepo.getById(authorId);
Consider adding a doc comment for getAuthorBooks
74    return bookViewMapper.toBookView(books);
75  }
76
77  public List<BookView> getAuthorBooks(ObjectId authorId) {78    var author = authorRepo.getById(authorId);79    return bookViewMapper.toBookView(bookRepo.findAllById(author.getBookIds()));80  }81
82  public List<BookView> searchBooks(Page page, SearchBooksQuery query) {
83    return bookViewMapper.toBookView(bookRepo.searchBooks(page, query));
Consider adding a doc comment for create
26  private final BookEditMapper bookEditMapper;
27  private final BookViewMapper bookViewMapper;
28
29  @Transactional30  public BookView create(EditBookRequest request) {31    var book = bookEditMapper.create(request);3233    book = bookRepo.save(book);34    updateAuthors(book);3536    return bookViewMapper.toBookView(book);37  }38
39  @Transactional
40  public BookView update(ObjectId id, EditBookRequest request) {
Consider adding a doc comment for update
36    return bookViewMapper.toBookView(book);
37  }
38
39  @Transactional40  public BookView update(ObjectId id, EditBookRequest request) {41    var book = bookRepo.getById(id);42    bookEditMapper.update(request, book);4344    book = bookRepo.save(book);45    if (!CollectionUtils.isEmpty(request.authorIds())) {46      updateAuthors(book);47    }4849    return bookViewMapper.toBookView(book);50  }51
52  private void updateAuthors(Book book) {
53    var authors = authorRepo.findAllById(book.getAuthorIds());
Consider adding a doc comment for searchBooks
79    return bookViewMapper.toBookView(bookRepo.findAllById(author.getBookIds()));
80  }
81
82  public List<BookView> searchBooks(Page page, SearchBooksQuery query) {83    return bookViewMapper.toBookView(bookRepo.searchBooks(page, query));84  }85}
Consider adding a doc comment for updateAuthors
49    return bookViewMapper.toBookView(book);
50  }
51
52  private void updateAuthors(Book book) {53    var authors = authorRepo.findAllById(book.getAuthorIds());54    authors.forEach(author -> author.getBookIds().add(book.getId()));55    authorRepo.saveAll(authors);56  }57
58  @Transactional
59  public BookView delete(ObjectId id) {
Consider adding a doc comment for delete
55    authorRepo.saveAll(authors);
56  }
57
58  @Transactional59  public BookView delete(ObjectId id) {60    var book = bookRepo.getById(id);6162    bookRepo.delete(book);6364    return bookViewMapper.toBookView(book);65  }66
67  public BookView getBook(ObjectId id) {
68    var book = bookRepo.getById(id);
Consider adding a doc comment for getBookAuthors
61    return authorViewMapper.toAuthorView(authorRepo.findAllById(ids));
62  }
63
64  public List<AuthorView> getBookAuthors(ObjectId bookId) {65    var book = bookRepo.getById(bookId);66    return authorViewMapper.toAuthorView(authorRepo.findAllById(book.getAuthorIds()));67  }68
69  public List<AuthorView> searchAuthors(Page page, SearchAuthorsQuery query) {
70    return authorViewMapper.toAuthorView(authorRepo.searchAuthors(page, query));
Consider adding a doc comment for getAuthor
53    return authorViewMapper.toAuthorView(author);
54  }
55
56  public AuthorView getAuthor(ObjectId id) {57    return authorViewMapper.toAuthorView(authorRepo.getById(id));58  }59
60  public List<AuthorView> getAuthors(Iterable<ObjectId> ids) {
61    return authorViewMapper.toAuthorView(authorRepo.findAllById(ids));
Consider adding a doc comment for searchAuthors
66    return authorViewMapper.toAuthorView(authorRepo.findAllById(book.getAuthorIds()));
67  }
68
69  public List<AuthorView> searchAuthors(Page page, SearchAuthorsQuery query) {70    return authorViewMapper.toAuthorView(authorRepo.searchAuthors(page, query));71  }72}
Consider adding a doc comment for getAuthors
57    return authorViewMapper.toAuthorView(authorRepo.getById(id));
58  }
59
60  public List<AuthorView> getAuthors(Iterable<ObjectId> ids) {61    return authorViewMapper.toAuthorView(authorRepo.findAllById(ids));62  }63
64  public List<AuthorView> getBookAuthors(ObjectId bookId) {
65    var book = bookRepo.getById(bookId);
Consider adding a doc comment for delete
43    return authorViewMapper.toAuthorView(author);
44  }
45
46  @Transactional47  public AuthorView delete(ObjectId id) {48    var author = authorRepo.getById(id);4950    authorRepo.delete(author);51    bookRepo.deleteAll(bookRepo.findAllById(author.getBookIds()));5253    return authorViewMapper.toAuthorView(author);54  }55
56  public AuthorView getAuthor(ObjectId id) {
57    return authorViewMapper.toAuthorView(authorRepo.getById(id));
Consider adding a doc comment for update
33    return authorViewMapper.toAuthorView(author);
34  }
35
36  @Transactional37  public AuthorView update(ObjectId id, EditAuthorRequest request) {38    var author = authorRepo.getById(id);39    authorEditMapper.update(request, author);4041    author = authorRepo.save(author);4243    return authorViewMapper.toAuthorView(author);44  }45
46  @Transactional
47  public AuthorView delete(ObjectId id) {
Consider adding a doc comment for create
24  private final AuthorEditMapper authorEditMapper;
25  private final AuthorViewMapper authorViewMapper;
26
27  @Transactional28  public AuthorView create(EditAuthorRequest request) {29    var author = authorEditMapper.create(request);3031    author = authorRepo.save(author);3233    return authorViewMapper.toAuthorView(author);34  }35
36  @Transactional
37  public AuthorView update(ObjectId id, EditAuthorRequest request) {
Consider adding a doc comment for searchUsers
 62
 63interface UserRepoCustom {
 64
 65  List<User> searchUsers(Page page, SearchUsersQuery query); 66}
 67
 68@RequiredArgsConstructor
Consider adding a doc comment for findByUsername
 56    return optionalUser.get();
 57  }
 58
 59  @Cacheable 60  Optional<User> findByUsername(String username); 61}
 62
 63interface UserRepoCustom {