lint: reduce scope

Fix some lint warnings of kind
```
style (variableScope): The scope of the variable '…' can be reduced
```
I'd leave that comment in because it fits the overall style and actually helps to understand what's happening here.