1

I recently came across this stackoverflow post (Why isn't calling a static method by way of an instance an error for the Java compiler?) and it got me thinking - is it possible to configure IntelliJ to manually to throw errors / refuse to build if something like this occurs in code.

IntelliJ already detects such occurrences, but what I'm after is to have it refuse to build and throw errors when it detects something like so:

enter image description here

Vy Do
  • 46,709
  • 59
  • 215
  • 313
Andorrax
  • 33
  • 4
  • Currently it's not possible to stop build on inspection results. Feel free to create feature request on YouTrack: https://youtrack.jetbrains.com/issues/IDEA – y.bedrov Aug 15 '22 at 12:11
  • 2
    There are libraries out there (e.g. [error-prone](https://github.com/google/error-prone)) which will cause similar compile-time errors for you on purpose. This includes their check for [StaticQualifiedUsingExpression](https://errorprone.info/bugpattern/StaticQualifiedUsingExpression) – Rogue Aug 15 '22 at 15:11
  • If you're using a build tool like Maven, there might also be code quality plugins you can use to make the build fail. But that is only partially relevant for your question, as the build in IDEA would still succeed. – slindenau Aug 16 '22 at 08:02

0 Answers0