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

LambdaParameterNaming false positives on data class constructors #5433

Closed
TWiStErRob opened this issue Oct 17, 2022 · 0 comments · Fixed by #5465
Closed

LambdaParameterNaming false positives on data class constructors #5433

TWiStErRob opened this issue Oct 17, 2022 · 0 comments · Fixed by #5465
Labels

Comments

@TWiStErRob
Copy link
Member

TWiStErRob commented Oct 17, 2022

Expected Behavior

No findings.

Observed Behavior

data class UserInfoOpenID(
	...
	/**
	 * The user's given name(s) or first name(s).
	 * _Might be provided when a [name] claim is present._
	 * @since profile
	 */
	val given_name: String?,

is flagged as:

LambdaParameterNaming - [Lambda parameter names should match the pattern: [a-z][A-Za-z0-9]*|_] at Heroku\backend\endpoint\src\main\kotlin\net\twisterrob\cinema\cineworld\backend\endpoint\auth\data\UserInfoOpenID.kt:35:6

Steps to Reproduce

    @Test
    fun `doesn't report invalid class constructor parameters`() {
        val code = """
            data class C(val _invalid: String)
        """.trimIndent()
        assertThat(LambdaParameterNaming().compileAndLint(code))
            .isEmpty()
    }

    @Test
    fun `doesn't report invalid function parameters`() {
        val code = """
            fun f(val _invalid: String) = Unit
        """.trimIndent()
        assertThat(LambdaParameterNaming().compileAndLint(code))
            .isEmpty()
    }

Context

Could be caused by #5212 cc @VovaStelmashchuk @cortinico.

In the original code it was like this (notice the override vs the delegated method):

    override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression) {
        super.visitLambdaExpression(lambdaExpression)
        lambdaExpression.valueParameters
            .forEach { lambdaParameterNamingRule.runIfActive { visitParameter(it) } }
    }

Your Environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant