Jump to content

Topic on Talk:Continuous integration/Codehealth Pipeline

mw.loader.getState can return null

3
Summary by ZFilipin (WMF)

Labeled this as a false positive.

SToyofuku-WMF (talkcontribs)

I recently introduced some code to the Vector repo that checks whether the result of calling mw.loader.getState is null or a string, and got an error saying state will never be null, despite my testing confirming this is working as intended. Is there a place that the return value of getState is being defined incorrectly? I'm concerned that now that it's been merged this will continue to affect all subsequent patches introduced into the Vector repo

PWangai-WMF (talkcontribs)

This appears to be a false positive. The highlighted expression return state!== null && state!== 'registered'; is valid since testing has confirmed that mw.loader.getState can return null, so the check is necessary. I have labeled this as a false positive, and hopefully, this will help SonarCloud handle the condition correctly if it occurs again.

SToyofuku-WMF (talkcontribs)