This is a Lint bug. In particular, this one .
The error seems to be in the inner class CommitFinder SharedPrefsDetector :
@Override public boolean visitMethodInvocation(MethodInvocation node) { ... String name = node.astName().astValue(); boolean isCommit = "commit".equals(name); if (isCommit || "apply".equals(name)) { ... if (returnValueIgnored) { String message = "Consider using apply() instead; commit writes " + "its data to persistent storage immediately, whereas " + "apply will handle it in the background"; mContext.report(ISSUE, node, mContext.getLocation(node), message, null); }
I think the idea was to give this warning only if you did not assign the return value of commit() to anything (this part works), but they forgot to check the isCommit flag. :)
source share