Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreachable else if case in docker_cli_build_test.go #43450

Open
vastjs opened this issue Apr 3, 2022 · 1 comment
Open

Unreachable else if case in docker_cli_build_test.go #43450

vastjs opened this issue Apr 3, 2022 · 1 comment

Comments

@vastjs
Copy link

vastjs commented Apr 3, 2022

docker_cli_build_test.go contains an unreachable else if case on line 216-220.

		if parts[0] == "bar" {
			found = true
			if parts[1] != "zzz" {
				c.Fatalf("Could not find replaced var for env `bar`: got %q instead of `zzz`", parts[1])
			}
		} else if strings.HasPrefix(parts[0], "env") {
			envCount++
			if parts[1] != "zzz" {
				c.Fatalf("%s should be 'zzz' but instead its %q", parts[0], parts[1])
			}
		} else if strings.HasPrefix(parts[0], "env") {
                        // unreachable
			envCount++
			if parts[1] != "foo" {
				c.Fatalf("%s should be 'foo' but instead its %q", parts[0], parts[1])
			}
		}

It is unclear to me if the else if block is just a duplicate and can be just removed. Because its body differs from the block above.

@thaJeztah
Copy link
Member

Nice catch; I see that was added in 39908fc (#11149), and (just at a quick glance), looks like it's just a duplicate (perhaps the original intent was to add more test-cases to TestBuildEnvironmentReplacementEnv() ?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants