Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Suggest `match` with `regexp` instead of `regexp-match`

Aperta
#541 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Ambito
tooling

Direzione di ricerca

Inizia con gli esempi collegati in drracket/browser/private/html.rkt e il caso di test fornito in resyntax/test; poi trova l’implementazione della raccomandazione e i test esistenti per regexp-match e i pattern di match. Il lavoro è completato quando il test mostrato passa, mentre i casi con più gruppi di cattura senza nome o rami che non sono lambda continuano a non essere raccomandati.

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

Descrizione

new lint

In this code, the use of cond and regexp-match can be expressed more cleanly using match with the regexp pattern. This probably shouldn't be rewritten unless 1) every non-else branch of the cond is using the lambda-based form and 2) all of the match patterns use define to name the extracted groups, if there are multiple groups. So this test case ought to pass:

#lang resyntax/test
require: resyntax/default-recommendations default-recommendations
header:
- #lang racket

test: "original code should be refactorable to new code"
--------------------
(define re #rx"^[ \t\n]*([0-9]+)[ \t\n]*,(.*)$")
(define (f str)
  (cond
    [(regexp-match re str)
     =>
     (lambda (m)
       (define a (cadr m))
       (define b (caddr m))
       (list a b))]
    [else 'else]))
====================
(define re #rx"^[ \t\n]*([0-9]+)[ \t\n]*,(.*)$")
(define (f str)
  (match str
    [(regexp re (list _ a b)) (list a b)]
    [else 'else]))
--------------------

There are some similar cases in DrRacket's codebase but refactoring all of them is questionable. The cases where there's multiple capture groups and none of them have named variables associated with them ought to be left alone.

Lingua principale
Racket
Stelle
70
Fork
11
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jackfirth/resyntax

Tutte le issue di jackfirth/resyntax

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.