Eliminate Duplicate Code function does not appear to work.
A bit new to intellij here so forgive me if it is a supid question.
anyway I was trying out the duplicate code feature and intellij did indeed find duplicate code, however the button to "Eliminate duplicate code" is grayed out in all instances.
2 examples that seem simple enough.
#1 I have the same method in 2 classes
private Date createDate(int year, int month, int date) {
GregorianCalendar calendar = new GregorianCalendar();
calendar.clear();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month-1);
calendar.set(Calendar.DAY_OF_MONTH, date);
return calendar.getTime();
}
I would expect that it would offer to do 1 of two things. combine it to 1 class or extract the mothod itself into a helper class. Although since it is grayed out I can do nothing.
And to make things worse if I manually extract the mothod to a class it doesn't go and change the other instance.
#2 Code duplication withing 1 method
session.enroll(janeDoe);
assertEquals(session.getNumberOfStudents(), 1);
assertEquals(1, session.getNumberOfStudents());
assertEquals(janeDoe, session.get(0));
session.enroll(joeBlow);
assertEquals(session.getNumberOfStudents(), 2);
assertEquals(2, session.getNumberOfStudents());
assertEquals(joeBlow, session.get(1));
it correctly identified I did the same thing twice but once again the eliminate duplicates button was grayed out.
Is this a bug or.... I have yet to see an instance where the button is not grayed out.
intellij 11.1.2
Thanks,
Mike
Please sign in to leave a comment.