Skip to content

[apex] EagerlyLoadedDescribeSObjectResult: False positive with fully qualified SObjectDescribeOptions/FieldDescribeOptions #5082

Closed

Description

@FedeAbella

Affects PMD Version: 7.0.0

Rule: EagerlyLoadedDescribeSObjectResult

Description: When calling SObjectType.getDescribe() using one of the SObjectDescribeOptions enums, the rule still comes up as failed if the option is called using the Schema namespace explicitly.

Code Sample demonstrating the issue:
Failing snippet:

Id niprRecordTypeId = Regulatory_Action__c.SObjectType.getDescribe(
        Schema.SObjectDescribeOptions.DEFERRED
      )
      .getRecordTypeInfosByDeveloperName()
      .get('NIPR')
      .getRecordTypeId();

Not failing snippet:

Id niprRecordTypeId = Regulatory_Action__c.SObjectType.getDescribe(
        SObjectDescribeOptions.DEFERRED
      )
      .getRecordTypeInfosByDeveloperName()
      .get('NIPR')
      .getRecordTypeId();

Expected outcome: The rule should not fail when explicitly invoking the Schema namespace, given this is a correct usage of the enum, accepted by the compiler.

Running PMD through: CLI

Activity

  1. added
    a:false-positive
    on Jun 21, 2024
  2. added 5 commits that reference this issue on Oct 1, 2026
    48862a9
    39b2be4
    15e2b86
    a31810c
    5dd05f6
  3. changed the title [-][apex] EagerlyLoadedDescribeSObjectResult rule fails when SObjectDescribeOptions is called using explicit Schema namespace[/-] [+][apex] EagerlyLoadedDescribeSObjectResult: false positive with fully qualified SObjectDescribeOptions[/+] on Oct 23, 2026
  4. changed the title [-][apex] EagerlyLoadedDescribeSObjectResult: false positive with fully qualified SObjectDescribeOptions[/-] [+][apex] EagerlyLoadedDescribeSObjectResult: false positive with fully qualified SObjectDescribeOptions/FieldDescribeOptions[/+] on Oct 26, 2026
  5. added this to the 7.29.0 milestone on Oct 26, 2026
  6. added a commit that references this issue on Oct 26, 2026
  7. added a commit that references this issue on Oct 26, 2026
    f4e059d
  8. changed the title [-][apex] EagerlyLoadedDescribeSObjectResult: false positive with fully qualified SObjectDescribeOptions/FieldDescribeOptions[/-] [+][apex] EagerlyLoadedDescribeSObjectResult: False positive with fully qualified SObjectDescribeOptions/FieldDescribeOptions[/+] on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positive

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions