question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lots of warnings during compliation of JTE generated Kotlin code

See original GitHub issue

After we have swithed to generate() in the build.gradle.kts (see our another issue #177), we are getting lots of Kotlin compiler warnings which we have never had before.

Below is list of warnings that we’ve faced:

// Unchecked cast: Any? to Response<ServiceResponse>
// many similar ones for different parameter names and types
// these all are our custom parameters which we pass into a KTE page, by declaring them like
// @param keyHistoryDetailsResponse: Response<KeyHistoryDetailsResponse>
    val fesServiceResponse = params["fesServiceResponse"] as Response<com.flowcrypt.eap.clients.fes.ServiceResponse>

// Parameter 'params' is never used
	@JvmStatic fun renderMap(jteOutput:gg.jte.html.HtmlTemplateOutput, jteHtmlInterceptor:gg.jte.html.HtmlInterceptor?, params:Map<String, Any?>) {
		render(jteOutput, jteHtmlInterceptor);
	}

// Parameter 'jteHtmlInterceptor' is never used
	@JvmStatic fun render(jteOutput:gg.jte.html.HtmlTemplateOutput, jteHtmlInterceptor:gg.jte.html.HtmlInterceptor?) {
		jteOutput.writeContent("....")
        }

// 'capitalize(): String' is deprecated. Use replaceFirstChar instead
       jteOutput.writeUserContent(provider.capitalize())

I suggest to add proper @Suppress(...) statements into the generated code. In the last case I’d suggest to use recommended method instead of deprecated one. On my end, I’m looking into how to disable such warnings for certain paths (generated code) in the project but no luck so far.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
IvanPizhenkocommented, Oct 7, 2022

Can you please also add in the beginning of each generated file following line:

@file:Suppress("ktlint")

I may later provide more fine-grained list of ktlint rules to disable, but for now suppressing all of them will be good enough.

1reaction
IvanPizhenkocommented, Oct 7, 2022

Thanks, found provider.capitalize() in my code, will fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fail your build on Kotlin warnings | by Maxi Rosson - Dipien
Kotlin warnings are very useful for developers. They help to clean up the code and even fix potential bugs. This is how they...
Read more >
Generated Kotlin code triggers compile warnings #207 - GitHub
This makes using Kotlin code generation mode impossible when allWarningsAsErrors is enabled. See #205. This time it's because the generated ...
Read more >
Treating Warnings As Errors In Kotlin | by JAVING
some code that has unused parameters. command used to compile. warnings displayed in the console .jar file is created despite there are ...
Read more >
Kotlin warnings with gradle build - java - Stack Overflow
The warnings that you see are reported by the Kotlin compiler, not by Android Lint, so lintOptions won't affect them.
Read more >
How to supress OptIn warnings in Gradle and during Git ...
I'm using OptIn features quite liberally in my code base. Because of this, I get a lot of warnings of the following form...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found