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

Create a sniff to safeguard that PHPCS annotations aren't being abused #68

Open
jrfnl opened this issue Jan 22, 2018 · 1 comment
Open

Comments

@jrfnl
Copy link
Collaborator

jrfnl commented Jan 22, 2018

As previously discussed with @moorscode, this sniff should:

  1. Check that only the new PHPCS annotations are used and forbid use of the old annotations.
    I.e. the following will no longer be allowed:
    • @codingStandardsIgnoreFile
    • @codingStandardsIgnoreStart / @codingStandardsIgnoreEnd
    • @codingStandardsIgnoreLine
    • @codingStandardsChangeSetting
  2. Detect & forbid blanket PHPCS ignores.
    The new annotations allow to indicate which Standard/Category/Sniff/Errorcode should be temporarily ignored/disabled.
    • Sniff/Errorcode ignore/disables will be allowed. Errorcode based ones are preferred.
    • Standard/Category ignores/disables will not be allowed.
    • File ignores will not be allowed. These should be done from within the ruleset and documented there.
  3. All temporary disables should be accompanied by a (re-) enable.
  4. All ignores/disables should be accompanied by a reason for the ignore/disable.

This sniff will only be able to work when PHPCS is run with --ignore-annotations as otherwise errors on annotation tokens will be, well, ignored (default behaviour).

This means a secondary PHPCS run will be added to the Travis script if & when this sniff has been added to YoastCS and a plugin upgrades to the YoastCS version which includes it. This secondary run will only check against this particular sniff.

@moorscode In your opinion, does this summarize correctly what we discussed ?

Refs:

@jrfnl jrfnl self-assigned this Jan 22, 2018
@moorscode moorscode changed the title Create a new sniff to safeguard that PHPCS annotations aren't being abused Create a sniff to safeguard that PHPCS annotations aren't being abused Feb 10, 2018
@moorscode moorscode added this to the Future release milestone Oct 24, 2018
@jrfnl
Copy link
Collaborator Author

jrfnl commented Sep 22, 2023

Maybe a ticket should be opened upstream about the fact that lines which only contain ignore annotations will never show an error/warning. (not even for the indent being wrong)

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