Inspection - Casting issue

Issue #1127 new
Jason Hardy created an issue

I'm just getting started with the tool. So far I'm impressed with it. I have found one annoying bit with the inspector though. I use a trigger factory context and it's not liking when I cast records inline.


I've got the casting right because I use this method in all of my bulk actions in the trigger factory. It's not a huge deal since I can just disable that particular rule; however, I thought I would report it.

You can reproduce this through any trigger context when you're looping through the triggered records:

For the task object, here's how it would be:

for (Task tsk : Trigger.New == null ? (List<Task>) Trigger.Old : Trigger.New) {
    //Process tasks in the loop

Comments (1)

  1. Scott Wells repo owner

    Thanks for reporting, Jason. I'll take a look for one of the upcoming builds. I'm always trying to swat down inspection false negatives to ensure they're as reliable and informative as I can make them.

  2. Log in to comment