Skip to content

hardis:org:diagnose:unused-apex-classes

Description

List all async Apex classes (Batch,Queueable,Schedulable) that has not been called for more than 365 days.

The result class list probably can be removed from the project, and that will improve your test classes performances 😊

The number of unused day is overridable using --days option.

The command uses queries on AsyncApexJob and CronTrigger technical tables to build the result.

Apex Classes CreatedBy and CreatedOn fields are calculated from MIN(date from git, date from org)

This command is part of sfdx-hardis Monitoring and can output Grafana, Slack and MsTeams Notifications.

Agent Mode

Supports non-interactive execution with --agent:

sf hardis:org:diagnose:unused-apex-classes --agent --target-org myorg@example.com

In agent mode, the command runs fully automatically. The inactivity threshold defaults to 365 days when --days is not provided.

Parameters

Name Type Description Default Required Options
agent boolean Run in non-interactive mode for agents and automation. Uses default values and skips prompts.
days
-t
option Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days
debug
-d
boolean Activate debug mode (more logs)
flags-dir option undefined
json boolean Format output as json.
outputfile
-f
option Force the path and name of output report file. Must end with .csv
skipauth boolean Skip authentication check when a default username is required
target-org
-o
option undefined
websocket option Websocket host:port for VsCode SFDX Hardis UI integration

Examples

$ sf hardis:org:diagnose:unused-apex-classes
$ sf hardis:org:diagnose:unused-apex-classes --days 700
$ sf hardis:org:diagnose:unused-apex-classes --agent