Automattic / Automattic/VIP-Coding-Standards

Make suggestion when autoload resolves to true

Aperta
#497 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Standard: VIP-Go Type: Enhancement
Lingua principale
PHP
Stelle
261
Fork
44
Merge medio
19m
PR unite (30g)
1

Descrizione

## What problem would the enhancement address for VIP?

Options get marked as autoload=yes when being added, unless there is an explicit setting to no.

For VIP clients, we should flag when it is yes, to remind and encourage developers to consider whether it should be autoload=no, which can help with performance.

## Describe the solution you'd like

PHPCS Warning when `'yes'` or `true` is supplied or implied when calling `add_option()` or `update_option()`.

## What code should be reported as a violation?

```
add_option( 'my_option', 'my_value', '', 'yes' );
add_option( 'my_option', 'my_value', '', true ); // Can be 'yes' string or boolean.
add_option( 'my_option', 'my_value', '' );
add_option( 'my_option', 'my_value' );
add_option( 'my_option' );
update_option( 'my_option', 'my_value', 'yes' );
update_option( 'my_option', 'my_value', true ); // Can be 'yes' string or boolean.
```

## What code should *not* be reported as a violation?

```
add_option( 'my_option', 'my_value', '', 'no' );
add_option( 'my_option', 'my_value', '', false );
update_option( 'my_option', 'my_value', 'no' );
update_option( 'my_option', 'my_value', false );
```

## Additional context

Some items may indeed be valid to be autoloaded, so it's not an Error in all cases.

This may seem like a bit of noise for some cases, but I think it counts as a good reminder. We can link the error message to [our public docs about autoloading](https://wpvip.com/documentation/vip-go/working-with-wp_options/#autoloading).

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Individua lo sniff PHPCS e i test che gestiscono add_option() e update_option(); esamina come vengono classificati gli argomenti omessi, i valori letterali yes/no e i booleani. Il lavoro è completato quando i casi yes/true/implied elencati producono avvisi, i casi no/false non ne producono e l'avviso può fare riferimento alla documentazione di autoloading fornita.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.