Skip to content

Code Analyzer suppressions

Reference8 min read

Find every inline Salesforce Code Analyzer suppression in the Record Health Check package, exactly where each one is, and why it is safe to leave in place. For the security model of an installed org, see Security and data access.

Record Health Check is engineered for AppExchange security-review readiness. Its release process keeps Salesforce Code Analyzer rules enabled by default, fails on new unsanctioned findings, and requires every narrow suppression to be documented and reviewable on this page. Those controls are supplemented by clean-source CI, permission-assignment tests, adversarial tests, package-boundary checks, and Salesforce runtime validation.

This readiness statement describes the repository’s engineering controls. It is not a claim that a specific package version has passed Salesforce AppExchange Security Review, and it does not replace Salesforce’s submission, automated scanning, manual review, clean-install, or integration-review requirements. State that a release is AppExchange approved only after Salesforce has approved that exact submitted solution and version.

Use this table to look up a suppression by file, rule, or category. Every suppression is a comment placed directly above the line it covers:

// code-analyzer-suppress-next-line <RuleName>: <reason>

The rule stays enabled for every other line in the package; a new violation anywhere else still fails the release scan. Reproduce this count from a clean checkout:

Terminal window
grep -rn "code-analyzer-suppress-next-line" \
packages/record-health-check/force-app \
packages/record-health-check/integration-tests

36 lines in the 2.0.11 source: 26 in the core package and 10 in the integration test harness.

Two core classes also carry a class-level annotation instead of an inline comment: RecordHealthCheckFieldPlanner.cls and RecordHealthCheckQuerySchemaValidator.cls use @SuppressWarnings('PMD.IfStmtsMustUseBraces,PMD.IfElseStmtsMustUseBraces'), a brace-style rule only. The release gate’s inventory, config/code-analyzer-inline-suppressions.json, lists all 38 entries and fails when the source and the inventory disagree.

26 suppressions across four rules.

Check Sets and Checks are stored as Custom Metadata Types (Record_Health_Check_Set__mdt, Record_Health_Check__mdt). Salesforce always lets Apex read a Custom Metadata Type record. It does not apply the same-object read permission or field-level security it applies to Accounts, Contacts, and other business records. That is a Salesforce platform behavior, not a gap in Record Health Check’s own code (Trailhead: Protect Custom Metadata Types & Records). Adding WITH USER_MODE to a query like this would have no effect, since Custom Metadata Type reads bypass record and field access checks either way.

Most reads below happen after Record Health Check’s own permission check confirms the user is allowed to run Checks at all (RecordHealthCheckAccess.canRunChecks()).

FileLineRuleWhat this line does
RecordHealthCheckAsyncSupport.cls65ApexCRUDViolationConfirms that the Check Set is active and reads its object before a Batch, Queueable, or Scheduled job is submitted.
RecordHealthCheckConfigService.cls61ApexCRUDViolationLoads the Check Set’s card heading and Run-button settings before the Check definitions load.
RecordHealthCheckConfigService.cls80ApexCRUDViolationCounts the Check Set’s active Checks for that first card view.
RecordHealthCheckConfigService.cls88ApexCRUDViolationCounts the Check Set’s inactive Checks for that first card view.
RecordHealthCheckConfigService.cls175ApexCRUDViolationFinds which Check Set a given Check belongs to.
RecordHealthCheckConfigService.cls199ApexCRUDViolationChecks which object every Check Set targets and whether it is active, to find the ones that apply to the current record page.
RecordHealthCheckConfigService.cls339ApexCRUDViolationLoads one Check’s configuration immediately before it runs.
RecordHealthCheckController.cls451ApexCRUDViolationConfirms that a Check belongs to the Check Set the caller names.
RecordHealthCheckDefinitionLoader.cls46ApexCRUDViolationLoads the Check Set Custom Metadata record shown on the card.
RecordHealthCheckDefinitionLoader.cls87ApexCRUDViolationLoads the Checks that belong to that Check Set.
RecordHealthCheckDefinitionLoader.cls422ApexCRUDViolationCounts a Check Set’s inactive Checks for the administrator tooltip.
RecordHealthCheckDefinitionLoader.cls440ApexCRUDViolationLists those inactive Checks’ names for that same tooltip.
RecordHealthCheckMetadataValidator.cls50ApexCRUDViolationReads every Check Set, active or inactive, so an administrator’s configuration can be validated.
RecordHealthCheckMetadataValidator.cls73ApexCRUDViolationReads every Check for that same administrator-facing validation.
RecordHealthCheckPreviewService.cls107ApexCRUDViolationLoads the saved Check Set that owns a Preview, after Admin and Run authorization.
RecordHealthCheckPreviewService.cls212ApexCRUDViolationReads the saved Check’s identity so a detached draft cannot impersonate an existing Check.
RecordHealthCheckScopePlanner.cls42ApexCRUDViolationLoads the Check Set’s own configuration. The Account, Contact, or other records it evaluates are queried separately, using the running user’s real record access (WITH USER_MODE).
RecordHealthCheckSetPicklist.cls54ApexCRUDViolationLists active Check Sets for the picker an administrator sees while building a Lightning page.
RecordHealthCheckSettingsProvider.cls10ApexCRUDViolationReads whether a Check Set publishes Log events. Not a subscriber’s business record.
RecordHealthCheckSettingsProvider.cls24ApexCRUDViolationReads whether a Check Set publishes its interactive run event.
RecordHealthCheckSettingsProvider.cls39ApexCRUDViolationReads which Checks publish their interactive result events.
FileLineRuleWhat this line does
RecordHealthCheckReadinessService.cls46ApexCRUDViolationSaves the immutable readiness receipt after Admin and Run authorization. Administrators cannot create receipts directly, so the service writes this server-owned evidence itself.
FileLineRuleWhat this line does
RecordHealthCheckScopeRecordLoader.cls128ApexSOQLInjectionBuilds the query that loads the records’ field values for evaluation. The record IDs come in as a bind variable, the object and field names are checked against Salesforce’s own schema first, and the query runs with the user’s real record access (WITH USER_MODE).
FileLineRuleWhat this line does
RecordHealthCheckDescribeCache.cls36AvoidMultipleMassSchemaLookupsLooks up Salesforce’s object and field metadata once per transaction and reuses it, instead of asking Salesforce again for every Check.
FileLineRuleWhat this line does
RecordHealthCheckContractHarnessTest.cls119OperationWithLimitsInLoopThis test plugin deliberately queries one record at a time, to prove the contract test detects query growth in a custom Apex Check.
RecordHealthCheckScopePlannerTest.cls235OperationWithLimitsInLoopThis test deliberately uses up all but two of the query slots, to prove the planner blocks a Check that would need three.

Not every finding here got a suppression comment. AvoidHardcodedCredentialsInFieldDecls matched a field named AUTHORIZATION_MESSAGE in three classes; its heuristic matched the word “AUTHORIZATION” in the field name, not its value, which was always a plain user-facing message (“You do not have permission to run Record Health Checks.”). Since this was a naming collision and not a real access-control question, the field was renamed instead of suppressed:

FileChange
RecordHealthCheckAgentRestResource.clsAUTHORIZATION_MESSAGE renamed to PERMISSION_DENIED_MESSAGE
RecordHealthCheckRunCheckAgentAction.clsAUTHORIZATION_MESSAGE renamed to PERMISSION_DENIED_MESSAGE
RecordHealthCheckRunSetAgentAction.clsAUTHORIZATION_MESSAGE renamed to PERMISSION_DENIED_MESSAGE

The public 'AUTHORIZATION' reason code these classes return to callers, documented in the Agent tool contract, did not change. Only the private field holding the message text did.

10 suppressions. This package only runs in a scratch org during development. It is never packaged, never installed in a subscriber org, and ships with none of the metadata described here.

FileLineRuleWhat this line does
RecordHealthCheckContractHarnessTest.cls149OperationWithLimitsInLoopThe integration copy of the deliberately non-bulk test plugin, used to prove that the contract test detects record-count-dependent query growth.

RHC_Benchmark_Result__c is a regular custom object, not a Custom Metadata Type. It holds performance numbers from admin-run benchmark tests and nothing else. It is suppressed because it is disposable test-org infrastructure that a subscriber never sees, not because record access rules don’t apply to it.

FileLineRuleWhat this line does
RecordHealthCheckScaleBenchmark.cls22ApexCRUDViolationWrites a new row to the benchmark’s own results object, which exists only in the test org.
RecordHealthCheckScaleBenchmark.cls29ApexCRUDViolationSaves the async job ID on that same results row.
RecordHealthCheckScaleBenchmark.cls57ApexCRUDViolationWrites benchmark results even when the running user’s Permission Set intentionally has no access to the results object; the benchmark still needs to record what happened.
RecordHealthCheckScaleBenchmark.cls68ApexCRUDViolationSaves the job ID on the results row for a specific benchmark run.
RecordHealthCheckScaleBenchmark.cls85ApexCRUDViolationReads the benchmark results report. Enforcing normal field-level security here would make the benchmark’s own fields unreadable to the person running it.
RecordHealthCheckScaleBenchmark.cls120ApexCRUDViolationLooks up one benchmark run’s results row by its run ID.
FileLineRuleWhat this line does
RecordHealthCheckExhaustiveSmoke.cls26OperationWithLimitsInLoopStarts one background (Queueable) job at a time, up to Salesforce’s 50-job-per-transaction limit. Salesforce does not offer a bulk way to start Queueable jobs.
RecordHealthCheckExhaustiveSmoke.cls54OperationWithLimitsInLoopStarts the next group of background jobs, capped at that same 50-job limit.
RecordHealthCheckExhaustiveSmoke.cls105QueueableWithoutFinalizerThis one-time test harness saves its own result directly; it has no follow-up job, so it does not need Salesforce’s Queueable Finalizer cleanup step.