FixInsight vs FMX in Delphi 10.1 Berlin
It becomes a good tradition to do a static analysis of FMX after each new Delphi release. I have already done this for Delphi XE8 and Delphi 10 Seattle. Now it’s a time to take a look at FMX in Delphi 10.1 Berlin (24.0.22858.6822).
As usual I will try to skip minor issues and mention only the most interesting parts of code (have you ever thought how many empty “except” blocks in FMX?).
There are a no new issues found by FixInsight! Very good! But let’s talk about strange code, that hasn’t been changed since previous releases.
W511 Object ‘LinePath’ created in TRY block
for I := 0 to FFrame3D.Count - 1 do try LinePath := TPathData.Create; LLine := FFrame3D[I]; LineAdvance := 0;
No, it’s not that case when you set a variable to nil before a try block :)
W528 Variable ‘J’ not used in FOR-loop
// Iterate through each control's list and remove gesture ID's // that don't exist in the updated FCustomGestures list for P in FControls do for I := P.Value.Count - 1 downto 0 do for J := 0 to FRecordedGestures.Count - 1 do begin if (P.Value[I].GestureType = TGestureType.Recorded) and (FRecordedGestures.FindGesture(P.Value[I].GestureID) = nil) then P.Value.Delete(I); end;
But why the inner J-loop is needed? Why is it there?
W505 Empty THEN block
if FoundValue.Count > 1 then else if FoundValue.Count > 0 then PropValues[Name] := FoundValue;
I still wonder why it’s not replaced with “If FoundValue.Count = 1 then PropValues[Name] := FoundValue” since Delphi XE8 (or maybe even earlier).
W508 Variable is assigned twice successively
Difference := ; Difference := Value - FInteractiveGestures;
P := Content.LocalToAbsolute(BottomRight); P := AItem.ParentControl.AbsoluteToLocal(Content.LocalToAbsolute(BottomRight));
ISFNkey := False; ISFNkey := Kind = TKeyKind.Functional;
RootViewRect := SharedApplication.keyWindow.rootViewController.view.frame; RootViewRect := SharedApplication.keyWindow.rootViewController.view.bounds;
Not a major issue, but FMX code could be a bit cleaner without this.
The good news is that most bugs reported in my previous posts seem to be fixed. General impression is much better.
But the developers of FMX shouldn’t relax, next time I’ll come up with even more comprehensive checks and rules :)