erica / testlint

61 stars 5 forks source link

false positive on variable named temperature and Regex bug #4

Open rkam opened 8 years ago

rkam commented 8 years ago

Firstly, thanks for this. It's very helpful while I try to unlearn ingrained habits when writing swift!

I fixed the false positive by including word boundaries around the relevant triggers as follows:

        if ([RegexHelper testString:@"\\Btemp\\B" inString:line] ||
            [RegexHelper testString:@"\\Btmp\\B" inString:line] ||
            [RegexHelper testString:@"\\Bresults\\B" inString:line] ||
            [RegexHelper testString:@"\\BreturnValue\\B" inString:line])
        {

I'm not entirely sure about them around other than temp, since your intent may be to also prevent things like tmpfoo. - Speaking of which, you may want to add foo, bar, foobar to the list :)

Also, in your original code, you don't ignore case, so, e.g. Temp passes.

(Normally, I'd submit a change, but I have several other checks disabled and so have other changes to your code. Also, the above should be clear and trivial enough that it didn't seem to be necessary either).