Skip to content

Conversation

@robinlinden
Copy link
Collaborator

No description provided.

value class PublicKey(private val value: String) {
fun bytes() = hexToBytes(value)
fun string() = value
fun fingerprint() = value.take(8)

Check warning

Code scanning / detekt

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning

This expression contains a magic number. Consider defining it to a well named constant.
private val viewModel: ChatViewModel by viewModels { vmFactory }

private lateinit var contactPubKey: String
private var contactPubKey = PublicKey("")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit strange that the empty string is a valid public key, but ok.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this one made me sad. No way to have a lateinit value class apparently. I'll clean these things up once I add a require in the PublicKey-ctor to require all pks to be valid pks. :/

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2020 aTox contributors
// SPDX-FileCopyrightText: 2019-2025 Robin Lindén <[email protected]>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only you now? :P no more contributors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it was always just me in this file, but I set all files to "aTox contributors" in the script that added them. :( I add back myself as I touch files.

@robinlinden robinlinden force-pushed the value-class-cleanup branch 2 times, most recently from 86fef43 to bb6a698 Compare February 9, 2025 01:59
This means a lot of conversions go away.
@robinlinden robinlinden force-pushed the value-class-cleanup branch from bb6a698 to 9dee188 Compare May 11, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants