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

Feature suggestion: new sniff for detecting brand name or text string #302

Closed
ernilambar opened this issue Dec 27, 2023 · 1 comment
Closed

Comments

@ernilambar
Copy link

ernilambar commented Dec 27, 2023

Is your feature request related to a problem?

This could be probably generalization of WordPress.WP.CapitalPDangit. Like we can use it for any brand name or string like WooCommerce, Github, etc

Describe the solution you'd like

Inspired from WordPress/WordPress-Coding-Standards#1945

  • Sniff should be customizable
  • It would take strings/regex
  • Setting for target checks. Eg, ignoring detection in T_COMMENT

Use cases:

  • Detect string like WooCommerce, Github, etc
  • Detect #https?://(localhost|127.0.0.1)# regex
@ernilambar ernilambar changed the title Feature suggestion: new sniff for detecting brand names or given string Feature suggestion: new sniff for detecting brand name or text string Dec 27, 2023
@jrfnl
Copy link
Member

jrfnl commented Dec 27, 2023

Thank you for the suggestion, but I'm not inclined to accept this feature request.

To detect this, all tokens which can contain text should be examined. However, whether something should be flagged, or not, is highly dependent on the context.
Think:

$array = [
    'woocommerce' => 'array keys should not be flagged as changing those breaks other code',
];

// And what about callbacks ? Should not be flagged as function names have their own naming conventions.
array_map('github_callback', $array);

// But hey, we do want to flag this:
printf( 'sentence containing %s keyword', 'woocommerce');

// Now what about a comment containing github ?
// But we don't want to flag it in a URL: https://github.com/org/package/blob/master/woocommerce-interface.php

In other words, a "generic" sniff for such a feature would be a nightmare to maintain and support as code can be written in lots of different ways, so there will always be more exceptions to take into account and some codebases will want the exception, while others won't want it.

@jrfnl jrfnl closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants