You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
java: ? and : count as branches inside string literals, and a ternary counts twice #4170
In Java, branch and complexity counting (struct_branch, per-function complexity) counts every ? and every : as a decision point:
Inside string literals. JDBC ? placeholders and SQL :host variables each add a branch.
Real ternaries.a ? b : c adds 2 instead of 1.
Minimal repro (main at 582caf5), each method has one if:
Method body besides the if
complexity
String s = "hello";
1
String s = "(?, ?, ?, ?, ?)";
6
String s = "(:a, :b, :c, :d, :e)";
6
String s = "where a = ?";
2
String s = x > 1 ? "a" : "b";
3 (should be 2)
Impact
IBM WCA4Z's published Lgacdb01.insertCustomer (sandeephans/validation-c2j) scores 21. Its real decision count is about 2–3: its two INSERT strings carry 19 ?.
Activity