[Codenarc-developer] ClosureAsLastMethodParameterRule - bug with double slashes; simplified?
Brought to you by:
chrismair
From: Chris M. <chr...@ea...> - 2011-06-03 02:12:19
|
Hamlet, When running the CodeNarc 0.14 snapshot against a project at work, I ran across a bug in ClosureAsLastMethodParameterRule, where it would give a false-positive violation if the closure parameter contained a string containing "//". Here is the test case I added, that initially failed with three violations: void testLinesWithStringsContainingDoubleSlash() { final SOURCE = ''' void testProcess() { shouldFail { process('xxx://wrsnetdev.usa.wachovia.net') } shouldFail(Exception) { process('http://') } shouldFail { process('http://wrsnetdev.usa.wachovia.net:xxx') } } ''' assertNoViolations(SOURCE) } I stripped out the logic in that rule that checked for comments in the source, and just base the check on the lastColumnNumber of the closure parm versus the whole method. It may be too simplistic, but it passes all of the tests, including my new test. If you get a chance, could you please take a look. If I am missing some "requirement", then we obviously need more/better tests. Chris |