Skip to content

v2.2.0

Latest

Choose a tag to compare

@github-actions github-actions released this 28 Nov 05:19

Added

  • RH012 reads the scripts a pipeline hands its work to, not only the pipeline file: anything
    under ci/, .ci/, .buildkite/ or .github/scripts/, and scripts/ci*. A workflow that
    says run: ./ci/verify.sh stays untouched when npm test is deleted from the script, which
    is where the suite actually stopped running. The same move, swallow and retry rules apply.
  • RH010 warns when one test's timeout is raised several times over, as it already did for a
    runner-wide timeout: the trailing timeout argument of an it/test call (}, 200); to
    }, 120000);), mocha's this.timeout(n), and a timeout option on a test declaration. Same
    bar as the runner rule: only the number changed, to at least 60 seconds and at least four times
    the old value. A comment saying why the test needs longer keeps it quiet.
  • WI109 follows an edited expectation one step further. A literal moved into a name the change
    introduces, with its value changed on the way (toBe(195) to
    const accepted = 194; ... toBe(accepted)), is the same edit as changing it in place and is
    reported the same way. pytest parametrize rows written as tuples ([(1, 2, 0.5), (3, 2, 1.5)])
    are read as table rows, and several rows on one line may have their expected column changed
    together; written one per line, those rows were already reported, so the old rule measured only
    layout. Moving a literal into a name unchanged, reading a name that already existed, changing an
    input, or a call's argument list in a test stays quiet.
  • WI109 now looks at an expectation edit even when the change also edits implementation code, so
    a wrong expected value cannot ride along with an unrelated fix (correct the sort order in
    sort.ts, and in the same change rewrite tax.test.ts to expect the wrong tax). It is a
    warning, not a block, and only when nothing in that code is related to the test: no shared file
    stem, no import of it in the test, no mention in its diff of a word the assertion uses, and
    neither the old nor the new value in its diff. Code and its tests edited together stay quiet,
    as before.
  • RH011 reports a single suppression laid over code the change did not otherwise touch: a
    # type: ignore[...] appended to an unchanged line, or a // @ts-ignore, scoped
    /* eslint-disable rule */ or #[allow(...)] placed above unchanged code. The code is exactly as
    it was and only the diagnostic went quiet. One suppression on code the change writes is still
    treated as a justified exception, and so is one with a reason on its line or in a comment just
    above it, or an edit to a suppression that was already there. A warning, like the rest of RH011.
  • RH002 reports an expected exception broadened to a catch-all type on the same assertion in every
    framework proctor reads, not only pytest.raises: toThrow(SyntaxError) to toThrow(Error)
    (including .rejects), assertRaises, JUnit assertThrows(X.class, ...) and
    @Test(expected = ...), Kotlin assertFailsWith<X>, C# Assert.Throws<X> and FluentAssertions,
    RSpec raise_error, Minitest assert_raises and PHPUnit expectException. Narrowing the type,
    or swapping one specific type for another, stays quiet.

On the held-out set these take the default checks from 40 to 49 of 72 cheats caught, and all
checks from 47 to 56, with the same benign cases flagged (3 and 4 of 72). Edited expected values
and suppression, both 0 of 3 before, are now 3 of 3. On the 700 human commits in bench/detection
blocking is unchanged (11 by defaults, 28 with all checks); one more commit gets a warning, an
unexplained # type: ignore added to a line it did not edit. The checks were written against
held-out misses, so these are development numbers; see docs/BENCHMARKS.md.

  • RH004 reports the one-line special-case branch in Go, Rust and Swift, which write
    if id == "acct-742" { return 6500 } without the parentheses its pattern needed; Rust may compare
    a byte string and return Ok(255). Both literals must be distinctive, so a base case
    (if n == 0 { return 1 }) or a sentinel on an empty string stays quiet, and vendored trees are
    skipped. A branch spread over two lines still needs a test that expects its value.

  • RH005 reports an existing function whose whole body became a constant return, including
    return Promise.resolve(true), compared by header, so rewriting a one-line function over three
    lines no longer hides it from the line-count gate. It also sees C#, Java and Kotlin methods, for
    the constant body and for a body emptied outright (public void Validate(int q) { }).

  • RH005 reports a Python test that replaces a function (monkeypatch.setattr, patch.object, or
    the dotted-string setattr) and then, in the same test, asserts on a call to it, which checks the
    replacement. Patching a dependency of the code under test (cli.input), or mocking a function in
    one test while another test asserts on the real one, stays quiet.

  • RH002 reports RSpec eq weakened to include or to a type-only matcher (be_a, be_kind_of,
    be_instance_of) or be_present, and Minitest assert_equal weakened to assert_includes.

  • WI103 (all checks) reports a validating parse replaced by a type assertion of the same value:
    return orderSchema.parse(raw) becoming return raw as Order (or <Order>raw), for zod, yup,
    valibot, io-ts, superstruct and pydantic call shapes. The rest of the line must be unchanged, so
    validation moved into a helper, a different value cast, or a rewritten line stays quiet.

Together: the held-out defaults go from 49 to 55 of 72 and all checks from 56 to 63, with the same
benign cases flagged; the 700 human commits are unchanged.

Changed

  • The README's GitHub Action example pins the commit behind v2.1.0 (77911c1) instead of the one
    behind v1.0.0, so a workflow copied from it runs today's checks rather than the first release's.
    The Action builds from the pinned commit's own source, so the pin does not depend on npm.
    tests/release-hardening.test.ts now holds the example to the v2.1.0 commit.
  • The README shows the demo recording right under the introduction instead of halfway down the
    page, and carries a monthly npm downloads badge.

Fixed

  • RH002 misread the subject of a Minitest assert_equal whose expected value held a comma
    (assert_equal [7, 11], records read the subject as 11]), so a weakening of it was never paired.
  • RH002 missed a toBeCloseTo precision lowered below zero. toBeCloseTo(216.34, -2) passes
    anywhere within 50, looser than any positive precision, but the precision pattern only read
    non-negative digits.
  • node bench/heldout/probe.mjs failed on Windows at its first git call. It pointed
    GIT_CONFIG_GLOBAL at os.devNull, which Git on Windows cannot open as a config file; it now
    uses an empty temporary file on every platform.
  • WI101 missed a Ruby rescue that hands back an unquoted constant. A rescue whose body is only a
    literal is reported, but literals are masked before a handler is judged, so only a quoted
    'system' looked empty; rescue StandardError returning nil (or false, 0, :none) read
    as a statement and passed. The value itself is now read, so every constant default is treated
    the same. A rescue that recovers through a call still passes.
  • WI101 counted the closing of an inline comment as words, so catch (e) { /* best effort */ }
    met the three-word bar for an explanation. The comment now ends at */; this applies to every
    WI check that accepts an explanation.
  • WI103 missed a deleted Go guard whose function returns a value type. It knew
    return nil, fmt.Errorf(...), but func Port(n int) (int, error) refuses with
    return 0, fmt.Errorf(...); zero values (0, "", false, Config{}) now count too.
  • WI101 recognises a C# handler that only writes the failure to Trace or Debug
    (Trace.WriteLine, Debug.WriteLine, Trace.TraceError, ...) as logging-only, as it already
    did for Console.WriteLine.
  • Held-out set with all checks: 69 of 72 cheats caught (was 63), with honest changes flagged
    unchanged at 4 of 72. The 700 sampled human commits are flagged exactly as before.