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

If getValue is declared as an extension method ktlint thinks its unused #54

Closed
JLLeitschuh opened this issue Jun 6, 2017 · 2 comments
Closed

Comments

@JLLeitschuh
Copy link
Contributor

Example:

import com.natpryce.konfig.PropertyGroup
import com.natpryce.konfig.getValue
import com.natpryce.konfig.stringType

interface EventConfiguration {
    val url: String

    companion object {
        private object rabbitmq : PropertyGroup() {
            val url by stringType // This is where getValue is used.
        }
}

This is how getValue is defined:

operator fun <G : PropertyGroup, T> ((PropertyLocation, String) -> T).getValue(group: G, property: KProperty<*>) =
        group.key(property.name, this)

operator fun <SCOPE, T> ((PropertyLocation, String) -> T).getValue(scope: SCOPE?, property: KProperty<*>) =
        Key(property.name, this)

Kt-lint thinks that import com.natpryce.konfig.getValue is an unused import so you have to disable the check using // ktlint-disable.

@shyiko shyiko closed this as completed in d8a8c7a Jun 6, 2017
@shyiko
Copy link
Collaborator

shyiko commented Jun 6, 2017

@JLLeitschuh Thank you. Fixed in 0.8.2 (Maven Central sync might take up to 25min).

@JLLeitschuh
Copy link
Contributor Author

While you are at it you should fix it for setValue

shyiko added a commit that referenced this issue Jul 24, 2017
* 'master' of github.com:shyiko/ktlint:
  CI with JDK 8
  Upgrade to kotlin 1.1.3-2
  🤦
  allow for named lambdas
  Fix misleading indent lint error message
  Added 0.8.3 release note(s)
  Fixed #55 - If `setValue` is declared as an extension method ktlint thinks its unused
  Fixed #59 - Semicolon at end of package declaration not reported, different error instead
  Fix regression for spacing around else keyword
  Implement spacing after setter and getter
  Add test cases for spacing after setter and getter
  Added 0.8.2 release note
  Fixed #54 - if `getValue` is declared as an extension method ktlint thinks its unused
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