git/contrib/coccinelle/strbuf.cocci
René Scharfe ae239fc8e5 cocci: simplify check for trivial format strings
353d84c537 (coccicheck: make transformation for strbuf_addf(sb, "...")
more precise) added a check to avoid transforming calls with format
strings which contain percent signs, as that would change the result.
It uses embedded Python code for that.  Simplify this rule by using the
regular expression matching operator instead.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-02 14:30:12 -08:00

32 lines
426 B
Plaintext

@ strbuf_addf_with_format_only @
expression E;
constant fmt !~ "%";
@@
- strbuf_addf
+ strbuf_addstr
(E,
(
fmt
|
_(fmt)
)
);
@@
expression E1, E2;
@@
- strbuf_addf(E1, "%s", E2);
+ strbuf_addstr(E1, E2);
@@
expression E1, E2, E3;
@@
- strbuf_addstr(E1, find_unique_abbrev(E2, E3));
+ strbuf_add_unique_abbrev(E1, E2, E3);
@@
expression E1, E2;
@@
- strbuf_addstr(E1, real_path(E2));
+ strbuf_add_real_path(E1, E2);