8 Replies Last post: Oct 2, 2007 10:34 PM by Randall Schulz  
Randall Schulz Apprentice 1,018 posts since
Nov 17, 2006
Currently Being Moderated

Oct 2, 2007 12:15 AM

"Method '...' is too complex to analyze by data flow algorithm"

Hi,

 

I just noticed this warning, signaled by a wavy grey underscore on the name of the method in question. The extended description reads:

 

"This inspection reports those conditions in the specified inspection scope that are always true or false, as well as points out where a RuntimeException may be thrown, based on data flow analysis of the code."

 

The method in question is not particularly complex:

 


public
void
format(PrintStream stream, String format)
{
    int                                     nFmtChars                       = format.length();
    boolean                                 percent                         = false;
    boolean                                 backslash                       = false;

    for (int iFmtChar = 0; iFmtChar < nFmtChars; iFmtChar++) {
        char                                fmtChar                         = format.charAt(iFmtChar);

        if (backslash) {
            stream.print(fmtChar);
            backslash = false;
        }

        else
        if (percent) {
            switch (fmtChar) {
            case '%':
                stream.print('%');
                break;

            case 's':
                stream.print(fSeverity.leftName);
                break;

            case 'M':
                stream.print(fMajor != null ? fMajor : "?");
                break;

            case 'm':
                stream.print(fMinor != null ? fMinor : "?");
                break;

            case 'v':
                stream.print(fVariant != null ? fVariant : "?");
                break;

            case 'f':
                printMessage(stream);
                break;

            case 't':
                printThrownMessage(stream);
                break;

            case 'S':
                printStackTrace(stream);
                break;

            case 'n':
                stream.println();
            }

            percent = false;
        }

        else
        if (fmtChar == '\\')
            backslash = true;

        else
        if (fmtChar == '%')
            percent = true;

        else
            stream.print(fmtChar);
    }

 

So what's the deal with this? Which inspection is creating it? What's too complex about that code?

 

I'm running EA 7312 under 1.6.0_02 on Linux.

 

Randal Schulz

Guest
Currently Being Moderated
Oct 2, 2007 12:29 AM in response to: Randall Schulz
Re: "Method '...' is too complex to analyze by data flow algorithm"

Hello Randall,

 

I just noticed this warning, signaled by a wavy grey underscore on the

name of the method in question. The extended description reads:

 

"This inspection reports those conditions in the specified inspection

scope that are always true or false, as well as points

out where a RuntimeException may be thrown, based on data flow

analysis of the code."

 

So what's the deal with this? Which inspection is creating it?

 

As you can see from the description, the "Constant Conditions and Exceptions"

inspection is creating it. Note that the only thing new for this is the warning

itself: previously such methods were silently ignored, and you got no null

pointer highlighting etc. in such methods.

 

What's

too complex about that code?

 

I don't know the exact rules for detecting too complex methods - Max Shafirov

will probably answer this part.

 

--

Dmitry Jemerov

Software Developer

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

 

 

 

k  Novice 125 posts since
Aug 22, 2002
Currently Being Moderated
Oct 2, 2007 5:39 PM in response to: Dmitry Jemerov
Re: "Method '...' is too complex to analyze by data flow algorithm"

Is there any way to disable the "too complex" portion of the inspection but still keep the inspection enabled for not-too complex methods?

Guest
Currently Being Moderated
Oct 2, 2007 5:45 PM in response to: k
Re: "Method '...' is too complex to analyze by data flow algorithm"

Hello k,

 

Is there any way to disable the "too complex" portion of the

inspection but still keep the inspection enabled for not-too complex

methods?

 

No, the highlighting of code which is too complex to analyze can't be separately

disabled.

 

--

Dmitry Jemerov

Software Developer

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

 

 

 

k  Novice 125 posts since
Aug 22, 2002
Currently Being Moderated
Oct 2, 2007 9:05 PM in response to: Dmitry Jemerov
Re: "Method '...' is too complex to analyze by data flow algorithm"

i'm still trying to figure this out...

 

a) is the "too complex" supposed to be a warning that the code actually is too complex and should be refactored?

 

or

 

b) is the "too complex" just information that the analyzer is not up to task to analyze the particular method?

 

 

if the answer is (a) then there are some pretty simple methods it can't analyze.   if the answer is (b) then why is this highlighting as yellow warning instead of just info

 

I try to keep my files "green" but this particular inspection has turned many of them yellow.  I want to keep the inspection on but if a method is too complex for it I don't want my entire file marked yellow because of it.

Guest
Currently Being Moderated
Oct 2, 2007 9:15 PM in response to: k
Re: "Method '...' is too complex to analyze by data flow algorithm"

Hello k,

 

i'm still trying to figure this out...

 

a) is the "too complex" supposed to be a warning that the code

actually is too complex and should be refactored?

 

or

 

b) is the "too complex" just information that the analyzer is not up

to task to analyze the particular method?

 

if the answer is (a) then there are some pretty simple methods it

can't analyze.   if the answer is (b) then why is this highlighting as

yellow warning instead of just info

 

The answer is (b), and the "too complex" highlighting is shown with INFO

severity.

 

--

Dmitry Jemerov

Software Developer

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

 

 

 

Gordon Tyler Apprentice 797 posts since
Aug 20, 2002
Currently Being Moderated
Oct 2, 2007 1:00 AM in response to: Randall Schulz
Re: "Method '...' is too complex to analyze by data flow algorithm"

Yeah I noticed this as well for a few of my methods. Seems like a few nesting levels (sometimes unavoidable) may be triggering it.

More Like This

  • Retrieving data ...