[BUG][code-analyzer] sfge: List.sort(Comparator) aborts the entry point (API 61 overload not accepted)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 88/100
Direzione di ricerca
Inizia da ApexListValue.java intorno alle righe 305-308, quindi esamina ApexValue.java:610 per comprendere il fallimento della convalida dei parametri. Riproduci il problema con il comando sf code-analyzer fornito e l’esempio Apex; il lavoro è completato quando sort(Comparator) non interrompe più l’entry point e l’analisi termina senza InternalExecutionError.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Have you tried to resolve this issue yourself first?
- I confirm I have gone through the above steps and still have an issue to report.
Bug Description
Engine: sfge (Salesforce Graph Engine) · Rule: ApexFlsViolation (DevPreview) · Selector: --rule-selector sfge
ApexListValue.apply asserts sort takes zero parameters:
// ApexListValue.java:305-308
} else if (METHOD_SORT.equalsIgnoreCase(methodName)) {
validateParameterSize(vertex, 0);
// Intentionally left blank
// TODO: Does this need to sort?
Apex added List.sort(Comparator<T>) in API 61 (Spring '24). The zero-argument assertion was never updated, so the overload throws at ApexValue.java:610.
List<Account> accs = new List<Account>();
accs.sort(new ByName());
Output / Logs
UnexpectedException: MethodCallExpressionVertex{fullMethodName=accs.sort, ... MethodName=sort}:
com.salesforce.graph.symbols.apex.ApexValue.validateParameterSize(ApexValue.java:610);
com.salesforce.graph.symbols.apex.ApexListValue.apply(ApexListValue.java:306);
com.salesforce.graph.symbols.PathScopeVisitor.handleApexValueMethod(PathScopeVisitor.java:1487); ...
Steps To Reproduce
- Create an empty SFDX project (
sfdx-project.jsonwith a singleforce-apppackage directory). - Add
force-app/main/default/classes/ListSortComparator.clswith the class shown below, plus a standardListSortComparator.cls-meta.xml(apiVersion 62.0). - Add
code-analyzer.yml:engines: sfge: java_thread_timeout: 900000 java_thread_count: 4 - Run:
sf code-analyzer run --rule-selector sfge --workspace . --config-file code-analyzer.yml - The run reports an
InternalExecutionErrorfor the entry point instead of analysing it. That entry point yields noApexFlsViolationfindings at all, and nothing in the summary indicates coverage was lost.
public with sharing class ListSortComparator {
public class ByName implements Comparator<Account> {
public Integer compare(Account a, Account b) { return 0; }
}
@AuraEnabled
public static void run() {
List<Account> accs = new List<Account>();
accs.sort(new ByName());
insert accs;
}
}
Expected Behavior
sort(Comparator) should be accepted. Suggested fix: validateParameterSizes(vertex, 0, 1). The existing body is already a no-op with a // TODO: Does this need to sort?, so accepting the comparator argument costs nothing beyond the assertion change.
Operating System
macOS 26.5.2
Salesforce CLI Version
@salesforce/cli/2.147.7 darwin-arm64 node-v24.5.0
Code Analyzer Plugin (code-analyzer) Version
code-analyzer 5.15.0
Node Version
v24.5.0
Java Version
openjdk version "11.0.32" 2026-07-21
Python Version
N/A
Additional Context (Screenshots, Files, etc)
One signature / one entry point in our codebase, but Comparator is the modern idiom for sorting in Apex and adoption is only going to grow, so this will get more common rather than less.
Workaround
Fall back to implements Comparable on the element type and call the zero-argument sort(), which sfge accepts.
Urgency
Moderate
- Lingua principale
- TypeScript
- Stelle
- 240
- Fork
- 52
- Merge medio
- 1g 23h
- PR unite (30g)
- 5
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di forcedotcom/code-analyzer
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
forcedotcom/code-analyzer#2094 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
forcedotcom/code-analyzer#2091 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
forcedotcom/code-analyzer#2090 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
forcedotcom/code-analyzer#2098 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
forcedotcom/code-analyzer#2097 ·
Tutte le issue di forcedotcom/code-analyzer
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
[Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity Apertabug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
calcite-components needs triage refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Esri/calcite-design-system#15203 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
danielmiessler/LifeOS#2218 ·