fix: suppress deprecation and unchecked cast warnings in Quartz internal code
Deprecated APIs in Quartz are kept for library consumers but internal usages now carry @Suppress annotations so the module builds warning-free. Also replaces redundant .toInt() on hex Int literals in ChaCha20Core and migrates deprecated java.net.URL to URI.resolve() in ServerInfoParser. The spotless license header delimiter is updated to recognize @file: annotations. https://claude.ai/code/session_01EwS56YAGGnnac5EuwhaUSs
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ allprojects {
|
|||||||
target 'src/**/*.kt'
|
target 'src/**/*.kt'
|
||||||
|
|
||||||
ktlint()
|
ktlint()
|
||||||
licenseHeaderFile rootProject.file('.spotless/copyright.kt'), "package|import|class|object|sealed|open|interface|abstract "
|
licenseHeaderFile rootProject.file('.spotless/copyright.kt'), "@file:|package|import|class|object|sealed|open|interface|abstract "
|
||||||
}
|
}
|
||||||
|
|
||||||
groovyGradle {
|
groovyGradle {
|
||||||
|
|||||||
+1
@@ -83,6 +83,7 @@ class NostrSignerExternal(
|
|||||||
val result = backgroundQuery.sign(unsignedEvent) ?: foregroundQuery.sign(unsignedEvent)
|
val result = backgroundQuery.sign(unsignedEvent) ?: foregroundQuery.sign(unsignedEvent)
|
||||||
|
|
||||||
if (result is SignerResult.RequestAddressed.Successful<SignResult>) {
|
if (result is SignerResult.RequestAddressed.Successful<SignResult>) {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
(result.result.event as? T)?.let {
|
(result.result.event as? T)?.let {
|
||||||
return it
|
return it
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -38,6 +38,7 @@ class GalleryListEvent(
|
|||||||
content: String,
|
content: String,
|
||||||
sig: HexKey,
|
sig: HexKey,
|
||||||
) : PrivateTagArrayEvent(id, pubKey, createdAt, KIND, tags, content, sig) {
|
) : PrivateTagArrayEvent(id, pubKey, createdAt, KIND, tags, content, sig) {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
companion object {
|
companion object {
|
||||||
const val KIND = 10011
|
const val KIND = 10011
|
||||||
const val ALT = "Profile Gallery"
|
const val ALT = "Profile Gallery"
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ data class NNote(
|
|||||||
return NNote(bytes.toHexKey())
|
return NNote(bytes.toHexKey())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
fun create(eventId: HexKey): String = eventId.hexToByteArray().toNote()
|
fun create(eventId: HexKey): String = eventId.hexToByteArray().toNote()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ class GitReplyEvent(
|
|||||||
|
|
||||||
fun rootIssueOrPatch() = tags.lastNotNullOfOrNull(MarkedETag::parseRootId)
|
fun rootIssueOrPatch() = tags.lastNotNullOfOrNull(MarkedETag::parseRootId)
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
companion object {
|
companion object {
|
||||||
const val KIND = 1622
|
const val KIND = 1622
|
||||||
const val ALT_DESCRIPTION = "A Git Reply"
|
const val ALT_DESCRIPTION = "A Git Reply"
|
||||||
|
|||||||
+5
@@ -32,12 +32,17 @@ import com.vitorpamplona.quartz.nip34Git.issue.GitIssueEvent
|
|||||||
import com.vitorpamplona.quartz.nip34Git.patch.GitPatchEvent
|
import com.vitorpamplona.quartz.nip34Git.patch.GitPatchEvent
|
||||||
import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent
|
import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
fun TagArrayBuilder<GitReplyEvent>.repository(rep: ATag) = addUnique(rep.toATagArray())
|
fun TagArrayBuilder<GitReplyEvent>.repository(rep: ATag) = addUnique(rep.toATagArray())
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
fun TagArrayBuilder<GitReplyEvent>.repository(rep: EventHintBundle<GitRepositoryEvent>) = addUnique(rep.toATag().toATagArray())
|
fun TagArrayBuilder<GitReplyEvent>.repository(rep: EventHintBundle<GitRepositoryEvent>) = addUnique(rep.toATag().toATagArray())
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
fun TagArrayBuilder<GitReplyEvent>.patch(rep: EventHintBundle<GitPatchEvent>) = addUnique(rep.toMarkedETag(MarkedETag.MARKER.ROOT).toTagArray())
|
fun TagArrayBuilder<GitReplyEvent>.patch(rep: EventHintBundle<GitPatchEvent>) = addUnique(rep.toMarkedETag(MarkedETag.MARKER.ROOT).toTagArray())
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
fun TagArrayBuilder<GitReplyEvent>.issue(rep: EventHintBundle<GitIssueEvent>) = addUnique(rep.toMarkedETag(MarkedETag.MARKER.ROOT).toTagArray())
|
fun TagArrayBuilder<GitReplyEvent>.issue(rep: EventHintBundle<GitIssueEvent>) = addUnique(rep.toMarkedETag(MarkedETag.MARKER.ROOT).toTagArray())
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
fun TagArrayBuilder<GitReplyEvent>.notify(list: List<PTag>) = pTags(list)
|
fun TagArrayBuilder<GitReplyEvent>.notify(list: List<PTag>) = pTags(list)
|
||||||
|
|||||||
+1
@@ -111,6 +111,7 @@ class TorrentCommentEvent(
|
|||||||
|
|
||||||
fun torrentIds() = tags.firstNotNullOfOrNull(MarkedETag::parseRootId) ?: tags.firstNotNullOfOrNull(ETag::parseId)
|
fun torrentIds() = tags.firstNotNullOfOrNull(MarkedETag::parseRootId) ?: tags.firstNotNullOfOrNull(ETag::parseId)
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
companion object {
|
companion object {
|
||||||
const val KIND = 2004
|
const val KIND = 2004
|
||||||
const val ALT_DESCRIPTION = "Comment for a Torrent file"
|
const val ALT_DESCRIPTION = "Comment for a Torrent file"
|
||||||
|
|||||||
+4
-4
@@ -32,10 +32,10 @@ package com.vitorpamplona.quartz.nip44Encryption.crypto
|
|||||||
*/
|
*/
|
||||||
object ChaCha20Core {
|
object ChaCha20Core {
|
||||||
// "expand 32-byte k" as little-endian integers
|
// "expand 32-byte k" as little-endian integers
|
||||||
private const val SIGMA0 = 0x61707865.toInt()
|
private const val SIGMA0 = 0x61707865
|
||||||
private const val SIGMA1 = 0x3320646e.toInt()
|
private const val SIGMA1 = 0x3320646e
|
||||||
private const val SIGMA2 = 0x79622d32.toInt()
|
private const val SIGMA2 = 0x79622d32
|
||||||
private const val SIGMA3 = 0x6b206574.toInt()
|
private const val SIGMA3 = 0x6b206574
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ChaCha20 quarter round (RFC 8439 §2.1).
|
* ChaCha20 quarter round (RFC 8439 §2.1).
|
||||||
|
|||||||
+1
@@ -118,6 +118,7 @@ class NostrSignerRemote(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (result is SignerResult.RequestAddressed.Successful<SignResult>) {
|
if (result is SignerResult.RequestAddressed.Successful<SignResult>) {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
(result.result.event as? T)?.let {
|
(result.result.event as? T)?.let {
|
||||||
return it
|
return it
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -73,6 +73,7 @@ class LabeledBookmarkListEvent(
|
|||||||
|
|
||||||
fun title() = tags.firstNotNullOfOrNull(TitleTag::parse)
|
fun title() = tags.firstNotNullOfOrNull(TitleTag::parse)
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
fun titleOrName() = title() ?: name()
|
fun titleOrName() = title() ?: name()
|
||||||
|
|
||||||
fun description() = tags.firstNotNullOfOrNull(DescriptionTag::parse)
|
fun description() = tags.firstNotNullOfOrNull(DescriptionTag::parse)
|
||||||
|
|||||||
+1
@@ -64,6 +64,7 @@ class PeopleListEvent(
|
|||||||
@Deprecated("NIP-51 has deprecated name. Use title instead", ReplaceWith("title()"))
|
@Deprecated("NIP-51 has deprecated name. Use title instead", ReplaceWith("title()"))
|
||||||
fun name() = tags.firstNotNullOfOrNull(NameTag::parse)
|
fun name() = tags.firstNotNullOfOrNull(NameTag::parse)
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
fun titleOrName() = title() ?: name()
|
fun titleOrName() = title() ?: name()
|
||||||
|
|
||||||
fun title() = tags.firstNotNullOfOrNull(TitleTag::parse)
|
fun title() = tags.firstNotNullOfOrNull(TitleTag::parse)
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("DEPRECATION")
|
||||||
|
|
||||||
package com.vitorpamplona.quartz.nip56Reports
|
package com.vitorpamplona.quartz.nip56Reports
|
||||||
|
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("DEPRECATION", "UNCHECKED_CAST")
|
||||||
|
|
||||||
package com.vitorpamplona.quartz.utils
|
package com.vitorpamplona.quartz.utils
|
||||||
|
|
||||||
import com.vitorpamplona.quartz.experimental.attestations.attestation.AttestationEvent
|
import com.vitorpamplona.quartz.experimental.attestations.attestation.AttestationEvent
|
||||||
|
|||||||
+1
-2
@@ -21,7 +21,6 @@
|
|||||||
package com.vitorpamplona.quartz.nip96FileStorage.info
|
package com.vitorpamplona.quartz.nip96FileStorage.info
|
||||||
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.net.URL
|
|
||||||
|
|
||||||
actual fun makeAbsoluteIfRelativeUrl(
|
actual fun makeAbsoluteIfRelativeUrl(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
@@ -32,7 +31,7 @@ actual fun makeAbsoluteIfRelativeUrl(
|
|||||||
if (apiUrl.isAbsolute) {
|
if (apiUrl.isAbsolute) {
|
||||||
potentiallyRelativeUrl
|
potentiallyRelativeUrl
|
||||||
} else {
|
} else {
|
||||||
URL(URL(baseUrl), potentiallyRelativeUrl).toString()
|
URI(baseUrl).resolve(potentiallyRelativeUrl).toString()
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
potentiallyRelativeUrl
|
potentiallyRelativeUrl
|
||||||
|
|||||||
Reference in New Issue
Block a user