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

Internal error no-unused-imports #996

Closed
paul-dingemans opened this issue Dec 6, 2020 · 1 comment · Fixed by #1026
Closed

Internal error no-unused-imports #996

paul-dingemans opened this issue Dec 6, 2020 · 1 comment · Fixed by #1026
Labels
Milestone

Comments

@paul-dingemans
Copy link
Collaborator

Observed Behavior

Running ktlint with parameter "-F" produces an internal error "no-unused-imports" on enclosed sample code. Running without parameter "-F" actually produces a helpful message.

Steps to Reproduce

Run "ktlint -F" on code below:

package com.example.ktlint.error

import mu.KLogging

class NoUnsedImportInternalErrorKtlint {

    fun getDrafts(val draftsIds: List<Long>) {
        logger.info { "Entering getDrafts: draftIds=[${draftsIds.toString()}]" }
    }

    private companion object : KLogging() {
    }
}

results in:
NoUnsedImportInternalErrorKtlint.kt:1:1: Internal Error (no-unused-imports). Please create a ticket at https://github.com/pinterest/ktlint/issues (if possible, provide the source code that triggered an error) (cannot be auto-corrected)

without parameter "-F", the result is:
NoUnsedImportInternalErrorKtlint.kt:8:65: Redundant "toString()" call in string template

After removing the redundant "toString" the problem is gone.

Your Environment

Ktlint version 0.39.0
MacOs

@Tapchicoma Tapchicoma added the bug label Dec 7, 2020
@Tapchicoma Tapchicoma added this to the 0.41.0 milestone Dec 7, 2020
@Tapchicoma
Copy link
Collaborator

Reproducible with ktlint 0.40.0

paul-dingemans pushed a commit to paul-dingemans/ktlint that referenced this issue Dec 20, 2020
…g is removed (pinterest#996)

The no-unused-imports rule fails on the existence of the dot-expression node but for which the actual call to the toString method was removed.
romtsn added a commit that referenced this issue Dec 21, 2020
…emoved (#1026)

* Fix string-template for dot-expression of which the redundant toString is removed (#996)

The no-unused-imports rule fails on the existence of the dot-expression node but for which the actual call to the toString method was removed.

* Update changelog

* Fix code style violation

Co-authored-by: Paul Dingemans <pdingemans@bol.com>
Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com>
romtsn added a commit to paul-dingemans/ktlint that referenced this issue Mar 7, 2021
…emoved (pinterest#1026)

* Fix string-template for dot-expression of which the redundant toString is removed (pinterest#996)

The no-unused-imports rule fails on the existence of the dot-expression node but for which the actual call to the toString method was removed.

* Update changelog

* Fix code style violation

Co-authored-by: Paul Dingemans <pdingemans@bol.com>
Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com>
mesopelagique pushed a commit to 4d/android-QMobileAPI that referenced this issue Mar 10, 2023
klint failed with wrong message pinterest/ktlint#996
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.

2 participants