Result of method call ignored
Reports method calls whose result is ignored.
For many methods, ignoring the result is perfectly legitimate, but for some it is almost certainly an error. Examples of methods where ignoring the result is likely an error include java.io.inputStream.read()
, which returns the number of bytes actually read, and any method on java.lang.String
or java.math.BigInteger
. These methods do not produce side-effects and thus pointless if their result is ignored.
The calls to the following methods are inspected:
Simple getters (which do nothing except return a field)
Methods specified in the settings of this inspection
Methods annotated with
org.jetbrains.annotations.Contract(pure=true)
Methods annotated with .*.
CheckReturnValue
Methods in a class or package annotated with
javax.annotation.CheckReturnValue
Optionally, all non-library methods
Calls to methods annotated with Error Prone's or AssertJ's @CanIgnoreReturnValue
annotation are not reported.
Use the inspection settings to specify the classes to check. Methods are matched by name or name pattern using Java regular expression syntax. For classes, use fully-qualified names. Each entry applies to both the class and all its inheritors.
Inspection options
Option | Type | Default |
---|---|---|
Table | None | |
Class Name | TableColumn | [java.io.File, java.io.InputStream, java.io.Reader, java.lang.AbstractStringBuilder, java.lang.Boolean, java.lang.Byte, java.lang.Character, java.lang.Double, java.lang.Float, java.lang.Integer, java.lang.Long, java.lang.Math, java.lang.Object, java.lang.Short, java.lang.StrictMath, java.lang.String, java.lang.Thread, java.math.BigDecimal, java.math.BigInteger, java.net.InetAddress, java.net.URI, java.nio.channels.AsynchronousChannelGroup, java.nio.channels.Channel, java.nio.channels.FileChannel, java.nio.channels.ScatteringByteChannel, java.nio.channels.SocketChannel, java.util.Arrays, java.util.Collections, java.util.List, java.util.Map, java.util.Set, java.util.UUID, java.util.concurrent.BlockingQueue, java.util.concurrent.CountDownLatch, java.util.concurrent.ExecutorService, java.util.concurrent.ForkJoinPool, java.util.concurrent.Semaphore, java.util.concurrent.locks.Condition, java.util.concurrent.locks.Lock, java.util.regex.Matcher, java.util.regex.Pattern, java.util.stream.BaseStream, java.util.stream.DoubleStream, java.util.stream.IntStream, java.util.stream.LongStream, java.util.stream.Stream] |
Method Name Regex | TableColumn | [.*, read|skip|available|markSupported, read|skip|ready|markSupported, capacity|codePointAt|codePointBefore|codePointCount|indexOf|lastIndexOf|offsetByCodePoints|substring|subSequence, .*, .*, .*, .*, .*, .*, .*, .*, equals|hashCode|toString, .*, .*, .*, interrupted, .*, .*, .*, .*, .*, isOpen, open|map|lock|tryLock|write, read, open|socket|isConnected|isConnectionPending, .*, (?!addAll).*, of, of|ofEntries|entry, of, .*, offer|remove, await|getCount, awaitTermination|isShutdown|isTerminated, awaitQuiescence, tryAcquire|availablePermits|isFair|hasQueuedThreads|getQueueLength|getQueuedThreads, await|awaitNanos|awaitUntil, tryLock|newCondition, pattern|toMatchResult|start|end|group|groupCount|matches|find|lookingAt|quoteReplacement|replaceAll|replaceFirst|regionStart|regionEnd|hasTransparentBounds|hasAnchoringBounds|hitEnd|requireEnd, .*, .*, .*, .*, .*, .*] |
Report all ignored non-library calls | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |