Nicholas Wagner
Nicholas Wagner

Reputation: 83

Kotlin: suppress warning for function starting with uppercase letter

The Kotlin guide on coding conventions says factory functions may start with an uppercase letter,

Exception: factory functions used to create instances of classes can have the same name as the class being created:
    abstract class Foo { ... }

    class FooImpl : Foo { ... }

    fun Foo(): Foo { return FooImpl(...) }

The code inspector in android studio did not get the memo, however; it complains about the upcase letter. I realize I can go into settings and modify the rule, but (1) I don't want to make that global change, and (2) I don't want other people using my code to get the warning. I just wish to suppress the warning coming from this one line with a @Suppress directive (or some other way).

And I can't seem to find a list of all @Suppress directives -- where is it?

And where do I file a bug report for this?

Upvotes: 7

Views: 7294

Answers (2)

Kostya  Mistery
Kostya Mistery

Reputation: 444

This can happen if you have your Jetpack Compose plugin disabled. Just go to

File->Settings->Plugins and type Compose in Search Field.

Settings

Upvotes: 2

yole
yole

Reputation: 97133

To suppress any warning in Kotlin, press Alt-Enter, then the right arrow key and select the suppress action from the context menu, as shown on the attached screenshot.

Suppress quickfix

The issue for this problem has already been filed.

Upvotes: 15

Related Questions