All code paths do not return a value.

I am trying to insert the following code but get this error. Looks fine to me, but my coding skills are very limited for now. Any advice would be appreciated.

private bool CheckIndex(int cIndex, bool a2DCollider)
    {
        if (a2DCollider)
        {
            if (floatingObjects2D.Count <= cIndex)
            {
                return true;
            }
            if (floatingObjects2D[cIndex] == null)
            {
                floatingObjects2D.RemoveAt(cIndex);
                return true;
            }
        }
        else
        {
            if (floatingObjects3D.Count <= cIndex)
                return true;
            if (floatingObjects3D[cIndex] == null)
            {
                floatingObjects3D.RemoveAt(cIndex);
                return true;
            }
        }
   }

What gets returned when
floatingObjects2D.Count > cIndex and floatingObjects2D[cIndex] != null?
You do not specify what should be returned in this case, but need to do so, thus the error.

If you want to return “false”, for every single condition you have NOT specified:
simply add return false; , before the closing parens of the function. This way, if it has not returned yet, but reached the end of the function, it will return false.

While not getting in the “Cyclomatic complexity” subject, your first IF does not have a return when the two following IFs are not satisfied.

Missing a return value after lines: 13 and 23;