Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics.kt class warnings #108

Open
TomerPacific opened this issue Oct 12, 2024 · 2 comments
Open

Analytics.kt class warnings #108

TomerPacific opened this issue Oct 12, 2024 · 2 comments

Comments

@TomerPacific
Copy link
Contributor

Building the project, I noticed the following warnings for the Analytics.kt class:

  1. In the method generateOSVersionString:
private fun generateOSVersionString(major: Any, minor: Any? = "0", patch: Any? = null): String {
    val patchStr = if (patch != null) patch.toString().toAnalyticsVersionStr() else ""
    val minorStr = minor.toString().padStart(2, '0').toLong().toString(2).toAnalyticsVersionStr()
    val majorStr = major.toString().padStart(2, '0').toLong().toString(2).toAnalyticsVersionStr()

    return "$majorStr$minorStr"
}

patchStr is never used

  1. In the method String.toAnalyticsVersionStr()
private fun String.toAnalyticsVersionStr(): String {
    val num = this.toInt(2)
    return when (val num = this.toInt(2)) {
        in 0..25 -> {
            ('A' + num).toString()
        }
        in 26..51 -> {
            ('a' + num - 26).toString()
        }
        else -> ('0' + num - 52).toString()
    }
}

the local variable num is never used

  1. In the method String.toAnalyticsVersionStr()
private fun String.toAnalyticsVersionStr(): String {
    val num = this.toInt(2)
    return when (val num = this.toInt(2)) {
        in 0..25 -> {
            ('A' + num).toString()
        }
        in 26..51 -> {
            ('a' + num - 26).toString()
        }
        else -> ('0' + num - 52).toString()
    }
}

There are two variables named num, thus causing variable shadowing

Relates to #107

@TomerPacific
Copy link
Contributor Author

I'd like to fix this, if possible.

@wissam-khalili
Copy link

@adimiz1 - Can you please check this PR please ?

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

No branches or pull requests

2 participants