terryyin / lizard

A simple code complexity analyser without caring about the C/C++ header files or Java imports, supports most of the popular languages.
Other
1.85k stars 250 forks source link

Lizard failing on char sequence #50

Closed MarkBlaas closed 9 years ago

MarkBlaas commented 10 years ago

Lizard fails to parse a file when (a form of) the following sequence is encounterd (in regex) [a-zA-Z]<.*>> So the following sequence is a failing sequence: a<>>

I encounterd the bug when trying to parse a java file with the following line of code: private static final Map<String, Map<Byte, String>> VAR_NAME = ImmutableMap.<String, Map<Byte, String>> builder() Although this is really ugly, it is valid java.

I worked around the problem by adding a space between ">>"

terryyin commented 10 years ago

Hi @MarkBlaas ,

But in your example code

private static final Map> VAR_NAME = ImmutableMap.> builder()

I didn't see the sequence like a<>>? Could you please give me a more complete example and/or help me understand what does it mean?

br, Terry

MarkBlaas commented 10 years ago

Correct, I forgot to put tags around the code, so some of it disapeared. The actual code is

private static final Map> PROPERTY_MAP = ImmutableMap . > builder()

MarkBlaas commented 10 years ago

Some of it is still disapearing… can't get the tags to work. And don't have the time to fix it.

private static final Map<String, Map<Byte, String>> PROPERTY_MAP = ImmutableMap .<String, Map<Byte, String> > builder()

Mark

On Sep 21, 2014, at 9:20 AM, Terry Yin notifications@github.com wrote:

Hi @MarkBlaas ,

But in your example code

private static final Map> VAR_NAME = ImmutableMap.> builder() I didn't see the sequence like a<>>? Could you please give me a more complete example and/or help me understand what does it mean?

br, Terry

— Reply to this email directly or view it on GitHub.

terryyin commented 9 years ago

Hi @MarkBlaas , I think the issue has been fixed by @rakhimov , do you mind to confirm?

rakhimov commented 9 years ago

The problem with C++ templates was triple '>>>'. The given Java example is parsed ok. I don't see any problems though I am not much experienced in Java.

@MarkBlaas, it would be helpful to get the whole file (on github?).

MarkBlaas commented 9 years ago

It has been a while :) good to see that it is still worked on. Unfortunately the file is part of some client code, so no can do there. But although i'm pretty busy this week, I'll probably manage to squeeze in some test time. I'll let you guys know what I find.

MarkBlaas commented 9 years ago

Hi Guys, it looks like it's fixed indeed. It is a while ago, but I think it was language unrelated, so it could very well be the triple >>> issue in C++ although my code was Java. I dug up some old analysis and compared the results. Here's a summary:

Sequence -- Old version --  New version
,A<A,A>>    Fails           Passes
,A<A,>>     Fails           Passes
,A<,>>      Fails           Passes
,<,>>       Passes          Passes
,A<>>       Fails           Passes
a<>>        Fails           Passes

Cheers :+1:

terryyin commented 9 years ago

great @MarkBlaas let's close this issue. Thanks!