Blog

All Blog Posts  |  Next Post  |  Previous Post

TMS FixInsight 2019.11

Bookmarks: 

Thursday, November 28, 2019

I'm happy to announce FixInsight 2019.11 release

What's New

* New : Rule W531 Actual parameter of FreeAndNil() must be a reference to class instance
* New : Rule W534 Class instance passed but interface expected
* Fixed : FixInsight hangs in some cases when running W525
* Fixed : File specified in {$INCLUDE} directive cannot be found in some cases
* Fixed : Access Violation on IDE start
* Fixed : "Load Defaults" button in Settings dialog doesn't restore general settings
* Fixed : Several parser issues

I'll add few more words about new features.

Rule W531 ensures that the parameter of FreeAndNil() is be a reference to a class instance. Due to FreeAndNil() implementation details, compiler is not able to check its parameter type.

This compiles, but this is wrong:
  var
    Intf: IInterface;
  begin
    FreeAndNil(Intf);
  end;

Rule W534 ensures that a class instance is not passed when an interface is expected. This may compile, but due to reference counting a class can be released right after such method call.

Example:

type
  ISomeInterface = interface
  ['{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}']
  end;

  TSomeClass = class(TInterfacedObject, ISomeInterface)
  end;

procedure DoSomethingWithSomeInterface(const SomeInterface: ISomeInterface);
begin
  // ...
end;

procedure DoSomethingWithSomeClass;
var
  SomeClass: TSomeClass;
begin
  SomeClass := TSomeClass.Create;
  try
    DoSomethingWithSomeInterface(SomeClass); // <= W534
    // After this call SomeClass will be released due to reference counting
  finally
   SomeClass.Free; // cannot be released twice
  end;
end;
Also there are new parameters for command line tool. In this release FixInsight needs to know more about your project.
FixInsightCL --project=c:\source\example.dpr --libpath="C:\Program Files (x86)\Embarcadero\Studio\20.0\source" --unitscopes=Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;Soap
--libpath should point to your Delphi source folder. And I suggest to copy values for --unitscopes and --unitaliases parameters from your project options.

Roman Yankovsky


Bookmarks: 

This blog post has received 2 comments.


1. Friday, November 29, 2019 at 7:52:40 AM

Are you planning to implement this leak detection

https://pascal.today/2016/12/16/take-care-of-const-and-interface-parameters/


Koistinen Mika


2. Friday, November 29, 2019 at 8:39:39 AM

Yes! This is actually planned for the next release (around February 2020).

Roman Yankovsky




Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.



All Blog Posts  |  Next Post  |  Previous Post