Skip to content
Merged
Prev Previous commit
Next Next commit
style: fix Qodana findings (javadoc order, regex, redundant cast, com…
…mented code, generics)
  • Loading branch information
erict875 committed Oct 6, 2025
commit 76bd6cbb5976c20a5fc66db0ea13cc2482bddcaf
2 changes: 1 addition & 1 deletion nostr-java-api/src/main/java/nostr/api/EventNostr.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public <U extends BaseMessage> U signAndSend() {
* @param relays relay map (name -> URI)
*/
public <U extends BaseMessage> U signAndSend(Map<String, String> relays) {
return (U) sign().send(relays);
return sign().send(relays);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion nostr-java-api/src/main/java/nostr/api/NIP44.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import nostr.event.tag.PubKeyTag;
import nostr.id.Identity;

@Slf4j
/**
* NIP-44 helpers (Encrypted DM with XChaCha20). Encrypt/decrypt content and DM events.
* Spec: https://github.com/nostr-protocol/nips/blob/master/44.md
*/
@Slf4j
public class NIP44 extends EventNostr {

/**
Expand Down
2 changes: 1 addition & 1 deletion nostr-java-api/src/main/java/nostr/api/NIP46.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import nostr.event.impl.GenericEvent;
import nostr.id.Identity;

@Slf4j
/**
* NIP-46 helpers (Nostr Connect). Build app requests and signer responses.
* Spec: https://github.com/nostr-protocol/nips/blob/master/46.md
*/
@Slf4j
public final class NIP46 extends EventNostr {

public NIP46(@NonNull Identity sender) {
Expand Down
2 changes: 1 addition & 1 deletion nostr-java-api/src/main/java/nostr/api/NIP57.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public NIP57 createZapRequestEvent(
null);
}

@SneakyThrows
/**
* Create a zap receipt event (kind 9735) acknowledging a zap payment.
*
Expand All @@ -185,6 +184,7 @@ public NIP57 createZapRequestEvent(
* @param zapRecipient the zap recipient pubkey (p-tag)
* @return this instance for chaining
*/
@SneakyThrows
public NIP57 createZapReceiptEvent(
@NonNull GenericEvent zapRequestEvent,
@NonNull String bolt11,
Expand Down
2 changes: 1 addition & 1 deletion nostr-java-api/src/main/java/nostr/api/NIP61.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ public NIP61 createNutzapInformationalEvent(
return this;
}

@SneakyThrows
/**
* Create a Nutzap event (kind 7374) from a structured payload.
*
* @param nutZap the structured Nutzap containing proofs, mint and optional target event
* @param content optional human-readable content
* @return this instance for chaining
*/
@SneakyThrows
public NIP61 createNutzapEvent(@NonNull NutZap nutZap, @NonNull String content) {

return createNutzapEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public SpringWebSocketClient(
this.relayUrl = relayUrl;
}

@NostrRetryable
/**
* Sends the provided {@link BaseMessage} over the WebSocket connection.
*
* @param eventMessage the message to send
* @return the list of responses from the relay
* @throws IOException if an I/O error occurs while sending the message
*/
@NostrRetryable
public List<String> send(@NonNull BaseMessage eventMessage) throws IOException {
String json = eventMessage.encode();
log.debug(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

@EqualsAndHashCode(callSuper = false)
public class CalendarContent<T extends BaseTag> extends NIP42Content {
// @JsonProperty
// private final String id;


// below fields mandatory
@Getter private final IdentifierTag identifierTag;
Expand Down Expand Up @@ -166,9 +165,9 @@ public Optional<GeohashTag> getGeohashTag() {
return getTagsByType(GeohashTag.class).stream().findFirst();
}

private <T extends BaseTag> List<T> getTagsByType(Class<T> clazz) {
private <E extends BaseTag> List<E> getTagsByType(Class<E> clazz) {
Tag annotation = clazz.getAnnotation(Tag.class);
List<T> list = getBaseTags(annotation).stream().map(clazz::cast).toList();
List<E> list = getBaseTags(annotation).stream().map(clazz::cast).toList();
return list;
}

Expand All @@ -178,7 +177,7 @@ private List<T> getBaseTags(@NonNull Tag type) {
List<T> value = classTypeTagsMap.get(code);
Optional<List<T>> value1 = Optional.ofNullable(value);
List<T> baseTags = value1.orElse(Collections.emptyList());
return (List<T>) baseTags;
return baseTags;
}

private void addTag(@NonNull T baseTag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
@JsonDeserialize(builder = CalendarRsvpContentBuilder.class)
@EqualsAndHashCode(callSuper = false)
public class CalendarRsvpContent extends NIP42Content {
// @JsonProperty
// private final String id;


// below fields mandatory
@Getter private final IdentifierTag identifierTag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public class CashuWallet {

@EqualsAndHashCode.Include private String privateKey;

/*
@EqualsAndHashCode.Include
private String unit;
*/

private Set<CashuMint> mints;
private Map<String, Set<Relay>> relays;
private Set<CashuToken> tokens;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
@Data
@EqualsAndHashCode(callSuper = false)
public class ZapReceipt implements JsonContent {
// @JsonIgnore
// private String id;


@JsonProperty private String bolt11;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Nip05Validator {
@Builder.Default @JsonIgnore
private final HttpClientProvider httpClientProvider = new DefaultHttpClientProvider();

private static final Pattern LOCAL_PART_PATTERN = Pattern.compile("^[a-zA-Z0-9-_\\.]+$");
private static final Pattern LOCAL_PART_PATTERN = Pattern.compile("^[a-zA-Z0-9-_.]+$");
private static final Pattern DOMAIN_PATTERN = Pattern.compile("^[A-Za-z0-9.-]+(:\\d{1,5})?$");
private static final ObjectMapper MAPPER_BLACKBIRD =
JsonMapper.builder().addModule(new BlackbirdModule()).build();
Expand Down