False negative on "Avoid unused private methods"
A source code analyzer
Brought to you by:
adangel,
juansotuyo
I get the "Avoid unused private methods" error on the two following code pieces:
(1)
@ContextConfiguration(classes = CucumberConfig.class)
public final class FlightSearchStepDefs {
private FlightSearchPage flightSearchPage;
private FlightResultPage flightResultPage;
@Then("^I see resultpage banners for positions \"([^\"]*)\"$")
public void I_see_resultpage_banners_for_positions(String bannerPositions) {
checkBannerPositions(bannerPositions, flightResultPage);
}
@Then("^I see searchpage banners for positions \"([^\"]*)\"$")
public void I_see_searchpage_banners_for_positions(String bannerPositions) {
checkBannerPositions(bannerPositions, flightSearchPage);
}
private void checkBannerPositions(String bannerPositions, Page page) { <-- error here
//stuff
}
}
I can work around it by casting flightSearchPage and flightResultPage to Page.
(2)
public final class SharedWebDrivers {
private SharedWebDriver desktopDriver;
private SharedWebDriver tabletDriver;
public void preparedTabletDriver() {
resize(tabletDriver, TABLET_WIDTH, TABLET_HEIGHT);
}
public void preparedDesktopDriver() {
resize(desktopDriver, DESKTOP_WIDTH, DESKTOP_HEIGHT);
}
private static void resize(WebDriver webDriver, int width, int height) { <-- error here
//stuff
}
}
I can work around this by changing the resize signature to use SharedWebDriver instead.
I can't reproduce it with version 5.2.2 (see attached zip file).
Do you use plain PMD or do you use PMD through ant/maven/gradle/IDE?
Last edit: Andreas Dangel 2014-12-15
I get even more of these after upgrading to 5.2.3. I use PMD through gradle.
Hi, do you get the false positives also with the attached example (bug-1292.zip)? Could you please try this - and if you don't get false positives, could you provide me a better example please?
Many thanks!