I always prefer to prevent require statements in view methods, unless it's really necessary. Because sometimes, backends like Metamask, due to some limitation, don't include the revert reason strings in the error, which causes user interfaces to have a hard time figuring out the cause of the error.
I'd instead suggest you to change your method to:
this is the code snippet from the frontend of Pancakeswap, and if I not wrong MasterChef calculates in the same way.
* Get the APR value in %
* @param stakingTokenPrice Token price in the same quote currency
* @param rewardTokenPrice Token price in the same quote currency
* @param totalStaked Total amount of stakingToken in the pool
* @param ...