sonar-delphi icon indicating copy to clipboard operation
sonar-delphi copied to clipboard

XX is not a valid line for pointer

Open jbabijczuk opened this issue 9 years ago • 2 comments

There is a problem with nested functions.

Scenario

  • two nested functions with the same name in different units.
  • one of this function is located further than end of file with second function
  • functions has problem with Complexity Results: XX is not a valid line for pointer

Example in attached file.

I added this code

if ((activeFunction != null) && (activeFunction.getUnit() != results.getActiveUnit()))
        activeFunction = null;

in method FunctionInterface createFunction(CodeAnalysisResults results, ClassInterface currentClass)

It solved this problem but it is not a good solution :(

. Desktop.zip

jbabijczuk avatar Feb 17 '16 17:02 jbabijczuk

Better solution:

private FunctionInterface getCachedFunction(CodeAnalysisResults results)
  {
      FunctionInterface activeFunction = results.getCachedFunction(functionName);
      if (activeFunction == null)
          return null;
      if (activeFunction.getUnit() != results.getActiveUnit())
          return null;
      if ((results.getParseStatus() == LexerMetrics.IMPLEMENTATION) && (!activeFunction.isDeclaration()))
          return null;
      return activeFunction;
  }

  private FunctionInterface createFunction(CodeAnalysisResults results, ClassInterface currentClass) 
  {
    FunctionInterface activeFunction = getCachedFunction(results);

    if (activeFunction == null)

jbabijczuk avatar Feb 17 '16 20:02 jbabijczuk

@jbabijczuk thanks for the fix, I think it worked, but I found another annoying bug!

panga avatar Mar 14 '16 13:03 panga