APIAvailability rule should pass when respondsToSelector: is called.

Issue #97 invalid
JinZhuHuang created an issue

Since the code uses respondsToSelector: to check if a api is available, the APIAvailability rule should stop warning in this case...

as the code shown below:

if ([cell respondsToSelector:@selector(setLayoutMargins:)])
{
     [cell setLayoutMargins:UIEdgeInsetsZero];
}

Comments (3)

  1. Ali Rantakari repo owner

    Thanks for reporting this. I was unable to reproduce this issue, however. Please ensure that the avoidFalsePositives option for this rule is on. If the setting is on, but you're still seeing this issue, a small self-contained source file or Xcode project that reproduces the issue would be appreciated.

  2. JinZhuHuang reporter

    That's right. When avoidFalsePositives is true, the issue disappeared.

    One more thing needs to be clarified is, why not make this warning fixed by default, instead using avoidFalsePositives option?

  3. Ali Rantakari repo owner

    Thanks, good to hear that the setting works correctly.

    why not make this warning fixed by default, instead using avoidFalsePositives option?

    Due to the dynamic nature of checks like this, it's not possible to avoid these kinds of false positives with 100% certainty (i.e. without ending up with some false negatives instead) so I want to offer the user a choice between a higher likelihood of false positives versus a higher likelihood of false negatives.

  4. Log in to comment