Skip to content

Update rule names for better messaging #328

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
Nov 9, 2021
Merged
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
30 changes: 15 additions & 15 deletions Magento2/Sniffs/Annotation/MethodArgumentsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ private function validateParameterAnnotationForArgumentExists(
$phpcsFile->addError(
'{@inheritdoc} does not import parameter annotation',
$stackPtr,
'MethodArguments'
'InheritDoc'
);
} elseif ($this->validateCommentBlockExists($phpcsFile, $previousCommentClosePtr, $stackPtr)
&& !$inheritdocAnnotationWithoutBracesExists
) {
$phpcsFile->addError(
'Missing @param for argument in method annotation',
$stackPtr,
'MethodArguments'
'ParamMissing'
);
}
}
Expand All @@ -260,13 +260,13 @@ private function validateCommentBlockDoesnotHaveExtraParameterAnnotation(
$phpcsFile->addError(
'Extra @param found in method annotation',
$stackPtr,
'MethodArguments'
'ExtraParam'
);
} elseif ($argumentsCount > 0 && $argumentsCount != $parametersCount && $parametersCount != 0) {
$phpcsFile->addError(
'@param is not found for one or more params in method annotation',
$stackPtr,
'MethodArguments'
'ParamMissing'
);
}
}
Expand All @@ -290,7 +290,7 @@ private function validateArgumentNameInParameterAnnotationExists(
$parameterNames = $this->getMethodParameters($paramDefinitions);
if (!in_array($methodArguments[$ptr], $parameterNames)) {
$error = $methodArguments[$ptr] . ' parameter is missing in method annotation';
$phpcsFile->addError($error, $stackPtr, 'MethodArguments');
$phpcsFile->addError($error, $stackPtr, 'ArgumentMissing');
}
}

Expand All @@ -314,7 +314,7 @@ private function validateParameterPresentInMethodSignature(
$phpcsFile->addError(
$paramDefinitionsArguments . ' parameter is missing in method arguments signature',
$paramPointers[$ptr],
'MethodArguments'
'ArgumentMissing'
);
}
}
Expand Down Expand Up @@ -343,7 +343,7 @@ private function validateParameterOrderIsCorrect(
$phpcsFile->addError(
$methodArguments[$ptr] . ' parameter is not in order',
$paramPointers[$ptr],
'MethodArguments'
'ParamOrder'
);
}
}
Expand Down Expand Up @@ -386,7 +386,7 @@ private function validateDuplicateAnnotationDoesnotExists(
$phpcsFile->addError(
$value . ' duplicate found in method annotation',
$stackPtr,
'MethodArguments'
'DuplicateParam'
);
}
}
Expand All @@ -413,15 +413,15 @@ private function validateParameterAnnotationFormatIsCorrect(
$phpcsFile->addError(
'Missing both type and parameter',
$paramPointers[$ptr],
'MethodArguments'
'Malformed'
);
break;
case 1:
if (preg_match('/^\$.*/', $paramDefinitions[0])) {
$phpcsFile->addError(
'Type is not specified',
$paramPointers[$ptr],
'MethodArguments'
'NoTypeSpecified'
);
}
break;
Expand All @@ -430,7 +430,7 @@ private function validateParameterAnnotationFormatIsCorrect(
$phpcsFile->addError(
$paramDefinitions[0] . ' is not a valid PHP type',
$paramPointers[$ptr],
'MethodArguments'
'NotValidType'
);
}
$this->validateParameterPresentInMethodSignature(
Expand All @@ -446,13 +446,13 @@ private function validateParameterAnnotationFormatIsCorrect(
$phpcsFile->addError(
'Type is not specified',
$paramPointers[$ptr],
'MethodArguments'
'NoTypeSpecified'
);
if ($this->isInvalidType($paramDefinitions[0])) {
$phpcsFile->addError(
$paramDefinitions[0] . ' is not a valid PHP type',
$paramPointers[$ptr],
'MethodArguments'
'NotValidType'
);
}
}
Expand Down Expand Up @@ -552,7 +552,7 @@ public function process(File $phpcsFile, $stackPtr)
$previousCommentClosePtr = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, $stackPtr - 1, 0);
if ($previousCommentClosePtr && $previousCommentOpenPtr) {
if (!$this->validateCommentBlockExists($phpcsFile, $previousCommentClosePtr, $stackPtr)) {
$phpcsFile->addError('Comment block is missing', $stackPtr, 'MethodArguments');
$phpcsFile->addError('Comment block is missing', $stackPtr, 'NoCommentBlock');
return;
}
} else {
Expand Down Expand Up @@ -636,7 +636,7 @@ private function validateFormattingConsistency(
$phpcsFile->addError(
'Method arguments visual alignment must be consistent',
$paramPointers[0],
'MethodArguments'
'VisualAlignment'
);
}
}
Expand Down