sniff icon indicating copy to clipboard operation
sniff copied to clipboard

Ignore comments

Open fmpwizard opened this issue 13 years ago • 2 comments

Hi,

If a line is commented out, it is still marked as a code smell. It would be better if that did not happen (at least when commented with // , if detecting

/**
 *
/*

seems more involved.

fmpwizard avatar Feb 05 '12 07:02 fmpwizard

Yeah regex's are inherently limited, but I don't want to have to support real parsing because I think the value of sniff is in really simple smell expressions. Tools like PMD and FindBugs can look into the bytecode.

You could add // detection into your smell definitions, or as I would argue, you should delete commented code since you're not using it anyway.

One final note: perhaps you can use an Ignore clause to not flag the commented code. However Ignores only work at the file level (right now). Maybe we can add an annotation or magic token to mark a section as "ignored"?

arosien avatar Feb 05 '12 13:02 arosien

In this one case, the comment was to tell me that I removed a [Option].get call , but because I don't have enough tests on that area yet (they have to involve Selenium in my project), I left the comment tell me that if something goes wrong in a week, or a month, this may be a good place to look at :) I simply added a space between the dot and get and that took care of it :)

I never tried PMD but what I like about sniff is that I already use specs2, so it is an easy addition. Of course this project becomes very useful when you have larger teams, where you most likely have a hudson instance running tests for you, where you can add findbug. But it saved me some time, instead of running some grep shell script, I just write a new rule and let the test tell me files and line numbers where the problems are :)

Thanks

fmpwizard avatar Feb 05 '12 20:02 fmpwizard