-
Notifications
You must be signed in to change notification settings - Fork 159
#58 : Implement sniff for class properties PHPDoc formatting #140
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
#58 : Implement sniff for class properties PHPDoc formatting #140
Conversation
Looking at failed Travis and see that sniff produces false positive findings, for example it should not be triggered for method declaration. |
Hello @lenaorobei , |
@konarshankar07 please cover also cases with meaningless description. Examples:
Method for this check already exists https://github.com/magento/magento-coding-standard/blob/develop/Magento2/Sniffs/Commenting/PHPDocFormattingValidator.php#L58 |
public function getWarningList() | ||
{ | ||
return [ | ||
12 => 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should detect on line 13.
private $_multipleClassAttribute = ''; | ||
|
||
private $_missingDocBlockClassAttribute = ''; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add here positive scenarios as well. Some examples with correctly formatted blocks.
Hello @lenaorobei , |
@konarshankar07, yes. The idea behind this is that |
Hello @lenaorobei , |
Hi @konarshankar07, sure. This sniff is not just about formatting. As per our conversation, please use |
Magento2/Tests/Commenting/ClassPropertyPHPDocFormattingUnitTest.inc
Outdated
Show resolved
Hide resolved
Magento2/Tests/Commenting/ClassPropertyPHPDocFormattingUnitTest.inc
Outdated
Show resolved
Hide resolved
Hello @lenaorobei , |
@konarshankar07 I will test it against Magento codebase and will get back to you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I run against Magento 2 codebase and discovered some false positives:
/**
* @var \Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface|
* \PHPUnit_Framework_MockObject_MockObject
*/
private $dataProviderMock;
Expected: ✅ Actual: ❌
In \Magento\Ui\Component\MassAction\Columns\Column
issue detected on line 31, but should be on 22 and 29.
File \Magento\Eav\Model\AttributeDataFactory
caused An error occurred during processing; checking has been aborted. The error message was: Undefined index: comment_opener in magento-coding-standard/Magento2/Sniffs/Commenting/ClassPropertyPHPDocFormattingSniff.php on | | line 65
/**
* @var ArrayUtils|\PHPUnit_Framework_MockObject_MockObject
*/
protected $arrayUtils;
Expected: ✅ Actual: ❌
Please address found issues and see some suggestions.
Magento2/Sniffs/Commenting/ClassPropertyPHPDocFormattingSniff.php
Outdated
Show resolved
Hide resolved
Magento2/Sniffs/Commenting/ClassPropertyPHPDocFormattingSniff.php
Outdated
Show resolved
Hide resolved
Magento2/Sniffs/Commenting/ClassPropertyPHPDocFormattingSniff.php
Outdated
Show resolved
Hide resolved
Magento2/Sniffs/Commenting/ClassPropertyPHPDocFormattingSniff.php
Outdated
Show resolved
Hide resolved
Magento2/Sniffs/Commenting/ClassPropertyPHPDocFormattingSniff.php
Outdated
Show resolved
Hide resolved
Thanks for the feedback |
…standard into implement-sniff-for-class-properties--task-58
@konarshankar07 thank you for the pull request! Would you be able to resolve the test failures? |
Hello @sivaschenko |
@sivaschenko ready for review |
return; | ||
} | ||
$error = 'Short description duplicates class property name.'; | ||
$phpcsFile->addWarning($error, $isShortDescriptionAfterVar, 'AlreadyHaveMeaningFulNameVar'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct camel casing: AlreadyHaveMeaningfulNameVar
return; | ||
} | ||
$error = 'Short description duplicates class property name.'; | ||
$phpcsFile->addWarning($error, $isShortDescriptionPreviousVar, 'AlreadyHaveMeaningFulNameVar'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct camel casing: AlreadyHaveMeaningfulNameVar
null, | ||
false | ||
); | ||
if ($this->PHPDocFormattingValidator->providesMeaning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
block can be extracted into a separate method, as it basically repeats is the same as the check done for checking description before @var
tag. This way, we reduce repetition and also function size, as processMemeberSize()
is quite big, helping readability along the way
@magento import pr to magento-commerce/magento-coding-standard |
@svera the pull request successfully imported. |
AC-99: Update Third Party library: jquery.tabs
This PR added new rule for class properties for PHP Doc block
Fixed #58