Skip to content

✨ Throw error instead of warning #87

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

Merged
merged 1 commit into from
Dec 22, 2019
Merged
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
8 changes: 4 additions & 4 deletions SymfonyCustom/Sniffs/Formatting/StrictComparisonSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PHP_CodeSniffer\Sniffs\Sniff;

/**
* Throws warning if == or != are use
* Throws error if == or != are use
*/
class StrictComparisonSniff implements Sniff
{
Expand Down Expand Up @@ -36,9 +36,9 @@ public function process(File $phpcsFile, $stackPtr): void
{
$tokens = $phpcsFile->getTokens();

// This warning is fixable, but it's too dangerous to add automatically fixer
$phpcsFile->addWarning(
'The %s comparator is not recommended, use %s instead',
// This error is fixable, but it's too dangerous to add automatically fixer
$phpcsFile->addError(
'The %s comparator is forbidden, use %s instead',
$stackPtr,
'NotStrict',
[
Expand Down
10 changes: 5 additions & 5 deletions SymfonyCustom/Tests/Formatting/StrictComparisonUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ class StrictComparisonUnitTest extends AbstractSniffUnitTest
*/
protected function getErrorList(): array
{
return [];
return [
3 => 1,
5 => 1,
];
}

/**
* @return array
*/
protected function getWarningList(): array
{
return [
3 => 1,
5 => 1,
];
return [];
}
}
14 changes: 9 additions & 5 deletions SymfonyCustom/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,23 @@

<!-- Disallow -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.CodeAnalysis.AssignmentInCondition"/>
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
<rule ref="Generic.CodeAnalysis.AssignmentInCondition">
<type>error</type>
</rule>
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement">
<type>error</type>
</rule>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.PHP.BacktickOperator"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="PEAR.Commenting.InlineComment"/>
<rule ref="Squiz.PHP.CommentedOutCode"/>
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
<rule ref="Squiz.PHP.Eval"/>
<rule ref="Squiz.PHP.NonExecutableCode"/>
<rule ref="Squiz.PHP.NonExecutableCode">
<type>error</type>
</rule>
<rule ref="Squiz.Operators.ValidLogicalOperators"/>

<!-- Others -->
Expand Down