Today, each of the 50 states follows a different set of building codes making navigating these codes confusing, particularly for architects or builders that have projects in multiple states. In some cases, the building code changes significantly between the state and certain cities or counties within the state. For example, at the time of writing Arizona had adopted the 2015 IRC Building Code, however, Phoenix was on the 2012 IRC, IBC and IECC code. With the majority of states either on the 2009, 2012 or 2015 code, below are some high-level points to consider and about how spray foam insulation contributes.

DID YOU KNOW? Spray FOam insulation out-performs conventional insulation materials because they (conventional insulation materials) trap still-dry air and if that air moves or becomes wet, the thermal resistance can drop by 50%. Spray Foam protects against air infiltration, which can increase energy costs in buildings by 10 to 40%. Eliminate these drafts and live in a more energy-efficient, comfortable and healthier building by choosing spray foam insulation.
The average price to cover 200 square feet with a foam insulation kit will run between $300 and $600 (about two to three kits). Inside these kits is something called Icynene, a foam made from two liquids that are heated and pushed through a gun on the can. When Icynene is released, it expands up to 100 times its size as it hits the surface area you're covering. These can contain a lot of gasses, making its installation a dangerous process. Even low-pressure sprayers can be harmful to homeowners' health.
You probably have some familiarity with spray foam insulation, and you may have even used the foam that comes in pressured spray cans at home improvement retailers. This foam is know as one-part foam, meaning that it is one continuous mixture that is simply applied to the area in need. One-part foam is frequently used for sealing small gaps and cracks.
The problem was that the installer was doing his first spray foam job ever, and the thickness of the insulation varied from zero (visible roof deck) to about 9". Unfortunately, good average thickness doesn't cut it. The coverage needs to be uniform because a lot of heat will go through the under-insulated areas. (See my article on flat or lumpy insulation performance.)
The guys who sprayed my attic were trained and certified, but I later found out, too late, that they had no experience and my attic was the first they'd ever sprayed. I was also never told to vacate my house for any length of time, and so I (and my pets) were in the house the day they sprayed and the entire time the off ratio foam was filling my home with horrendous vapors. The company kept telling me that it was a good job and I had nothing to worry about, even after I'd had 2 other experienced sprayers from 2 different companies visually examine the foam and confirm that large areas appeared to be off ratio. The 3rd sprayer from yet another company, was also outraged because the company who did my attic had failed to vacuum up all of the old cellulose insulation, and he also noticed areas where the foam was shrinking or pulling away, and this was not even 5 weeks after the spraying.  
My other question was gonna be this. We ripped all the drywall out after Hurricane Harvey and we found some latent termite damage from some time back. One of the common studs in one corner is pretty well eaten to shreds. I was gonna brace it but then I read about more modern framing practices and I read how each stud is a thermal bridge. So now I'm thinking that I won't bother with it because the house hasn't fallen down and the foam might help a little. Unless you say to brace the stud. Then I'll do it, Martin! :)
The United States has adapted to using sprayfoam insulation and a new technology called Wall Injection to retrofit existing wall construction by drilling small holes between wall studs in the structures framing and filling the void with a less aggressive expanding water based foam. This allows existing home and business owners to conserve energy by creating a thermal envelope in their existing structure.
R-value is the term given to thermal resistance to heat flow. The higher the R-value of an insulation product, the more effective the insulation properties. Spray polyurethane foam comes in a range of densities and cel structure. Low density foams are referred to as Open Cel SPF while higher density foams are referred to as Closed Cel foam. 1.8-2 pound polyurethane foam has the highest R-value of readily available spray foam insulation used in homes and buildings.[4]

Roof Spray Foam Insulation