Short answer. For a roof on a rental or business property, the IRS method is MACRS straight-line with the mid-month convention: 27.5 years for residential rental property and 39 years for nonresidential property. Bonus depreciation does not reach these long recovery periods, though roofs on nonresidential buildings can qualify for Section 179 expensing.
How straight-line mid-month works
The cost is spread evenly over the recovery period, but the first year counts from the middle of the month the roof was placed in service. A rental roof placed in service in January gets about 11.5 months of depreciation in year one; one placed in service in December gets half a month.
Partial disposition of the old roof
When you replace a rental's roof, the old roof was part of the building's depreciable basis. The IRS lets you elect a partial disposition, writing off the old roof's remaining undepreciated cost in the year you replace it. The election is made on a timely filed return for that year, so raise it with your preparer before filing.
Section 179 and bonus depreciation
Bonus depreciation applies to property with recovery periods of 20 years or less, so it does not reach 27.5 or 39 year building components.
Section 179 can cover roofs on nonresidential real property, but not property used for lodging, such as residential rentals.
The insurance method, for comparison
Insurers also use a straight-line idea on claims, but their purpose is valuing a damaged roof, not spreading a cost for taxes. The two numbers will not match, and neither affects the other.
This is general information; your tax preparer should apply it to your situation. On the claim side, see ACV vs RCV roof claims.