Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new upstream sniffs #240

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

dingo-d
Copy link
Member

@dingo-d dingo-d commented Nov 17, 2019

Detached the two new sniffs from #239 and add them here.

Short ternary addition seems like it promotes best practices, and escaped not translated sniff seems like a useful sniff for themes to have.

@dingo-d dingo-d added this to the 0.2.1 milestone Nov 17, 2019
@dingo-d dingo-d requested a review from jrfnl November 17, 2019 15:50
@dingo-d dingo-d self-assigned this Nov 17, 2019
@dingo-d dingo-d force-pushed the feature/add-new-upstream-sniffs branch from 58a1a89 to c445642 Compare November 17, 2019 16:09
Copy link

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of things:

  1. As this repo supposedly uses SemVer, adding new sniffs should not be done in a patch release. These should be milestoned for the next minor or this upcoming release should become 0.3.0.
  2. EscapedNotTranslated is an obvious one as it alerts people to a code error, so I don't think there can be any discussion over it, so 👍 from me.
  3. DisallowShortTernary should probably be pulled separately and discussed in the Theme Review meeting.
    There are good reasons to forbid it for Core, but I'm not sure this should be forbidden for themes and I can imagine this could yield a lot of discussion.
    Possibly this should be downgraded to a warning for TRT with a custom message.
  4. There is one more new sniff WordPress.DateTime.CurrentTimeTimestamp and a second group in the WordPress.DateTime.RestrictedFunctions sniff.
    Any particular reason why those haven't be pulled (either in this PR or in a separate one) ?
    As themes will often display post/comment dates etc, I imagine them doing that with the correct timezone and such would be helpful.

I presume you didn't pull the PostTypeSlug one as registering post types is not allowed in themes ? Or am I remembering that wrong ?

@dingo-d dingo-d modified the milestones: 0.2.1, 0.2.x/0.3.0 Next Nov 17, 2019
@dingo-d
Copy link
Member Author

dingo-d commented Nov 17, 2019

Valid points! Will put this for next major version milestone 👍

Good point about shorthand ternary. Tbh I almost never used it (I use null coalesce most of the time), and from what I've seen by searching the theme directory (link), they are using it wrong - checking the existence of key in array with short ternary will either throw an error or true instead of the key (which I think is what the authors intended).
So adding it as a warning might be a good thing, but could also confuse reviewers who aren't on good terms with PHP.
Definitely one for discussion (I'll open an issue for it 👍)

There is one more new sniff WordPress.DateTime.CurrentTimeTimestamp and a second group in the WordPress.DateTime.RestrictedFunctions sniff.
Any particular reason why those haven't be pulled (either in this PR or in a separate one)

The first one I think I wasn't 100% sure if this is allowed in a theme (from your comment it looks like it has a merit of being in the theme).
The second group I didn't add because you mentioned it in the comment in the PR

The WordPress.DateTime.RestrictedFunctions sniff contains a second function group, so we need to make sure that one is not (yet) included.

So I didn't include it 😄

I presume you didn't pull the PostTypeSlug one as registering post types is not allowed in themes ? Or am I remembering that wrong ?

Correct 👍 Themes cannot register post types (this is covered by the ForbiddenFunctions sniff).

@jrfnl
Copy link

jrfnl commented Nov 17, 2019

The second group I didn't add because you mentioned it in the comment in the PR

It didn't belong in the other PR as it would change the functionality in TRTCS, while that PR was just about updating the WPCS dependency.

For this PR, which is intended to change the TRTCS functionality, it would be a good fit.

@jrfnl
Copy link

jrfnl commented Nov 17, 2019

Basically, it's about decision points:
For the other PR the decision was supposed to be "should we update the minimum WPCS version to 2.2.0 ?".

By having the extra datetime check in that same PR, that PR would be asking for two decisions: "should we update the minimum WPCS version to 2.2.0 ?" AND "should this new check be added to TRTCS ?"

As those are two different decisions which may have different answers, they shouldn't be in the same PR.

To bring the point home: the first decision is something which could go into a patch version, the second decision means that PR would have to go into the next minor (as discussed above).

Does that help ?

@dingo-d
Copy link
Member Author

dingo-d commented Nov 17, 2019

Yes, it makes sense. I've moved the milestone so we can work on this after 0.2.1 is released 🙂

@dingo-d dingo-d force-pushed the feature/add-new-upstream-sniffs branch from c445642 to 5bcd7bf Compare February 20, 2021 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants