github / github/codeql-cli-binaries
Add `string` predicates `startsWith`, `endsWith` and `contains`
- 主要语言
- 没有语言数据
- 星标
- 1k
- 派生
- 184
- PR 合并指标
- 30 天内没有已合并 PR
描述
What do you think about adding predicates to the CodeQL type `string` for determining whether a string has a given prefix or suffix or contains a substring? For example `startsWith(string)`, `endsWith(string)` and `contains(string)`.
Currently the workarounds are using `indexOf(...) = 0` or `matches(...%)` (which seems to be faster than `indexOf`, see https://github.com/github/codeql/issues/6479#issuecomment-900081363). However, these predicates do not convey the intention as clearly, might not be that performant and for `matches` one must take care not to accidentally use `%`or `_` where the intention was to match them literally.
In the github/codeql repository (at https://github.com/github/codeql/commit/39533317ffbeb6224d049de22fc182d8eeea4b61) there are at least:
- 196 cases where `startsWith` could be used
(I searched for the regex `matches\("[^%_]*%"\)` in CodeQL source files)
- 72 cases where `endsWith` could be used
(I searched for the regex `matches\("%[^%_]*"\)` in CodeQL source files)
贡献指南
调研方向
该 issue 提议向 CodeQL 的 string 类型添加 startsWith、endsWith 和 contains 谓词,但没有说明源文件、测试或实现入口。首先定位 string 类型的实现及其测试;当这些谓词可用,并且覆盖前缀、后缀和子字符串检查,且不依赖 indexOf 或 matches 变通方案时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100