github / github/codeql-cli-binaries
Add `string` predicates `startsWith`, `endsWith` and `contains`
- Lenguaje dominante
- Sin datos de lenguaje
- Estrellas
- 1k
- Forks
- 184
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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)
Guía de contribución
Línea de trabajo
El issue propone añadir los predicados startsWith, endsWith y contains al tipo string de CodeQL, pero no nombra archivos fuente, pruebas ni puntos de entrada de la implementación. Comienza localizando la implementación del tipo string y sus pruebas; el trabajo estará terminado cuando los predicados estén disponibles y cubran las comprobaciones de prefijos, sufijos y subcadenas sin depender de soluciones alternativas con indexOf o matches.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Área
- devtools
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100