I repack all grains like rice and pasta with some bay leaves scattered in, and have only had bugs once, with brown rice that was very old and ill packed. Not saying it will always work, but have not had any bugs in years. Some people don’t have big enough freezers to do the freezing thing.
One thing learned from reading others’ experience:
Never, ever store foods in the original cardboard boxes etc, unless said boxes are in tight containers (which wastes a lot of space). Bugs, what to speak of rodents, can chew right threw cardboard, thin plastic or cellophane bags and destroy tons of food.
Sam’s Club bakeries give away their 3 and 5 gallon buckets that icing comes in. Add a mylar bag and an O2 absorber and you’re in business! ;-)