github / github/codeql-cli-binaries

Add `string` predicates `startsWith`, `endsWith` and `contains`

Aperta
#78 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
CLI
Lingua principale
Nessun dato sulla lingua
Stelle
1k
Fork
184
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

The issue proposes adding startsWith, endsWith, and contains predicates to the CodeQL string type, but names no source files, tests, or implementation entry points. Begin by locating the string type implementation and its tests; done means the predicates are available and cover prefix, suffix, and substring checks without relying on indexOf or matches workarounds.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Ambito
devtools
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.