Automattic / Automattic/VIP-Coding-Standards

Audit Public Sniff Properties

未关闭
#234 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Type: Maintenance
主要语言
PHP
星标
261
派生
44
平均合并
19 分钟
30 天内合并 PR
1

描述

## What problem would the enhancement address for VIP?

There are 47 instances of public properties within sniff classes. Public properties allow changing sniff behaviour by customising a ruleset by passing different types of values via the ruleset. VIP [uses](https://github.com/Automattic/VIP-Coding-Standards/blob/918b0ca0fe986ae58babd77c7ab5e0ff7a6f7eb5/.phpcs.xml.dist#L29) itself to adjust how a WPCS sniff runs.

However, I suspect that some of the instances are NOT meant to be changed - whitelisted Batcache params, restricted constant names and declarations, etc.

## Describe the solution you'd like

Audit the uses and convert to `private` where suitable. Document the rest on a [wiki page](https://github.com/Automattic/VIP-Coding-Standards/wiki/Custom-properties-for-VIPCS-Sniffs).

I'll create a linked list of the 47 instances, possibly along with who added them, to check if they are meant to be public or not.

For those that are meant to be changeable, then a better approach for some cases is to have a private default list of values, and then a public custom list, and the two lists merged together - that way, the custom rulesets don't need to also add in the default values as well.

## Additional context
Note that this would technically be a breaking change, since it is possible that someone was already making use of these unintentional public properties in their own rulesets. As such, this would require a bump from `0.y.z` to `0.y+1.0`, or a normal major release if `1.0.0` has been released in the meantime.

贡献指南

打开贡献指南

调研方向

检查 sniff 类中的 47 个 public 属性,从 .phpcs.xml.dist 中的 VIP override 开始,并在可用时检查实例的链表。对于每个属性,确定其 intended 状态是 configurable 还是 private,并将 configurable 属性的指导原则记录在 wiki 页面 Custom properties for VIPCS Sniffs 上。完成的标准是:合适的属性为 private,其余属性已记录文档,并且已处理 breaking change release 的影响。

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
documentation, tooling
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。