-
Notifications
You must be signed in to change notification settings - Fork 160
AC-663 PHPCS classes test #274
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
AC-663 PHPCS classes test #274
Conversation
…into AC-663_phpcs-ClassesTest
</field> | ||
<field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" canRestore="1"> | ||
<label>New Order Status</label> | ||
<source_model>Sales\MODEL\Config\Source\Order\Status\NewStatus</source_model> |
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.
How about this line? Should it work?
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.
@jcuerdo is not in the Magento
namespace, thus it is ignored
} | ||
if ($testFile === 'ClassesConfigurationUnitTest.2.xml') { | ||
return [ | ||
22 => 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.
In lines 22 and 42 there are no classes...
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.
@jcuerdo sniffer returns the position of the opening tag where the issue happens
$classes = $this->getXmlNode( | ||
$xml, | ||
' | ||
/config//resource_adapter | /config/*[not(name()="sections")]//class[not(ancestor::observers)] |
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 regexp must be updated almost certainly, as I think some of these paths are no longer accurate. Could you please check them out @sivaschenko ?
</field> | ||
<field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" canRestore="1"> | ||
<label>New Order Status</label> | ||
<source_model>Sales\MODEL\Config\Source\Order\Status\NewStatus</source_model> |
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.
@jcuerdo is not in the Magento
namespace, thus it is ignored
} | ||
if ($testFile === 'ClassesConfigurationUnitTest.2.xml') { | ||
return [ | ||
22 => 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.
@jcuerdo sniffer returns the position of the opening tag where the issue happens
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.
Thanks for the PR @svera ! Please see my review comments
Magento2/Sniffs/Legacy/ClassReferencesInConfigurationFilesSniff.php
Outdated
Show resolved
Hide resolved
Magento2/Sniffs/Legacy/ClassReferencesInConfigurationFilesSniff.php
Outdated
Show resolved
Hide resolved
Magento2/Sniffs/Legacy/ClassReferencesInConfigurationFilesSniff.php
Outdated
Show resolved
Hide resolved
Magento2/Sniffs/Legacy/ClassReferencesInConfigurationFilesSniff.php
Outdated
Show resolved
Hide resolved
Magento2/Sniffs/Legacy/ClassReferencesInConfigurationFilesSniff.php
Outdated
Show resolved
Hide resolved
…f.php Co-authored-by: Sergii Ivashchenko <[email protected]>
…f.php Co-authored-by: Sergii Ivashchenko <[email protected]>
Magento2/Sniffs/Legacy/ClassReferencesInConfigurationFilesSniff.php
Outdated
Show resolved
Hide resolved
Magento2/Sniffs/Legacy/ClassReferencesInConfigurationFilesSniff.php
Outdated
Show resolved
Hide resolved
@@ -148,6 +148,14 @@ | |||
<exclude-pattern>*\.xml$</exclude-pattern> | |||
<exclude-pattern>*\.js$</exclude-pattern> | |||
</rule> | |||
<rule ref="Magento2.Legacy.ClassReferencesInConfigurationFiles"> | |||
<include-pattern>*\/etc/*.xml$</include-pattern> |
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.
Layout files are tested in this sniff as well
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.
@sivaschenko there are also checks which involve references to classes in layouts, look at collectClassesInLayout()
. Maybe we should rename this sniff to ClassReferencesInXMLFilesSniff
?
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 think the naming is fine. Should we add the include pattern for layout files?
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've removed layout files check from sniff, so I guess we no longer need to include its pattern here @sivaschenko
…f.php Co-authored-by: Sergii Ivashchenko <[email protected]>
{ | ||
return $this->getValuesFromXmlTagAttribute( | ||
$xml, | ||
'/layout//@module', |
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.
@sivaschenko I see a lot of occurrences of <page layout="...
but none of <layout>... module="">
which are the ones we are looking for at the moment. Are these also outdated?
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.
yes, this check can be removed as well
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.
Removed as talked offline @sivaschenko
Magento2/Sniffs/Legacy/ClassReferencesInConfigurationFilesSniff.php
Outdated
Show resolved
Hide resolved
…f.php Co-authored-by: Jorge Cuerdo Álvarez <[email protected]>
@magento import pr to magento-commerce/magento-coding-standard |
@svera the Pull Request is successfully imported. |
This second part of AC-663 is focused on checking that all references to classes in
xml
files underetc
follows PSR standards.