diktat
diktat copied to clipboard
Diktat adds a space line and delete it repeatedly
We noticed that diktat added a space line and delete it repeatedly when it detected [LONG_LINE], our code is like:
fun bindNetworkClientDataSource(): NetworkClient =
//diktat adds a space line and delete it here repeatedly
NetworkingClient {
// .......
headers = {
buildMap {
// ...
put("X-PX-AUTHORIZATION", "2:eyJ1IjoiNDA0Mjc2YjItMTljNi0xMWVkLWFlOTAtMDAwMDYzZDM1YzIzIiwidiI6ImYxZjFlY2Y4LTE5YmYtMTFlZC1hMjQzLTc4NDQ2ZDU2NDE3MyIsInQiOjE2NjAyNTc2ODE2NDUsImgiOiI0YjIyMTQwNjAxMGNkMzEwNGIyNDA0YjU2ZmQ5MmQ4MDVjZjZmZWVjYWJjNDQ0YWEzNjYxNzNiNWMxNjg4MmEzIn0=")
// ...
}
}
// ...
}
When diktatFix is executed, it detected a [LONG_LINE] issue on this line:
put("X-PX-AUTHORIZATION", "2:eyJ1IjoiNDA0Mjc2YjItMTljNi0xMWVkLWFlOTAtMDAwMDYzZDM1YzIzIiwidiI6ImYxZjFlY2Y4LTE5YmYtMTFlZC1hMjQzLTc4NDQ2ZDU2NDE3MyIsInQiOjE2NjAyNTc2ODE2NDUsImgiOiI0YjIyMTQwNjAxMGNkMzEwNGIyNDA0YjU2ZmQ5MmQ4MDVjZjZmZWVjYWJjNDQ0YWEzNjYxNzNiNWMxNjg4MmEzIn0=")
which is correct. But at the same time it added a space line to right after
fun bindNetworkClientDataSource(): NetworkClient =
— exactly the line of that comment "//diktat adds a space line and delete it here repeatedly" Then diktat was executed again, but that space line was removed. Because we are using CI/CD platform to run diktat check, whenever any code is changed, diktat will be triggered. Thus we would see endless changes, it added and deleted the space line repeatedly.
And if we just simply delete that [LONG_LINE] code, diktat would never add or delete any space line.
That seems to be a bug
Oh, thank you for your report, we will investigate it asap. As we think now - it is really a bug - we will investigate
@xiaoqian0408, thank you for your report.
I've checked your code, and it looks like only Diktat 1.1.0 and earlier has this problem. I was unable to reproduce the issue using any of the more recent versions (1.2.0 through 1.2.3). Could you please confirm you're using the latest released version?
If you still observe any problems with the latest release, please attach the code fragment that reproduces the issue rather than paste it inline as a code snippet. This will help preserve the original formatting.
@xiaoqian0408, I'm closing the issue for now.
Feel free to re-open once you have any further feedback.