Make Codacy happy with scope

Because defining variables in an if is *baaaad*.