How do I change the way an inspection works in IntelliJ IDEA?(Scala plugin)

173 Views Asked by At

Picture says it all:

enter image description here

I want the squiggle to be under Int, rather than having it under an unintended type (Unit in the example)

How do I achieve this behavior?

2

There are 2 best solutions below

0
On

You have defined a function that returns Int but your implementation returns Unity, you can fix it by providing a default return value or null

def wha():Int = {
   0
}
0
On

You can't. All kinds of errors, warnings, problems, etc. for certain behavior are pre-setup and called inspections in IntelliJ. They are configured in "Inspections"(Preferences | Editor | Inspections) for all languages and frameworks separately. The only configuration available there is to enable/disable an inspection and change its severity level - you cannot change how they work.

UPDATE:
Apparently, recently Jetbrains introduced the feature to create custom inspections through Structural Search Inspection. You should be able to create custom inspection for Scala otherwise it's still not achievable.
And there is still no posibility to edit pre-existing inspections though as of version 2020.1