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

Resolve issues with regex include and exclude patterns in Magento 2 ruleset.xml #486

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

gwharton
Copy link

See #485 for a detailed description of the issue.

These fixes makes the following assumptions and these will need to be verified by someone who knows why the rules were introduced in the first place and has more knowledge about phpcs and Magento than I do.

Magento2.Legacy.Layout
The existing rule seems to target files such as

  • anything/view/adminhtml/anything/.xml
  • anything/view/frontend/anything/.xml

I don't think thats right. I believe it should actually be targetting

  • anything/view/adminhtml/anything/anything.xml
  • anything/view/frontend/anything/anything.xml

The updated rule targets any xml file in any subfolder of a view/adminhtml, view/frontend or view/base folder. I think this was the intended target.

Magento2.Html.HtmlBinding
I believe the intention with this rule is to target any phtml file anywhere in the tree. The existing rule, as written, will target only files with the following paths

  • .phtml
  • somewhere/.phtml
  • somewhere/somewhere/.phtml

In addition to this, escaping the first forward slash, as in the previous example, breaks things even more under windows. The replacement rule removes the escaping of forward slash so it works under both Linux and Windows, and corrects the rule to target paths such as

  • something.phtml
  • somewhere/something.phtml
  • somewhere/somewhere/something.phtml

Magento2.Legacy.ClassReferencesInConfigurationFiles
I believe the intention with this rule is to target any xml file present in any etc folder, anywhere, but exclude wsdl.xml, wsdl2.xml and wsi.xml. There is no need to escape the leading forward slash, and by doing so, it stops the rule working under windows. The replacement rule removes the escaping of the first slash so it works under both Linux and Windows.

Magento2.Legacy.ModuleXML
Magento2.Legacy.DiConfig
Magento2.Legacy.WidgetXML
I believe the intention with these rules is to target any file named module.xml, widget.xml or di.xml, in any subfolder of the tree, but not the root. The existing rules escape the first forward slash, which results in the rule failing when running under windows. The rule is updated to remove the escaping so it works under both Linux and Windows.

QUESTION: Why were all these forward slashes escaped in the rules. Is there something/some system I am overlooking that requires it?

For more detailed analysis see issue #485

Tested under Ubuntu 24.04 and Windows 11/Cygwin

@gwharton
Copy link
Author

Let me know if you would prefer these 4 commits squashed into 1 to keep the history clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants