-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a means to resolve analysis bugs in included libraries #65
Comments
Hi @Scharrels,
This could stand to be more discoverable - but DelphiLint actually does quite a bit of logging (the equivalent of a If you're able to share those logs with me (or relevant portions), I'd be happy to see what insights there are to be had. |
There's not much information there, unfortunately. Here's a couple of relevant parts:
Note: This library only provides a compiled version for the missing GisBaseObject (this object handles the licensing). |
Hi @Scharrels, |
Unfortunately there won't be a more detailed stack trace. The
I will have another look at whether we can eke more information out of the IoC because it definitely isn't ideal to have a crash, then have no idea what happened to it. We could maybe add some log redirecting support to SonarDelphi?
Hmm, I'm not sure if that would be possible on an architectural level - if you are scanning a unit that indirectly depends on a source file, SonarDelphi will index it. I think the biggest problem here is that at the moment DelphiLint treats any error from SonarDelphi as fatal, which is a little dramatic. SonarDelphi will happily complete a scan even if it fails to parse certain files - that could be why a standalone scan is succeeding. Fixing this in DelphiLint would require a bit of a different approach to error management - interested to hear if anyone has any novel ideas to detect a failure. This is the information we get from the
Perhaps an analysis only counts as a failure if no issues are produced? |
Also - @Scharrels, can you confirm whether the logs for the successful standalone scan shows a non-fatal error on the same file? That should contain a full stack trace and might give an important clue to fix the actual error. |
I can confirm that a non-fatal error is shown in the stack trace of the standalone scan. The error is:
The interesting part here is that this particular part of the file is guarded by compiler directives and should have been skipped. I can't share this source file, but the following snippet should give you an idea of the code:
It seems that Sonar is enabling both the
This doesn't seem to help (it almost looks like these conditional undefines are ignored in the library path), so I'm running out of ideas here. |
Hi @Scharrels, SonarDelphi doesn't seem to be enabling the compiler directives on a project level - in the original logs you sent, neither If they are enabled, then they must be enabled from SonarDelphi encountering a You can test if the problem is actually these directives being defined by editing the file to add something like this at the top:
If, when scanned again, SonarDelphi crashes at that point instead, we know it's because Is there anything else in the file that seems unusual or niche that could be causing the error? Parsing exceptions can sometimes be a little inaccurate with the exact location that the unexpected code is at.
Currently working on a change to SonarDelphi error handling in DelphiLint that will note when errors occur during analysis and provide a little window for you to browse them, but won't fail the scan. I think this will be a good QoL change and will mean that you and your team will be able to start using DelphiLint again. |
The behaviour that I see here is rather strange. I have modified the source file in the following manner (note: this example is simplified):
What I see here is that the error is still emitted on the following line:
This is behaviour that I didn't expect. The ifdef checks for the |
I did a bit more analysis. I can trigger this exception with the following minimized file, included as a library:
I am unable to trigger it if I analyze the following unit directly (if I define it within my project):
The difference here is the unit name and the fact that one of these is part of the library and the other one is included directly. |
I reduced the problem to a more minimal example unit Bad;
interface
{$IF False}
// inside the not-taken branch
type
Foo = {$IF False} asdf {$ENDIF} class end;
// ^ anything invalid
// 'implementation' must be inside the conditional branch
implementation
{$ELSE}
implementation
{$ENDIF}
end. The above unit needs to be included into a file that is being analysed, without itself being part of the analysis. I think this has something to do with SonarDelphi's partial indexing it does for interface sections. debug.zip can be used with either DelphiLint or a full sonar-scanner to reproduce the issue. |
Thanks both @Scharrels and @zaneduffield, that's extremely helpful. I've raised integrated-application-development/sonar-delphi#299 to track this SonarDelphi bug - discussion can continue there if needed but I think with such a simple minimal case we should be OK. I will keep this issue open to track the work I'm doing improving the DelphiLint experience when SonarDelphi reports errors. |
I've already identified the problem in SonarDelphi and will get the bug resolved for the November release. @Scharrels, if you're interested in a stopgap measure and have the appetite for a minor patch to your 3rdParty library code, then you can simply move the So for example, this: {$IF ABC}
// ...
implementation
{$ELSE}
// ...
implementation
{$ENDIF} Would become this: {$IF ABC}
// ...
{$ELSE}
// ...
{$ENDIF}
implementation |
I'm glad that the bug has been identified. Thank you all for the time invested in this bug, and in this project in general :) |
@Scharrels, the change stopping DelphiLint from falling over on non-fatal errors has been merged in #67. If you'd like the changes you can build a new version from latest master or wait until the next release (which will be soon). |
Prerequisites
Engine area
Delphi analysis
Improvement description
SonarDelphi 1.8.0 included the following change:
This change caused DelphiLint to analyze a lot more included libraries in our projects (which is a good thing, by the way).
Unfortunately, SonarDelphi crashes on one of these files, giving the following error:
In this case, I am unable to share the source code for this error, as the license for this library does not allow us to share source code. Normally, I would start my analysis of such problems with a sonar runner, enabling the -x flag to maximize debug information. In this case, a standalone Sonar runner does not show the same problem.
Our entire team is currently unable to use DelphiLint, so I still want to resolve this. Could you enhance DelphiLint to either:
Rationale
See other section
The text was updated successfully, but these errors were encountered: