S-traps are not allowed by any plumbing code because their design causes the trap to siphon. This is what the gurgling noise is.
Modern plumbing requires a P-trap at every fixture, and that trap must have a vent. The vent is what prevents traps from siphoning. The vent must rise from the trap arm vertically through the roof, or can connect to other fixture vents before it goes through the roof.
Where I live, the plumbing code permits the vent for a 2" horizontal drain to be up to 8 feet from the trap, or 6 feet on a 1-1/2" drain.