This is a further enhancement for [feature-requests:#312]. As we already have the database of methods without side effects (see [feature-requests:#318]) it would be simpler and better to use it for this pattern: duplicate call to method without side effect is very unlikely to be intended.
Several new bugs found after this change is implemented:
// org.eclipse.equinox.spi.p2.publisher.PublisherHelper public static Version fromOSGiVersion(org.osgi.framework.Version version) { if (version == null) return null; if (version.getMajor() == Integer.MAX_VALUE && version.getMicro() == Integer.MAX_VALUE && // <<<< version.getMicro() == Integer.MAX_VALUE) return Version.MAX_VERSION; return Version.createOSGi(version.getMajor(), version.getMinor(), version.getMicro(), version.getQualifier()); }
version.getMicro() is compared two times. Seems that version.getMinor() was intended.
// org.eclipse.osgi.internal.loader.BundleLoaderSources boolean forceSourceCreation(ModuleCapability packageCapability) { Map<String, String> directives = packageCapability.getDirectives(); return directives.get(PackageNamespace.CAPABILITY_EXCLUDE_DIRECTIVE) != null || directives.get(PackageNamespace.CAPABILITY_EXCLUDE_DIRECTIVE) != null; }
The same element is fetched from the same map twice. Seems that CAPABILITY_INCLUDE_DIRECTIVE was intended.
// org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration for (BugzillaFlag bugzillaFlag : flags) { if (nameValue.equals(bugzillaFlag.getName())) { if (nameValue.equals(bugzillaFlag.getName())) { ... } } }
Not sure what was intended, but clearly a bug.
False-positives are very unlikely, but I'll test a few more projects before committing the changes.
Done.
https://code.google.com/p/findbugs/source/detail?r=cf05dd8a9e7b53b905dca872547e16e960998afa