Put the condition before the command
Rule ste-procedural.condition-after-command in the STE Procedural Writing category.
| Field | Value |
|---|---|
| Kind | pattern |
| Severity | warning |
| Scope | body-sentence |
Profile strict |
enforced |
Profile normal |
advisory |
Profile relaxed |
advisory |
Message
Section titled “Message”The condition follows the command (“<match>”). Put the condition first.
Move the condition clause to the front and follow it with a comma.
Examples
Section titled “Examples”Example 1: flagged
Section titled “Example 1: flagged”Restart the worker if the queue depth is above one thousand.Rewrite:
If the queue depth is above one thousand, restart the worker.Example 2: flagged
Section titled “Example 2: flagged”Clear the cache when the import completes.Rewrite:
When the import completes, clear the cache.Example 3: flagged
Section titled “Example 3: flagged”Drain the queue before the worker shuts down.Rewrite:
The worker drains the queue before it shuts down.Example 4: flagged
Section titled “Example 4: flagged”For headless servers, configure the permissions required by the workload before it starts.Rewrite:
Before the workload starts, configure the permissions it requires on headless servers.Example 5: flagged
Section titled “Example 5: flagged”Reconcile the ledger when the import completes.Rewrite:
When the import completes, reconcile the ledger.Exceptions
Section titled “Exceptions”- quotation
- code-span
Provenance
Section titled “Provenance”ASD-STE100