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

Ruleset: hard deprecate support for standards called "Internal" #893

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,13 @@ private function expandSniffDirectory($directory, $depth=0)
*/
private function expandRulesetReference($ref, $rulesetDir, $depth=0)
{
// Naming an (external) standard "Internal" is deprecated.
if (strtolower($ref) === 'internal') {
$message = 'The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL;
Copy link
Contributor

Choose a reason for hiding this comment

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

I tried to remove one use of "internal" from the message to avoid repeating it three times. I came up with the following suggestion:

Suggested change
$message = 'The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL;
$message = 'The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not it.'.PHP_EOL;

What do you think? This is just a nitpick. Feel free to ignore it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@rodrigoprimo The suggested change is a grammatical error. Want to have another look ?

$message .= 'Contact the maintainer of the standard to fix this.';
$this->msgCache->add($message, MessageCollector::DEPRECATED);
}

// Ignore internal sniffs codes as they are used to only
// hide and change internal messages.
if (substr($ref, 0, 9) === 'Internal.') {
Expand Down
5 changes: 5 additions & 0 deletions tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public function testInternalRefDoesNotGetExpanded()
*/
public function testInternalStandardDoesGetExpanded()
{
$message = 'DEPRECATED: The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL;
$message .= 'Contact the maintainer of the standard to fix this.'.PHP_EOL.PHP_EOL;

$this->expectOutputString($message);

// Set up the ruleset.
$standard = __DIR__.'/ExpandRulesetReferenceInternalStandardTest.xml';
$config = new ConfigDouble(["--standard=$standard"]);
Expand Down