Overview
The Compression Apex namespace, introduced in Salesforce Spring '25, provides native, on-platform support for creating and extracting ZIP files. This eliminates the need for off-platform solutions or third-party tools. The namespace offers two classes for these operations, utilizing efficient DEFLATE compression to improve performance and reduce CPU consumption.
β
The Compression namespace offers two classes for creating and extracting zip files. This capability enables developers to perform these operations directly on-platform, reducing the need for off-platform solutions or third-party tools.
β
Code reviews classifies this issue as an Warning because the issues have a minor impact on the application, with low rework requirements. They do not block pull requests but should still be addressed for optimal code quality.
β
What This Rule Checks
This rule is triggered when your Apex code uses third-party ZIP libraries like Zippex for creating or extracting ZIP files. The provided code snippet specifically identifies instances where zippex is used to create files within an ApexClass or ApexTrigger.
βWhy Use the Native Compression API?
Using the built-in Salesforce compression offers several benefits:
Reduced CPU Usage: The native API is more efficient than third-party Apex code, leading to reduced CPU consumption. This is particularly important on the Salesforce platform, where CPU time is a governed resource.
True Compression: It supports real compression with algorithms like DEFLATE, unlike libraries such as Zippex that may not compress data but only store files.
Simplified Code: Eliminates the need for external libraries or client-side workarounds, simplifying your codebase and improving maintainability.
Improved Performance: Enhances the performance of Apex code that compresses or extracts ZIP archives.
Additional Context
Many teams previously offloaded ZIP file creation to JavaScript in the browser or used libraries like Zippex due to the lack of native support for ZIP functions. With the introduction of the Compression namespace in Spring '25, these workarounds are no longer necessary and should be phased out to improve performance and maintainability.
