How To Find Bugs, Part 3: @VisibleForTesting

Sometimes, doing things properly is hard. When that happens, there’s always @VisibleForTesting. To quote the Javadoc: @VisibleForTesting annotates a program element that exists, or is more widely visible than otherwise necessary, only for use in test code. There are occasions where @VisibleForTesting is the best solution, I suspect: I’m not entirely sure what they are. … More How To Find Bugs, Part 3: @VisibleForTesting

How To Find Bugs, Part 2: Well, this is somewhat confusing and frustrating

Last time we implemented a minimal detector, and I presented the code for the detector as a fait accompli. Let’s take a closer look at it.   import java.nio.file.Files; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.classfile.ClassDescriptor; import edu.umd.cs.findbugs.classfile.DescriptorFactory; import edu.umd.cs.findbugs.classfile.MethodDescriptor; public class FilesLinesDetector extends BytecodeScanningDetector { private static final ClassDescriptor JAVA_NIO_FILES = DescriptorFactory.createClassDescriptor(Files.class); final … More How To Find Bugs, Part 2: Well, this is somewhat confusing and frustrating

How To Find Bugs, Part 1: A Minimal Bug Detector

Findbugs is an incredibly powerful tool, and it supports running of custom detectors. However, the API for writing custom detectors is not well documented, at least as far as I’ve been able to find. So, as I started writing detectors, I’ve been working primarily off a process of trial and error. It’s likely there are … More How To Find Bugs, Part 1: A Minimal Bug Detector