Remove duplicate and sort values in .XML files

Issue #2189 resolved
Olek Tymchenko created an issue

Hi Scott,
I’m working on a project where we have to modify .xml files manually (profiles, custom labels, perm sets) and due to the big size of files (more than 10k lines) we are making mistakes and adding the same permissions, label values etc. double or triple.
Salesforce usually, do not throw any warning or error and basically deployment is successful, but later last permission has higher priority and override previous ones (like in CSS).
Is any chance that IC2 will have the ability to find duplicates and sort .xml files like you do for the manifest/package.xml ?

Comments (4)

  1. Scott Wells repo owner

    Hi. Thanks for the suggestion. What you’re saying certainly makes sense, and there are other languages with code inspections that report duplicates as errors, e.g., properties files and JSON. In this case the notion of “duplicate” is a bit more specific to the document type, so it would likely require a dedicated code inspection to find those. I’ll keep that on the work list via this issue.

    As for sorting, I think you may be able to do that already using XML code style arrangement settings, e.g.:

    Notice the second rule that I added to say that all tags should be arranged according to tag name in ascending order, and I also changed the value for Force rearrange to Always so that it happens on all reformats of XML files.

    So configured, reformatting an XML file will result in an ordered arrangement of that file’s tags (hierarchically scoped, of course). I’ll be curious to hear whether that takes care of the sorting part of your request.

  2. Scott Wells repo owner

    Well, in this case I’m just trying to provide a response to part of the request based on existing JetBrains IDE features vs. trying to compare what is already available to what a custom implementation might be. Assuming this works for you, I probably won’t consider adding support for sorting of arbitrary XML files to IC2 vs. the special handling for package.xml files where there are some special considerations even for sorting. Also note that you can check your code style into version control so that such a configuration only has to happen once and can be shared with all team members.

    Duplicate entry detection and reporting is a different story because it’s something that, to my knowledge at least, cannot be done with existing JetBrains IDE features. That seems like a good candidate for an IC2 enhancement specific to those types of files.

  3. Scott Wells repo owner

    Resolving as sorting is already available in the base IDE features and generalized duplicate detection is likely out of scope.

  4. Log in to comment