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

Add magento/magento-coding-standard as a dependency to magento/magento2 #4

Closed
lenaorobei opened this issue Jan 11, 2019 · 9 comments
Closed
Assignees

Comments

@lenaorobei
Copy link
Contributor

lenaorobei commented Jan 11, 2019

Description

This unified coding standard will contain all Magento related sniffs, so there is no need to keep core sniffs under Magento 2 dev/tests/static folded.

Acceptance Criteria

  1. Sniffs are removed from Magento 2 dev/tests/static/framework/Magento folder.
  2. magento/magento-coding-standard depencency is added to the require-dev section of Magento 2 composer.json file.
  3. No duplicate findings detected by other static tools (eg: Magento\TestFramework\Utility\XssOutputValidatorTest covers the same as XssTemplateSniff, FinalImplementation Mess Detector rule and FinalImplementation sniff).
  4. Static build is green.

Additional information

Needs to be done after the first Magento Coding Standard release.

@schmengler
Copy link
Contributor

Magento\TestFramework\Utility\XssOutputValidator covers the same as XssTemplateSniff

are those static tests also going to be moved into this repository? More importantly, are they used for marketplace extensions?

@lenaorobei
Copy link
Contributor Author

lenaorobei commented Jan 25, 2019

@schmengler PHP CodeSniffer should became preferred tool for static checks. If its functionality is not enough (dynamic check, etc), we should consider using other approaches like Mess Detector or PHPUnit. For example, I rewrite FinalImplementation Mess Detector rule with FinalImplementation sniff because for this case PHP CodeSniffer is good enough.

More importantly, are they used for marketplace extensions?

Not yet, but in future we want to make all static tests (not only sniffs) consistent for Marketplace and core development

@schmengler
Copy link
Contributor

Sounds good. That means, Magento\TestFramework\Utility\XssOutputValidatorTest will be removed in favor of XssTemplateSniff, right?

@lenaorobei
Copy link
Contributor Author

@schmengler yes, that's right.

@orlangur
Copy link

@lenaorobei,

For example, I rewrite FinalImplementation Mess Detector rule with FinalImplementation sniff because for this case PHP CodeSniffer is good enough.

Well, you missed the Design part. That was the whole point. It has nothing to do with Php.

@lenaorobei lenaorobei self-assigned this Mar 25, 2019
@orlangur
Copy link

orlangur commented Apr 1, 2019

https://github.com/magento/magento2/blob/2.3-develop/composer.json#L88 this needs to be fixed a little bit: dev version of Magento must rely on dev version of coding standard so that we can introduce new rules, fix code and immediately enforce it.

Concrete version must be added during publication: https://github.com/magento/magento2/blob/2.3.1/composer.json#L99

Also, it would be really good to not introduce mess and use the same versioning as for other Magento components.

@lenaorobei
Copy link
Contributor Author

@orlangur thanks for your feedback, however I don't see any reasons to

use same versioning as for other Magento components

because Codings Standard is not a Magento component (module). New rules may be added to develop (master) branch and will cause static build failure. By following SemVer we will explicitly let our application know about braking changes.

Here is my proposal for Coding Standard versioning strategy. If you have any concerns regarding this do not hesitate to reflect them there magento/architecture#136

@lenaorobei
Copy link
Contributor Author

@orlangur
Copy link

orlangur commented Apr 9, 2019

@lenaorobei,

because Codings Standard is not a Magento component (module)

Which is pretty wrong.

New rules may be added to develop (master) branch and will cause static build failure. By following SemVer we will explicitly let our application know about braking changes.

Yep, this is what I was talking about and such use cases needed to be covered PRIOR to changes applied to main repo.

Here is my proposal for Coding Standard versioning strategy

Thanks, I'll share my thoughts that we don't need to reinvent the wheel and introduce ONE MORE versioning strategy. Will strive to visiting corresponding arch council meeting as well.

mmansoor-magento pushed a commit that referenced this issue Dec 3, 2020
…coding-standard-198

[Imported] Discourage local-FS-only methods
fredden added a commit to fredden/magento-coding-standard that referenced this issue May 24, 2021
    Fatal error: Uncaught TypeError: vsprintf(): Argument magento#2 ($values) must be of type array, int given in /srv/www/vendor/squizlabs/php_codesniffer/src/Files/File.php:1056
    Stack trace:
    #0 /srv/www/vendor/squizlabs/php_codesniffer/src/Files/File.php(1056): vsprintf('Direct throw of...', 531)
    magento#1 /srv/www/vendor/squizlabs/php_codesniffer/src/Files/File.php(706): PHP_CodeSniffer\Files\File->addMessage(false, 'Direct throw of...', 67, 4, 'FoundDirectThro...', 531, 8, false)
    magento#2 /srv/www/vendor/magento/magento-coding-standard/Magento2/Sniffs/Exceptions/DirectThrowSniff.php(48): PHP_CodeSniffer\Files\File->addWarning('Direct throw of...', 526, 'FoundDirectThro...', 531)
    magento#3 /srv/www/vendor/squizlabs/php_codesniffer/src/Files/File.php(498): Magento2\Sniffs\Exceptions\DirectThrowSniff->process(Object(PHP_CodeSniffer\Files\LocalFile), 526)
    magento#4 /srv/www/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
    #5 /srv/www/vendor/squizlabs/php_codesniffer/src/Runner.php(630): PHP_CodeSniffer\Files\LocalFile->process()
    magento#6 /srv/www/vendor/squizlabs/php_codesniffer/src/Runner.php(434): PHP_CodeSniffer\Runner->processFile(Object(PHP_CodeSniffer\Files\LocalFile))
    magento#7 /srv/www/vendor/squizlabs/php_codesniffer/src/Runner.php(114): PHP_CodeSniffer\Runner->run()
    magento#8 /srv/www/vendor/squizlabs/php_codesniffer/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
    magento#9 {main}
      thrown in /srv/www/vendor/squizlabs/php_codesniffer/src/Files/File.php on line 1056
fredden added a commit to fredden/magento-coding-standard that referenced this issue Sep 2, 2021
  PHP Fatal error:  Uncaught TypeError: strpos(): Argument magento#2 ($needle) must be of type string, null given in /srv/www/vendor/magento/magento-coding-standard/Magento2/Sniffs/Annotation/MethodArgumentsSniff.php:629
  Stack trace:
  #0 /srv/www/vendor/magento/magento-coding-standard/Magento2/Sniffs/Annotation/MethodArgumentsSniff.php(629): strpos('\\VendorName\\Mod...', NULL)
  magento#1 /srv/www/vendor/magento/magento-coding-standard/Magento2/Sniffs/Annotation/MethodArgumentsSniff.php(515): Magento2\Sniffs\Annotation\MethodArgumentsSniff->validateFormattingConsistency(Array, Array, Object(PHP_CodeSniffer\Files\LocalFile), Array)
  magento#2 /srv/www/vendor/magento/magento-coding-standard/Magento2/Sniffs/Annotation/MethodArgumentsSniff.php(600): Magento2\Sniffs\Annotation\MethodArgumentsSniff->validateMethodParameterAnnotations(385, Array, Array, Object(PHP_CodeSniffer\Files\LocalFile), Array, 356, 380)
  magento#3 /srv/www/vendor/squizlabs/php_codesniffer/src/Files/File.php(498): Magento2\Sniffs\Annotation\MethodArgumentsSniff->process(Object(PHP_CodeSniffer\Files\LocalFile), 385)
  magento#4 /srv/www/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
  #5 /srv/www/vendor/squizlabs/php_codesniffer/src/Runner.php(630): PHP_CodeSniffer\Files\LocalFile->process()
  magento#6 /srv/www/vendor/squizlabs/php_codesniffer/src/Runner.php(434): PHP_CodeSniffer\Runner->processFile(Object(PHP_CodeSniffer\Files\LocalFile))
  magento#7 /srv/www/vendor/squizlabs/php_codesniffer/src/Runner.php(114): PHP_CodeSniffer\Runner->run()
  magento#8 /srv/www/vendor/squizlabs/php_codesniffer/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
  magento#9 {main}
    thrown in /srv/www/vendor/magento/magento-coding-standard/Magento2/Sniffs/Annotation/MethodArgumentsSniff.php on line 629
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

No branches or pull requests

3 participants