This question has 2 sides - for long range accuracy you need longer barrel, but it makes the rifle clumsy in close quarters. For close quarters you need something easily manoeverable, but this means short barrel and lesser oomph/accuracy at long ranges. So it's a tradeoff - can't excel in both.
You need to figure out, what you need, exactly, write it down if you want, like - I need the gun for following duties: ....
Ie how much work is done in CQB and how much in 'reach out and touch someone' distances. Something good in the middle may have too much tradeoffs on both ends.
For CQB I'd use something short, like FAL carbine, or .223 cal rifle, something M4 like; and longer ranges something good and accurate, with 20+ inches barrel (perefably 22+), like M1A, or AR-10(T) or AR-10A4. You know, each job has the tools that fit best.