Skip to content

AC-664: Create phpcs static check for CodingStandardsIgnoreAnnotationUsageTest #257

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

Closed
wants to merge 6 commits into from

Conversation

loginesta
Copy link
Contributor

https://jira.corp.magento.com/browse/AC-664 Create phpcs static check for CodingStandardsIgnoreAnnotationUsageTest

…UsageTest

- Initial commit, copy the sniff across from magento repo
…UsageTest

- Add methods register() and process()
{
private const CODING_STANDARDS_IGNORE_FILE = '@codingStandardsIgnoreFile';

private const WARNING_CODE = self::CODING_STANDARDS_IGNORE_FILE . ' annotation must be avoided. ';
Copy link
Contributor

Choose a reason for hiding this comment

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

WARNING_CODE must be something like avoidAnnotation

{
return [];
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Newline missing

*/
public function getErrorList()
{
return [];
Copy link
Contributor

Choose a reason for hiding this comment

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

There must be an error at line 7, that's where @codingStandardsIgnoreFile is set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know, i set it up empty because was expecting complains on command line when running vendor/bin/phpunit.
Actually, it must be a warning.

public function register(): array
{
return [
T_OBJECT_OPERATOR
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure about this operator? I think you should be looking for T_ASPERAND (the @ char) or T_COMMENT

*/
public function process(File $phpcsFile, $stackPtr)
{
$lineContent = $phpcsFile->getTokensAsString($stackPtr, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't this way will work, try to do

php$tokens = $phpcsFile->getTokens();
    if (strpos($tokens[$stackPtr - 1]['content']) !== false) {
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gonna try both

@loginesta
Copy link
Contributor Author

This test cannot be moved to magento-coding-standard, since that’s not simply a phpunit question.
Cannot be tested via PHPCS. Closing this PR

@loginesta loginesta closed this Sep 6, 2021
@loginesta loginesta deleted the AC-664 branch September 6, 2021 11:09
magento-devops-reposync-svc pushed a commit that referenced this pull request Sep 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
AC-12715::Investigate the laminas composer dependencies upgrading to latest version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants