I lived there for 27 years in favelas like Rocinha and Santa Marta (when I didn't have money), and in apartments in Botafogo and Flamengo (after making money). I walked on the streets midnight and later. Nothing has ever happened to me. I've never even witnessed anything.
Of course, it's my own experience and I have some privileges.
The only time I was robbed in my life I was in the US. My computer has been stolen in the Houston International Airport (thankfully, it was recovered by a super professional Mexican police officer).
[1] https://thebrazilbusiness.com/article/the-10-safest-state-ca...