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

Developed preference xml inspections #578

Conversation

Iamwade
Copy link
Collaborator

@Iamwade Iamwade commented Apr 23, 2021

Description (*)
Added inspection to the di.xml file for preference.
The inspection is performed for preference attributes "for" and "type".
If the class in the specified path for these attributes does not exist, then the corresponding warning will be displayed
image

image

Fixed Issues (if relevant)

  1. Fixes Develop preference xml inspections #566

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with integration/functional tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@Iamwade
Copy link
Collaborator Author

Iamwade commented Apr 23, 2021

Waiting for #577

@Iamwade
Copy link
Collaborator Author

Iamwade commented Apr 28, 2021

Waiting for #582

@Iamwade Iamwade marked this pull request as ready for review April 30, 2021 16:11
Copy link
Collaborator

@bohdan-harniuk bohdan-harniuk left a comment

Choose a reason for hiding this comment

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

Hello, @Iamwade! I've left few comments in your PR. Please, check them.

<li>existence of attribute values</li>
</ul>
</body>
</html>
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Iamwade, please add an empty line in the and of the file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!

<html>
<body>
<p>
Validates classes and interfaces for attributes "for" and the "type" for the "preference" tag
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Iamwade, please remove extra space after the first "for". And if you can, please, formulate this sentence differently. For now, it is hard to read.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!

@@ -219,6 +219,13 @@
enabledByDefault="true" level="WARNING"
implementationClass="com.magento.idea.magento2plugin.inspections.xml.InvalidDependencyInjectionTypeInspection"/>

<localInspection language="XML" groupPath="XML"
shortName="PreferenceXmlInspections"
displayName="Inspection the existence of PHP classes for attributes in the preference"
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Iamwade, please extract displayName attribute value to the magento2.inspection bundle and reference it from this context:

Suggested change
displayName="Inspection the existence of PHP classes for attributes in the preference"
bundle="magento2.inspection" key="inspection.displayName.PreferenceXmlInspections"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!

<localInspection language="XML" groupPath="XML"
shortName="PreferenceXmlInspections"
displayName="Inspection the existence of PHP classes for attributes in the preference"
groupName="Magento 2"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
groupName="Magento 2"
groupBundle="magento2.inspection" groupKey="inspection.group.name"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!


private static final String ARGUMENT_VALUE_IS_EMPTY =
"inspection.error.idAttributeCanNotBeEmpty";

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Iamwade, do we really need extra empty lines after each constant property?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!

* Test for an error for the "type" attribute because it is empty.
* <preference for="" type="Foo\Bar\Model\Logger"/>
*/
public void testAttrArgForValuesIsEmpty() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Iamwade, sorry, but I cannot understand this...you are testing type attribute, but method annotation, description, name and test data file name says that you are testing For attribute. Could you check it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!


final String typeAttrIsEmptyMessage = inspectionBundle.message(
ARGUMENT_VALUE_IS_EMPTY,
ModuleDiXml.PREFERENCE_ATTR_FOR
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Iamwade, check it, please. (the reason the same as for previous methods)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!

@Iamwade
Copy link
Collaborator Author

Iamwade commented Apr 30, 2021

@bohdan-harniuk
Thank you for the code review, the described points have been fixed

Copy link
Collaborator

@bohdan-harniuk bohdan-harniuk left a comment

Choose a reason for hiding this comment

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

Hello, @Iamwade! I've left one more comment in your PR. Please, check it.

bohdan-harniuk
bohdan-harniuk previously approved these changes May 3, 2021
Copy link
Collaborator

@bohdan-harniuk bohdan-harniuk left a comment

Choose a reason for hiding this comment

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

@Iamwade, thank you for your work here!

@VitaliyBoyko VitaliyBoyko self-requested a review May 4, 2021 07:12
@VitaliyBoyko VitaliyBoyko self-assigned this May 4, 2021
Copy link
Contributor

@VitaliyBoyko VitaliyBoyko left a comment

Choose a reason for hiding this comment

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

Getting an error when removing the attribute value

Screenshot 2021-05-04 at 15 06 40

@Iamwade Iamwade force-pushed the developed-preference-xml-inspections branch from 454c97a to 084b53a Compare May 5, 2021 12:27
@Iamwade
Copy link
Collaborator Author

Iamwade commented May 5, 2021

@VitaliyBoyko a bug when removing an attribute value has been fixed. In the process of fixing this error, I found this error for the tag in the file
https://github.com/magento/magento2-phpstorm-plugin/blob/4.0.0-develop/src/com/magento/idea/magento2plugin/inspections/xml/InvalidDependencyInjectionTypeInspection.java
and I fixed it too.
Please review.

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.

Develop preference xml inspections
4 participants