Gendarme Tasks. Weekly Status Report #3

June 17, 2007

This is the status report for June 10 - June 17

Accomplished this week.

This week I have proposed 2 new rules. The first one is called "Don't swallow errors catching nonspecific exceptions". And the second is the first into the smells set, it's called "Detect code duplicated in methods that belongs to same class".

I'm working hard in this last rule.

Plans for the next week.

The next week, I would like finish this first smell rule. And purpose other rules too.

I have made a plan for finish this first smell.

I've identified 3 main scenarios:

  1. Code duplicated in the same class. This happens when you have 2 (or more) methods that have the same expression. You have to do a "Extract Method" and invoke the code from both places.
  2. Code duplicated in two sibling subclasses. Then you can remove the duplication extracting method and pulling it up. But there are other refactorings to apply here.
  3. Code duplicated in two unrelated classes. This scenario can be more difficult to identify. And I will study it later.

Challenges or problems.

I have a really interesting challenge, detect code duplication often isn't easy and there are a lot of stuff to do. Luckyly with the unit test you can see quickly if you get your goals.

By the moment, I'm writting this detector using a peephole. With this approach I can check the IL directly without build an AST and I can detect the smell in any language (VB, Nemerle ...)

Interesting resources.

This week, I have a really interesting resource: Code Nose Thesis. This project inspects Java code for detect some smells too. Thanks to Chris Gameweld for the link.

I want also thank all people that have written comments for the rules.

Discussion