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

KTLint formatting adding debug text to file #4132

Closed
MorrisonWill opened this issue Apr 1, 2022 · 4 comments
Closed

KTLint formatting adding debug text to file #4132

MorrisonWill opened this issue Apr 1, 2022 · 4 comments
Labels

Comments

@MorrisonWill
Copy link

MorrisonWill commented Apr 1, 2022

Information

NVIM v0.6.1
Build type: Release

Arch Linux x86_64

What went wrong

After setting up ktlint using kotlin = { "ktlint" }, in my neovim config and saving a file, the file formats correctly but the ktlint debug information is added on both sides of the file. Here is an example from Gradle's default hello world after removing a tab and then saving with the format on save option enabled:

`00:46:02.120 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "baseline" id.
00:46:02.122 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "checkstyle" id.
00:46:02.123 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "json" id.
00:46:02.123 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "html" id.
00:46:02.123 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "plain" id.
00:46:02.123 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "sarif" id.
00:46:02.123 [main] DEBUG com.pinterest.ktlint.Main - Initializing "plain" reporter with {verbose=false, color=false, color_name=DARK_GRAY}
/*

  • This Kotlin source file was generated by the Gradle 'init' task.
    */
    package hello_world

class App {

val greeting: String
    get() {
        return "Hello World!"
    }

}

fun main() {
println(App().greeting)
}
00:46:03.083 [main] DEBUG com.pinterest.ktlint.Main - 1248ms / 1 file(s) / 0 error(s)`

Reproducing the bug

  1. Install neovim
  2. Set up ale with ktlint enabled for kotlin formatting and format on save
  3. Generate Gradle hello world project
  4. Save App.kt

:ALEInfo

let g:ale_loclist_msg_format = v:null let g:ale_max_buffer_history_size = v:null let g:ale_max_signs = v:null let g:ale_maximum_file_size = v:null let g:ale_open_list = v:null let g:ale_pattern_options = v:null let g:ale_pattern_options_enabled = v:null let g:ale_root = {} let g:ale_set_balloons = 0 let g:ale_set_highlights = 1 let g:ale_set_loclist = 1 let g:ale_set_quickfix = 0 let g:ale_set_signs = 1 let g:ale_sign_column_always = v:null let g:ale_sign_error = v:null let g:ale_sign_info = v:null let g:ale_sign_offset = v:null let g:ale_sign_style_error = v:null let g:ale_sign_style_warning = v:null let g:ale_sign_warning = v:null let g:ale_sign_highlight_linenrs = v:null let g:ale_statusline_format = v:null let g:ale_type_map = v:null let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 0 let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1

@hsanson
Copy link
Contributor

hsanson commented Apr 3, 2022

I use ktlint with ALE for work and I have never seen this behavior. I just tested on my machine and the fixer works as expected. Can you verify if you have some ktlint configuration that causes it to output debug information?

I am using latest ALE from master, neovim 0.7.0-dev, and ktlint 0.42.1.

@MorrisonWill
Copy link
Author

I don't have any ktlint configuration and other ALE fixers are working properly. I tried a few different ktlint versions as well and updated ALE. Same result each time.

@hsanson
Copy link
Contributor

hsanson commented Apr 5, 2022

Seems there was a bug that caused ktlint to output debug info even if --debug flag was not used: pinterest/ktlint#1412

If you still see this behavior and are sure the --debug flag is not being passed to ktlint then is a regression on Ktlint side. I recommend to report this problem at Ktlint repository.

@hsanson
Copy link
Contributor

hsanson commented Dec 10, 2022

Does not seem to be ALE issue. Ktlint works fine on my own projects.

@hsanson hsanson closed this as completed Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants