blob: 1d45b83f9898c8ce2e56a552ec4f4d905874b3f8 [file] [edit]
---
id: cmhassuffix-char
language: Cpp
severity: warning
message: "`cmHasSuffix` with a one-char suffix search should use `cmHasSuffix`"
rule:
kind: string_literal
pattern: $ARG
follows:
regex: '(,|[(])'
inside:
matches: cmhassuffix-call
stopBy:
kind: call_expression
constraints:
ARG:
regex: '^"(.|\\.)"$'
transform:
ARG_CHANGE_QUOTE:
replace:
source: $ARG
replace: '(^"|"$)'
by: "'"
ARG_ESCAPE_SINGLE_QUOTE:
replace:
source: $ARG_CHANGE_QUOTE
replace: "'''"
by: "'\\''"
ARG_OUT:
replace:
source: $ARG_ESCAPE_SINGLE_QUOTE
replace: '\\"'
by: '"'
fix: $ARG_OUT