| --- |
| 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 |