A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/2774 below:

[apex] ApexSharingViolations does not correlate sharing settings with class that contains data access · Issue #2774 · pmd/pmd · GitHub

Affects PMD Version:
6.27.0

Rule:
ApexSharingViolations

Description:
ApexSharingViolations scans inner and outer classes for DML, SOQL, or SOSL. The rule only looks at the outer class for a sharing declaration. As described here the sharing setting applies to the class that performs the data access.

Code Sample demonstrating the issue:

Example False Positive(Sharing is correctly declared on Inner class)

public class Outer {
   public with sharing class Inner {
      public List<Contact> getAllInnerSoqlSecrets() { return [SELECT Name FROM Contact]; }
   }
}

Example False Negative(Sharing is incorrectly declared on Outer class)

public with sharing class Outer {
   public class Inner {
      public List<Contact> getAllInnerSoqlSecrets() { return [SELECT Name FROM Contact]; }
   }
}

Expected outcome:
The rule is generating both a false-positive and false-negative

Running PMD through: CLI


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4