Delphi-PRAXiS
Seite 5 von 7   « Erste     345 67      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Klatsch und Tratsch (https://www.delphipraxis.net/34-klatsch-und-tratsch/)
-   -   Neuer FixInsight ist da! (https://www.delphipraxis.net/183874-neuer-fixinsight-ist-da.html)

Der schöne Günther 26. Mär 2015 10:20

AW: Neuer FixInsight ist da!
 
Thank you for your reply.

Regarding excluding code from being checked, you mean like this?
Take this:
Delphi-Quellcode:
unit SomeUnit;

interface

type
   TParent = class
      procedure someVirtualMethod(); virtual;
   end;

   TChild = class(TParent)
      procedure someVirtualMethod(); override;
   end;

implementation

{ TParent }

procedure TParent.someVirtualMethod();
begin
   WriteLn('Quack!');
end;

{ TChild }

{$IFNDEF _FIXINSIGHT_}
procedure TChild.someVirtualMethod();
begin
   // No quack at all
end;
{$ENDIF _FIXINSIGHT_}

end.
Do you think it would also be possible to further specify which warning or convention to ignore? In this case, I'd only like to ignore a W519 but lose all the other cool warnings and conventions as well.

Stevie 26. Mär 2015 11:36

AW: Neuer FixInsight ist da!
 
Zitat:

Zitat von Der schöne Günther (Beitrag 1294880)
Do you think it would also be possible to further specify which warning or convention to ignore? In this case, I'd only like to ignore a W519 but lose all the other cool warnings and conventions as well.

Given how DelphiAST works I think that is not so trivial. The trick with the $IFNDEF just works because it ignores that part of code because the define is set by FixInsight.
For using the same technique it would require multiple parses for each rule or including ifdefs into the AST which currently is not the case.

A different approach could be like rule suppressions in StyleCop work.
But using attributes for such purpose will lead to W1025 when compiling that code unless you add a unit with dummy attributes.

Edit: Ok, maybe a combination of both could work... something like this:

Delphi-Quellcode:
{$IFDEF _FIXINSIGHT_}[SuppressRule(W519)]{$ENDIF}
procedure TChild.someVirtualMethod();
begin
   // No quack at all
end;

Uwe Raabe 26. Mär 2015 12:36

AW: Neuer FixInsight ist da!
 
Zitat:

Zitat von Stevie (Beitrag 1294903)
Delphi-Quellcode:
{$IFDEF _FIXINSIGHT_}[SuppressRule(W519)]{$ENDIF}
procedure TChild.someVirtualMethod();
begin
   // No quack at all
end;

How long is this "SuppressRule" valid: Only for the following method or for the rest of the unit?

We have a similar problem when dealing with string constants and localization tools automagically extracting those from the sources. It is quite common for these tools to accept a special formatted comment to ignore such a constant. If you scan the Delphi source you will find lots of comments like
Delphi-Quellcode:
{ Do not localize }
which are valid for the current line. Perhaps we can have a similar approach for FixInsight warnings.

Delphi-Quellcode:
procedure TChild.someVirtualMethod(); { FIXINSIGHT: SuppressRule(W519) }
begin
   // No quack at all
end;
As the comment lies inside the method implementation the scope should be obvious. Depending on the nature of any rule other intrinsic scopes may be appropriate.

Stevie 26. Mär 2015 12:42

AW: Neuer FixInsight ist da!
 
Zitat:

Zitat von Uwe Raabe (Beitrag 1294916)
How long is this "SuppressRule" valid: Only for the following method or for the rest of the unit?

For exactly the element it was put on. In this case for the entire method. Personally I would not make it too fine grained.
In the end we want to find bad code and not put suppress rule directives all over the place, right?

Zitat:

Zitat von Uwe Raabe (Beitrag 1294916)
We have a similar problem when dealing with string constants and localization tools automagically extracting those from the sources. It is quite common for these tools to accept a special formatted comment to ignore such a constant. If you scan the Delphi source you will find lots of comments like
Delphi-Quellcode:
{ Do not localize }
which are valid for the current line. Perhaps we can have a similar approach for FixInsight warnings.

...

As the comment lies inside the method implementation the scope should be obvious. Depending on the nature of any rule other intrinsic scopes may be appropriate.

As I said, the current implementation of DelphiAST limits the possibilities. Comments won't work either since they are not part of the generated AST (afaik).
To my knowledge FI works on the generated AST. Anything that is not part of that AST cannot be taken into consideration.

Roman Yankovsky 26. Mär 2015 13:22

AW: Neuer FixInsight ist da!
 
Zitat:

Zitat von Der schöne Günther (Beitrag 1294880)
Regarding excluding code from being checked, you mean like this?
Take this:

Yes, exactly like this.

Regarding your second question about ignoring only a specific warning Stefan is right, it's not a trivial task. I'm thinking about implementing this though.

Zitat:

Zitat von Stevie (Beitrag 1294903)
Zitat:

Zitat von Der schöne Günther (Beitrag 1294880)
Do you think it would also be possible to further specify which warning or convention to ignore? In this case, I'd only like to ignore a W519 but lose all the other cool warnings and conventions as well.

Given how DelphiAST works I think that is not so trivial. The trick with the $IFNDEF just works because it ignores that part of code because the define is set by FixInsight.
For using the same technique it would require multiple parses for each rule or including ifdefs into the AST which currently is not the case.

I was thinking about something like this:
Delphi-Quellcode:
{$FIOFF W509}
procedure Method;
begin

end;
{$FION W509}
It's still not trivial, but I think I can handle this directives in DelphiAST by adding a certan attribute to all syntax nodes between $FIOFF and $FION. Not in DelphiAST itself of course, but it is possible to inherit it and override a few methods. And as you have mentioned above, attributes is another option.

Der schöne Günther 26. Mär 2015 17:51

AW: Neuer FixInsight ist da!
 
I don't know about this DelphiAST, but what about the other way around? Just parse as you always do. We now have a list of warnings and the line number it occurred on.

So in case the code goes like this
Delphi-Quellcode:
25:   procedure TChild.someVirtualMethod();
26:   begin
27:       // No quack at all
28:   end;
, there is a W519 raised for line 25. Now before outputting our results to the IDE's listbox, let's check line 25 whether it contains a comment with an exclamation mark followed by "W519".

So if the code is like
Delphi-Quellcode:
25:   procedure TChild.someVirtualMethod(); //!W519 because FixInsight is smart
26:   begin
27:       // No quack at all
28:   end;
, there will be no "false positive".

Roman Yankovsky 26. Mär 2015 21:29

AW: Neuer FixInsight ist da!
 
Nice idea :)

jaenicke 27. Mär 2015 05:20

AW: Neuer FixInsight ist da!
 
This could even be expanded to the whole unit scope (for example for 3rd party units, where only the first line would have to be modified then):
Delphi-Quellcode:
unit Example; //!W519 (cannot be fixed because of...)
...

freimatz 27. Mär 2015 16:04

AW: Neuer FixInsight ist da!
 
Zitat:

Zitat von Roman Yankovsky (Beitrag 1294694)
Zitat:

Zitat von freimatz (Beitrag 1294603)
Hallo,
habe heute mal die Demo installiert. Bei Aufruf mit einem meiner Projekte kommt ein EStringListError in Classes.TFileIterator.Next. (nach madExcept) Eine Ausgabe kommt dann bei continue trotzdem. Umständlich ist, dass mich die meisten units des Projektes gar nicht insteressieren.
Bei Aufruf von Kommandozeile geht gar nichts. D.h. FixInsightCL nacht eine kleine Pause und beendet dann. Zumindest bei --output und --xml hätte ich eine leere xml erwartet.

The EStringListError is fixed today.
Please download the latest build http://sourceoddity.com/download/Fix...upd1_setup.exe

Unfortunately, I cannot reproduce the issue ...

Nach Installation der neuen Version ist alles gut :-D

schöni 27. Mär 2015 20:36

AW: Neuer FixInsight ist da!
 
Ab welcher Delphi Version kann man das einsetzen?

Ab welcher Windows Version funktioniert das Tool?

@freimatz: Ist das gefixte Tool im Link die Demo- oder die Vollversion?


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:46 Uhr.
Seite 5 von 7   « Erste     345 67      

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz