Skip to content

[business-logic] test_gaming_check hardcoded index 11 guards wrong regex — Ruby skip causes false positives in Go test files #87

Description

@topcheer

Bug: test_gaming_check hardcoded index 11 doesn't match Ruby skip pattern (now at index 13)

File

internal/agent/test_gaming_check.go line 218-220

Problem

The Ruby skip directive guard uses a hardcoded index 11 to skip the Ruby ^\s*skip\b regex for non-.rb files. But the skipDirectiveRegexes array actually has 14 elements (indices 0-13), with the Ruby pattern at index 13, not 11.

// countSkipDirectives, line 218-220:
for i, re := range skipDirectiveRegexes {
    // skipDirectiveRegexes index 11 is the Ruby `^\s*skip\b` pattern.
    if i == 11 && ext != ".rb" {
        continue
    }

The actual array layout (0-indexed):

[0]  t.Skip(f)?
[1]  pytest.skip
[2]  @pytest.mark.skip
[3]  self.skipTest
[4]  unittest.skip
[5]  @unittest.skip
[6]  @pytest.mark.xfail
[7]  (it|test|describe).skip
[8]  xit
[9]  xdescribe
[10] @Ignore
[11] @Disabled     ← this is what index 11 actually points to
[12] Assume.assumeFalse
[13] skip (Ruby)   ← actual Ruby pattern

Impact

  1. Ruby skip guard is broken: index 11 now protects @Disabled (a Java/Kotlin pattern) from being applied to non-.rb files, which is meaningless — @Disabled never matches in Go/Python anyway.

  2. Ruby skip causes false positives: The Ruby ^\s*skip\b regex at index 13 is not guarded for non-.rb files. Any Go code with skip := true, skip = false, or if skip { in a test file triggers a false positive skip directive warning.

  3. Fragile design: The hardcoded index approach means any future addition to the array silently shifts the index, breaking the guard with no compiler protection.

Trigger Scenario

A Go test file containing:

func TestFoo(t *testing.T) {
    skip := shouldSkip()
    if skip {
        t.Skip()
    }
    // ...
}

The line skip := shouldSkip() matches ^\s*skip\b (Ruby pattern). Since index 13 != 11, the guard doesn't fire, and this is counted as a skip directive — producing a false positive test-gaming warning.

Fix

Replace the hardcoded index with a type-safe approach:

// Option A: Check the pattern source
if strings.Contains(re.String(), `^\s*skip\b`) && ext != ".rb" {
    continue
}
// Option B: Separate Ruby patterns into a different slice

Severity

Medium — produces false positives on Go test files using skip as a variable name, which is common and idiomatic Go.

Verification

Independently verified by sub-agent (sa-69). Array contains 14 elements; Ruby pattern is at index 13, not 11.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions