Skip to content

Commit d2d8e37

Browse files
fourlscirras
authored andcommitted
Improve FormatArgumentCount description
1 parent 3245d03 commit d2d8e37

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

delphi-checks/src/main/resources/org/sonar/l10n/delphi/rules/community-delphi/FormatArgumentCount.html

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ <h2>Why is this an issue?</h2>
44
raises a runtime exception.
55
</p>
66
<p>
7-
Generally speaking, the number of arguments should exactly match the number of format specifiers
8-
in the string. <code>Format</code> allows you to format the same argument multiple times using
9-
index specifiers, in which case the number of arguments may be more difficult to determine.
7+
Typically, the number of arguments should exactly match the number of format specifiers
8+
in the string. For some complex cases, a different number of arguments is required
109
</p>
10+
<ul>
11+
<li>
12+
Width and precision wildcards in floating point format specifiers
13+
(e.g. <code>%*.*f</code>) require corresponding arguments
14+
</li>
15+
<li>
16+
Format specifiers with a specified index (e.g. <code>%1:s</code>)
17+
can reuse existing arguments or require additional arguments
18+
</li>
19+
</ul>
1120
<h2>How to fix it</h2>
1221
<p>
1322
Ensure that the arguments to the <code>Format</code> call match the specifiers in the format
@@ -16,7 +25,7 @@ <h2>How to fix it</h2>
1625
<pre data-diff-id="1" data-diff-type="noncompliant">
1726
Format('%s (class %d) got %.*f percent on the test.', ['Bob', 74.599]);
1827
</pre>
19-
<pre data-diff-id="1" data-diff-type="noncompliant">
28+
<pre data-diff-id="1" data-diff-type="compliant">
2029
Format('%s (class %d) got %.*f percent on the test.', ['Bob', 6, 2, 74.599]);
2130
</pre>
2231
<h2>Resources</h2>

0 commit comments

Comments
 (0)