AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Neuer FixInsight ist da!

Ein Thema von Insider2004 · begonnen am 10. Feb 2015 · letzter Beitrag vom 24. Apr 2016
Antwort Antwort
Der schöne Günther

Registriert seit: 6. Mär 2013
6.199 Beiträge
 
Delphi 10 Seattle Enterprise
 
#1

AW: Neuer FixInsight ist da!

  Alt 25. Mär 2015, 09:21
How can one surpress FixInsight warnings locally? I might, for example, leave an overridden virtual method empty on purpose. FixInsight is correctly raising a W519 here but the code is entirely valid and working as intended.


Oh, and while we're at it: There must be an option to exclude files. If you got some third party sources, gnugettext.pas for example, you're also going to get warnings on files you definitely don't want to modify.

I'm sure this is already on uservoice but I haven't bothered to check


One last thing: C104 ("Class name should start with 'T'") is true, but I suppose it doesn't apply to attributes.
Embarcaderos examples omit the "T".
Also, Marco Cantus new book states
Zitat:
So if you name your class SimpleAttribute you'll be able to use in the code an attribute called Simple or SimpleAttribute . For this is the reason the classic initial T for Object Pascal classes is generally not used in case of attributes.

Geändert von Der schöne Günther (25. Mär 2015 um 09:45 Uhr)
  Mit Zitat antworten Zitat
Roman Yankovsky

Registriert seit: 18. Feb 2015
 
#2

AW: Neuer FixInsight ist da!

  Alt 26. Mär 2015, 09:52
How can one surpress FixInsight warnings locally?
You may use _FIXINSIGHT_ compiler conditional. It works just like a real compiler directive.

For example,
Delphi-Quellcode:
{$IFNDEF _FIXINSIGHT_}
  ThisCodeWillBeIgnored(1,2,3);
{$ENDIF}
I have to add this to the documentation. I have never expected that so many people will need this functionality

There must be an option to exclude files. If you got some third party sources, gnugettext.pas for example, you're also going to get warnings on files you definitely don't want to modify.
Yes, this would be great. It's on my todo list.

One last thing: C104 ("Class name should start with 'T'") is true, but I suppose it doesn't apply to attributes.
Agree. I will fix this
  Mit Zitat antworten Zitat
Der schöne Günther

Registriert seit: 6. Mär 2013
6.199 Beiträge
 
Delphi 10 Seattle Enterprise
 
#3

AW: Neuer FixInsight ist da!

  Alt 26. Mär 2015, 10:20
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.
  Mit Zitat antworten Zitat
Benutzerbild von Stevie
Stevie

Registriert seit: 12. Aug 2003
Ort: Soest
4.045 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#4

AW: Neuer FixInsight ist da!

  Alt 26. Mär 2015, 11:36
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;
Stefan
“Simplicity, carried to the extreme, becomes elegance.” Jon Franklin

Delphi Sorcery - DSharp - Spring4D - TestInsight

Geändert von Stevie (26. Mär 2015 um 11:43 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.635 Beiträge
 
Delphi 12 Athens
 
#5

AW: Neuer FixInsight ist da!

  Alt 26. Mär 2015, 12:36
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 { 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.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
Benutzerbild von Stevie
Stevie

Registriert seit: 12. Aug 2003
Ort: Soest
4.045 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#6

AW: Neuer FixInsight ist da!

  Alt 26. Mär 2015, 12:42
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?

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 { 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.
Stefan
“Simplicity, carried to the extreme, becomes elegance.” Jon Franklin

Delphi Sorcery - DSharp - Spring4D - TestInsight
  Mit Zitat antworten Zitat
Roman Yankovsky

Registriert seit: 18. Feb 2015
 
#7

AW: Neuer FixInsight ist da!

  Alt 26. Mär 2015, 13:22
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.

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.
  Mit Zitat antworten Zitat
Der schöne Günther

Registriert seit: 6. Mär 2013
6.199 Beiträge
 
Delphi 10 Seattle Enterprise
 
#8

AW: Neuer FixInsight ist da!

  Alt 26. Mär 2015, 17:51
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".
  Mit Zitat antworten Zitat
Roman Yankovsky

Registriert seit: 18. Feb 2015
 
#9

AW: Neuer FixInsight ist da!

  Alt 26. Mär 2015, 21:29
Nice idea
  Mit Zitat antworten Zitat
Roman Yankovsky

Registriert seit: 18. Feb 2015
 
#10

AW: Neuer FixInsight ist da!

  Alt 4. Okt 2015, 18:30
Finally FixInsight 2015.10 is able to suppress a warning for a piece of code (that was discussed on a previous page). It works not for a scope, but for a particular line though.

Example:
Delphi-Quellcode:
      procedure RestartTimer;
      begin
        FTimer.Enabled := False;
        FTimer.Enabled := True; //FI:W508 - this warning will be ignored.
      end;
So it's just a "FI:<RULENUMBER>" comment.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:58 Uhr.
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