-
Notifications
You must be signed in to change notification settings - Fork 105
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
#27 [Inspection] Observer declaration check for duplicates #59
#27 [Inspection] Observer declaration check for duplicates #59
Conversation
…hpstorm-plugin into observer-declaration-check � Conflicts: � resources/META-INF/plugin.xml
…hpstorm-plugin into observer-declaration-check
src/com/magento/idea/magento2plugin/inspections/xml/ObserverDeclarationInspection.java
Show resolved
Hide resolved
src/com/magento/idea/magento2plugin/inspections/xml/ObserverDeclarationInspection.java
Show resolved
Hide resolved
return new XmlElementVisitor() { | ||
private final String moduleXmlFileName = ModuleXml.getInstance().getFileName(); | ||
private static final String eventsXmlFileName = "events.xml";//todo: move to separate file as done to ModuleXml | ||
private static final String duplicatedObserverNameSameFileProblemDescription = "Observer name already used in this file. For more details see Inspection Description."; |
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.
The observer name already used in this file. For more details see Inspection Description.
private static final String eventsXmlFileName = "events.xml";//todo: move to separate file as done to ModuleXml | ||
private static final String duplicatedObserverNameSameFileProblemDescription = "Observer name already used in this file. For more details see Inspection Description."; | ||
private static final String duplicatedObserverNameProblemDescription = | ||
"Observer name \"%s\" for event \"%s\" is already used in the module \"%s\" (%s scope). For more details see Inspection Description."; |
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.
The observer name...
One more thing. Don't forget to update CHANGELOG.md with the new functionality. |
Hi @VitaliyBoyko, |
src/com/magento/idea/magento2plugin/inspections/xml/ObserverDeclarationInspection.java
Outdated
Show resolved
Hide resolved
Hi @VitaliyBoyko, |
Description
This PR adds a new code inspection to avoid accidentally overriding an observer.
This PR solves next issues
More details
ℹ️ The Observer Inspections adds warnings with the following information
1. Observer name already used in the same file

2. Observer name already used in the scope of other modules
(see screenshot from #3)
3. Information about the duplicated name scope:
Vendor_Module/etc
,Vendor_Module/etc/adminhtml
orVendor_Module/etc/frontend
4. 🙅♂ No warning for the disabled observer

5. 📖Details of why such situation occurs and how to handle it
