Skip to content

Commit d3b58bb

Browse files
committed
Sonar findings
1 parent 8fa2799 commit d3b58bb

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

server/src/main/java/dev/findfirst/core/dto/BookmarkDTO.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.fasterxml.jackson.annotation.JsonProperty;
77
import lombok.AllArgsConstructor;
8+
import lombok.Builder;
89
import lombok.Getter;
910
import lombok.NoArgsConstructor;
1011
import lombok.Setter;
@@ -15,6 +16,7 @@
1516
@Setter
1617
@AllArgsConstructor
1718
@NoArgsConstructor
19+
@Builder
1820
public class BookmarkDTO {
1921

2022
private long id;
@@ -27,9 +29,4 @@ public class BookmarkDTO {
2729
private List<TagOnly> tags;
2830
private String textHighlight;
2931

30-
public BookmarkDTO(long id, String title, String url, String screenshotUrl, boolean scrapable,
31-
Date createdDate, Date lastModifiedOn, List<TagOnly> tags) {
32-
// we don't have any highlighted text.
33-
this(id, title, url, screenshotUrl, scrapable, createdDate, lastModifiedOn, tags, null);
34-
}
3532
}

server/src/main/java/dev/findfirst/core/service/BookmarkService.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,12 @@ public List<BookmarkDTO> convertBookmarkJDBCToDTO(List<BookmarkJDBC> bookmarkEnt
137137
tagDTOs.add(new TagOnly(t.getId(), t.getTitle()));
138138
}
139139

140-
return new BookmarkDTO(ent.getId(), ent.getTitle(), ent.getUrl(), ent.getScreenshotUrl(),
141-
ent.getScrapable(), ent.getCreatedDate(), ent.getLastModifiedDate(), tagDTOs);
140+
var dto = BookmarkDTO.builder().id(ent.getId()).title(ent.getTitle()).url(ent.getUrl())
141+
.screenshotUrl(ent.getScreenshotUrl()).scrapable(ent.getScrapable())
142+
.createdDate(ent.getCreatedDate()).lastModifiedOn(ent.getLastModifiedDate()).tags(tagDTOs)
143+
.build();
144+
145+
return dto;
142146
}).toList();
143147
}
144148

@@ -349,7 +353,8 @@ public Flux<BookmarkDTO> importBookmarks(String htmlFile) {
349353
| URISyntaxException ex) {
350354
log.error(ex.getMessage());
351355
}
352-
return new BookmarkDTO(0, null, null, null, false, null, null, null);
356+
// empty bookmark.
357+
return new BookmarkDTO();
353358
}).delayElements(Duration.ofMillis(100));
354359
}
355360

server/src/main/java/dev/findfirst/core/service/TypesenseService.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
@Slf4j
2828
public class TypesenseService {
2929

30-
public record SearchHighlightResult(Long id, String highlight) {
31-
};
30+
public record SearchHighlightResult(Long id, String highlight) {};
3231

3332
private final TypsenseInitializationRepository initRepo;
3433

@@ -58,7 +57,8 @@ private CollectionSchema createCollectionSchemaSchema() {
5857

5958
private String saveSchema(TypesenseInitRecord initRecord) {
6059
try {
61-
CollectionResponse collectionResponse = client.collections().create(createCollectionSchemaSchema());
60+
CollectionResponse collectionResponse =
61+
client.collections().create(createCollectionSchemaSchema());
6262
log.debug(collectionResponse.toString());
6363
initRecord.setInitialized(true);
6464
initRepo.save(initRecord);
@@ -93,7 +93,8 @@ public List<SearchHighlightResult> search(String text) {
9393
.highlightFields("text").highlightStartTag("<mark>").highlightEndTag("</mark>");
9494
try {
9595
log.debug("searching");
96-
SearchResult searchResult = client.collections(schemaName).documents().search(searchParameters);
96+
SearchResult searchResult =
97+
client.collections(schemaName).documents().search(searchParameters);
9798
log.debug(searchResult.toString());
9899

99100
return searchResult.getHits().stream().map(hit -> {

0 commit comments

Comments
 (0)