Validate command input and handle bad values cleanly

Aperta
#73 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
50/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
backend, testing

Direzione di ricerca

Start by reading the command handlers for /shop add, update, delete, sell, and create, plus identifyStore and the tab completer; the issue does not name their files. Run the existing tests that reproduce the first three rows and the sell case, then add coverage for the remaining rows. Done means invalid input leaves state unchanged, duplicate matches use STORE_MULTI_MATCH in commands and completion, and all listed cases are covered.

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

Descrizione

bug

Problem

Several commands accept input they can't handle, or fail with an unhelpful error.

Input Result
/shop add stone NaN NaN -1 1 (also Infinity, and the same through update) Accepted. /shop buy on that item then always fails with "Invalid numerical value"
/shop add stone -3 with shops.update.inf-stock Takes 3 from the store's stock, then reports "Invalid number of arguments"
/shop update location Dup ... when two stores are named Dup MultipleStoresMatchedException isn't caught, so "An internal error occurred". The tab completer calls identifyStore unguarded too
/shop delete abc~ when a store named abc exists split("~") leaves no second part, so input[1] throws
Store names containing ~ Created normally, but can't be found by name afterward
/shop sell notreal all Reports "Invalid quantity (0)" instead of an invalid material
/shop create <name> <player> The limit is checked against the sender's stores, not the new owner's

The first three rows and the sell row were reproduced in tests. The others come from reading the code.

Done when

  • Prices must be finite numbers, and negative values are only accepted where they have a meaning.
  • A failed command changes nothing.
  • Duplicate-name errors show STORE_MULTI_MATCH everywhere, including tab completion.
  • Store names can't contain ~, or the parser handles them.
  • Tests cover each row.
Lingua principale
Java
Stelle
1
Fork
0
Merge medio
2h 35m
PR unite (30g)
14

Preparare l'ambiente

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 BrendonButler/Shops

Tutte le issue di BrendonButler/Shops

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.