Skip to content

Fix FPs around custom managed records in VariableInitialization - #469

Open
Bazooper-blip wants to merge 1 commit into
integrated-application-development:masterfrom
Bazooper-blip:fix/468-custom-managed-records
Open

Bazooper-blip wants to merge 1 commit into
integrated-application-development:masterfrom
Bazooper-blip:fix/468-custom-managed-records

Conversation

@Bazooper-blip

Copy link
Copy Markdown
Contributor

This PR fixes false positives in VariableInitialization on custom managed records. Delphi initializes a local custom managed record automatically through its Initialize operator, but the rule tracked it like any other unmanaged record, so code like the example in the issue was flagged even though the record had been initialized.

Records that declare an Initialize operator are now treated like the managed types the rule already exempts (strings, variants, interfaces and arrays). This applies to local var sections, inline var declarations and fields of other records, where the containing record's other fields are still checked. Both the Initialize(out Dest: T) form and the implicit-Self class operator Initialize; form are recognized.

Two cases are intentionally still checked:

  • Records with only a Finalize operator, since their unmanaged fields aren't initialized.
  • out parameters of custom managed record types, in line with 3614f61 treating out parameters as uninitialized. This also keeps the check working inside the Initialize operator itself.

I've also listed these records as an exception in the rule description and added a changelog entry.

Fixes #468.

Local custom managed records with an `Initialize` operator are
initialized automatically by Delphi, but we were tracking them like
any other unmanaged record and flagging them as uninitialized.

Records declaring an `Initialize` operator are now treated like other
managed types, both as local variables and as fields of other records.
Records with only a `Finalize` operator, and `out` parameters of custom
managed record types, are still checked as before.

Closes integrated-application-development#468
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VariableInitialization false positive for custom managed record with Initialize operator

1 participant