I have asked "could you walk me through some of your best and worst code for a few minutes?" the last two times I went job hunting, usually at the end where people ask "do you have any questions for us?" Thus far, this has universally been received as positive. Not all companies may be willing/able to do this – much depends on company culture, size, industry, etc.
The reason I ask for the best and worst code is so that I can get a vague idea of what they consider to be "good code", and also get a vague idea of what they consider to problems in their code base. Note that this is not a code review, but rather an opening to start a discussion about the state of their code, future plans to improve the code base, and most importantly, their general approach to software development. Even if they're not able/willing to actually show you code, this can still be a good conversation starter; for example they can verbally describe why they consider their good code to be good, or their bad code to be bad.
Some organisations have surprisingly funny ideas about this. To give an example one organisation showed me what was clearly a huge spaghetti mess, and the biggest problems they pointed out with it were "public
and private
keywords often not being added" and "variable names not always being descriptive". While these are legitimate concerns, those were far from the most pressing concerns with that code. They clearly didn't know what they were doing. I did end up working there as a friend of mine worked there and I trusted her, but this turned out to be a big mistake and vexing experience for both parties.
Addendum: OP came back and posted the following in the comments:
Although I found this a good idea, and I tried it several times, results were pretty bad: big companies can't do that, as they'd need a process that they have not implemented, but that's ok because big companies usually don't give you home assignments. Other companies, including the ones that do give you home assignments, refuse with better or worse excuses, promise to do it and then never send it, or don't understand why/what you want. A couple of them sent me their whole repositories with several thousand lines of code, which at least was honest in that I would know what to expect. – antonro
So it looks like your mileage may vary; I can only speak from my own limited personal experience. I've almost exclusively interviewed at smaller "non-enterprise-y" companies, and perhaps it also depends a bit on your locality (I'm in Europe). It's important to stress that I've never asked anyone to send me anything, but rather to just walk through the code a bit with them during the interview for a few minutes. Just sending code seems pretty useless to me because there's no conversation: the value is mostly in the conversation not necessarily the code as such, which is mostly of a MacGuffin in this context.
As for asking employee's contact information, this seems rather strange to me. I understand where you're coming from, but aside from the privacy concerns it can also put regular employees in a rather tough spot.
Use sites like glassdoor instead, where current and past employees can leave reviews, if they choose to. For medium to large companies this should give you a reasonable indication, although I would strongly recommend to read some of the reviews rather than blindingly trust the 4.4 rating (or whatever).