Make options declaration mandatory
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start by reading AbstractAnonymizer validation and the existing option handling, then inspect anonymizer implementations that duplicate the columns validation introduced in #234. Define how initialize(), addOption(), declared options, and the Options array should interact; done means mandatory and type validation is centralized and declared options can support the proposed column-name checks.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In all multiple column anonymizers that accept other options than column names, columns cannot be named with the same names as options, such as sample_size, source, etc...
In #234 I introduced this in validation:
$columns = $this->options->get('columns', null, true);
if (!\is_array($columns)) {
throw new ConfigurationException("'columns' must be an array of string or null values.");
}
$invalidNames = ['source', 'columns', 'file_csv_enclosure', 'file_csv_escape', 'file_csv_separator', 'file_skip_header'];
foreach ($columns as $index => $column) {
if (\in_array($column, $invalidNames)) {
throw new ConfigurationException(\sprintf("'columns' values cannot be one of ('%s') for column #%d.", \implode("', '", $invalidNames), $index));
}
if (!\is_string($column) && null !== $column) {
throw new ConfigurationException(\sprintf("'columns' must be an array of string or null values (invalid type for column #%d.", $index));
}
}
This works, but I now have to repeat this a second, then a third time for new anonymizer implementations.
It's becoming hard to maintain:
- copy-pasted code more than two times is wrong,
- some other options can be set at the abstract anonymizer level (sample size, for example).
What I propose is to force anonymizers to declare their options, for example:
protected function initialize(): void
{
$this->addOption(
'sample_size',
Option::TYPE_INT,
"Some short description",
null /* default value) */,
true /* Is optional (default true) */,
"Some long description..."
);
// ...
}
Then, in AbstractAnonymizer, when validation happens, check the given Options array and validate automatically at least the mandatory and type state.
- We can also generate documentation from this.
- We also can get rid of long class PHP doc.
- We can generate meaningful console commands that documents it as well.
- We can automatize some validation in check command.
- We can use this declared attribute list for the custom validation I presented on top of this issue: instead of iterating over a raw array, we could iterate over
\array_keys($this->getDeclaredOptions())for example.
- Lingua principale
- PHP
- Stelle
- 235
- Fork
- 17
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di makinacorpus/DbToolsBundle
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
makinacorpus/DbToolsBundle#259 ·
-
Command-line option --config is not applied when creating database connections in standalone modeAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
makinacorpus/DbToolsBundle#260 ·
-
Laravel 12.0 & 13.0 supportForse di nuovo libera @Lonnytunes l’ha presa 169 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement good first issue
makinacorpus/DbToolsBundle#254 · 6 commenti · 1 assegnatario ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
makinacorpus/DbToolsBundle#252 · 2 commenti ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
makinacorpus/DbToolsBundle#236 ·
Tutte le issue di makinacorpus/DbToolsBundle
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
taskforcesh/bullmq#5238 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects itForse già presa @bfs2021 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Automattic/jetpack#55517 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
-
area/import type/enhancement when/later
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno