yu.pitomets
yu.pitomets

Reputation: 1840

IntelliJ-Idea disable inspection: Actual value of parameter is always

Is there a way to disable this inspection? I know, this maybe be a bad design, but I still would like to disable it.

Upvotes: 27

Views: 4952

Answers (4)

xdavidliu
xdavidliu

Reputation: 3043

For me, the inspection text is

Value of parameter 'x' is always '"foo"'

One way to hide that (in IDEA 2024.3.1.1 UE) is to right-click the /!\ icon in the upper-right then "Configure inspections", then under "Declaration redundancy", uncheck "Method parameter always has the same value".

edit: I believe that does it for the current project. I noticed the next time I created a new project, the warning came back, so I exited the project, then in the main "splash screen", went into settings and searched for "Method parameter always" and unchecked it there again. That makes this setting stick for all new projects.

Upvotes: 0

Syed Rafaqat Hussain
Syed Rafaqat Hussain

Reputation: 1126

Use @SuppressWarnings("SameParameterValue") in java

and @Suppress("SameParameterValue") in kotlin

Tested on Android Studio Arctic Fox | 2020.3.1

Upvotes: 8

pintergabor
pintergabor

Reputation: 577

@SuppressWarnings("SameParameterValue")

I tested it in Android Studio 3.5, which is based on IntelliJ-Idea, so it probably works in other IntelliJ-Idea based IDEs too.

Upvotes: 23

Mureinik
Mureinik

Reputation: 310983

Find an instance of the inspection, and hit ALT+ENTER to open the content menu. You'll see a suggestion there that looks like "Inline value 'XYZ' for parameter 'myParameter'". Click the right arrow next to it to open a second context menu, and there you'll find options to edit the inspection setting in order to tune the conditions that will produce it, suppress it for the method/class/parameter, or even disable it altogether.

Upvotes: 23

Related Questions