Consider Documenting Blocks of Code Rather than Individual Lines [DS20]
Tip DS20
Placing comments close to the corresponding code doesn’t mean that every comment has to be right before the individual line it most closely applies to. Having a comment for each individual line can be quite disruptive to reading. Sometimes, comments between individual lines of code can be helpful, but in many cases, it can be fine to relocate comments closer to the beginning of the “block” of relevant code.
See the following example for a case where comments are probably better not placed before individual lines: