Apex annotations and inspections

Issue #24 resolved
Scott Wells repo owner created an issue

Add annotations and inspections for the most common types of errors:

  • Unresolved references - if unresolved reference to a type, look for potential matches with namespace qualifications and offer a quick fix option to qualify the namespace
  • Duplicate declarations
  • Unused declarations - offer a quick fix to delete the declaration
  • Data type mismatches - offer a quick fix to add a cast

Comments (11)

  1. Willem Mulder

    This would be great!

    Especially dead code detection could would really help me to clean up ever growing orgs :-)

  2. Scott Wells reporter
    • changed version to 2.0
    • edited description

    I've already implemented Unresolved References and Unused Declarations for 2.0. I'll be adding the other two as well, hopefully before 2.0 ships but if not very shortly thereafter.

  3. Willem Mulder

    Great work!

    I've not had the chance to check it out, but if there could be a high-level option: "Illuminated Cloud --> find unused code" that would be fantastic! Is that something you'd consider?

  4. Scott Wells reporter

    Willem, you can run these inspections in bulk as well. I've run the unused declaration inspection against the entire project and it lists all unused code. You can then remove all of it with a single button click, though I wouldn't recommend that. Some unused code can actually be used in other ways that aren't obvious to IC. For those you can use a comment to suppress the inspection for that statement, method, or type so that it won't be flagged again. Also, it doesn't currently perform transitive dependency analysis so after you delete a bunch of unused code, you may have peeled back another layer of code that was only ever called by that code. I do plan to add that at some point, but for an existing code base right now you need to run it a few times until you've purged all of the cruft.

  5. Willem Mulder


    You've gone even further than I hoped 👍 Thanks!

    Running it a few times is not a problem at all, and is actually a great way to walk through all the code layer by layer to see whether the code can really be removed.

  6. Scott Wells reporter

    Hah! That's seeing the silver lining! I actually do agree, though having run this inspection across a pretty significant code base and used it to shave off the dead ends (of which there were quite a few!), there were times I wished I'd just implemented transitive processing since it would have generally just "done the right thing".

    Anyway, all of the inspections will have the ability to be run en masse on any subset of the code base, and similar with the corresponding code intentions. Most of them will run on-the-fly as you're typing your code, but some are prohibitively expensive for on-the-fly processing so those will instead be run as an explicit activity. The primary current examples are the external static code analyzers I've already integrated such as PMD Apex and Lightning Lint.

    FYI, I'll be demoing all of this in SF next week at the Bay Area SDUG meeting and again at DF17.

  7. Scott Wells reporter

    IC2 ships with unresolvable reference, unused declaration, and illegal assignment code inspections. Resolving this more broad enhancement request as complete and will create additional stories for specific new inspections/intentions and enhancements to the existing ones.

  8. Log in to comment