Uploaded image for project: 'SonarSlang'
  1. SonarSlang
  2. SONARSLANG-499

Rule S5377 [Apex] should not raise when sharing properties are inherited

    XMLWordPrintable

    Details

      Description

      A SonarCloud user gave this feedback about the rule RSPEC-5377:
      "Not applicable as it defined in parent class. And access is inherited from the parent class."

      public class BigMachinesQuoteModel extends BaseTriggerHandler { // Noncompliant but FP
      

      Before raising on a child class defined without sharing rules, the analyzer should check if the parent as defined sharing rules, if it the case it's compliant:

      public with sharing class  BaseTriggerHandler { 
      // OR
      public without sharing class  BaseTriggerHandler { 
      // OR
      public inherited sharing class  BaseTriggerHandler { 
      
      // ...
      
      public class BigMachinesQuoteModel extends BaseTriggerHandler { // Compliant
      
      public class  BaseTriggerHandler { 
      
      // ...
      
      public class BigMachinesQuoteModel extends BaseTriggerHandler { // Noncompliant
      

      For a first improvement we decided (see comments) to simply not raise on a child class.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              quentin.jaquier Quentin Jaquier
              Reporter:
              eric.therond Eric Therond
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: