AIFeed

Show HN:Coderot——为任意 GitHub 仓库展示 AI 占比与复杂度随时间的变化

Translation(model translation, not the source's own text)

文章标题:Show HN: Coderot — 任意 GitHub 仓库的 AI 份额与复杂度随时间变化

正文: 第 1 轮,共 3 轮

图表:Human。2020 年的 dotnet/runtime,当时 Copilot 还不存在。来源

A · GroupJoinIterator()


        {
    using (IEnumerator<TOuter> e = outer.GetEnumerator())
    {
        if (e.MoveNext())
        {
            Lookup<TKey, TInner> lookup =
                Lookup<TKey, TInner>.CreateForJoin(
                    inner, innerKeySelector, comparer);
            do
            {
                TOuter item = e.Current;
                yield return resultSelector(
                    item, lookup[outerKeySelector(item)]);
            }
            while (e.MoveNext());
        }
    }
}
      

B · GroupJoinIterator()


        {
    using IEnumerator<TOuter> e = outer.GetEnumerator();
    if (e.MoveNext())
    {
        Lookup<TKey, TInner> lookup =
            Lookup<TKey, TInner>.CreateForJoin(
                inner, innerKeySelector, comparer);
        do
        {
            TOuter item = e.Current;
            yield return new GroupJoinGrouping<TOuter, TInner>(
                item, lookup[outerKeySelector(item)]);
        }
        while (e.MoveNext());
    }
}
      

注意到更新的 using 语法了吗?这能标出代码的年代,但没法指认作者:agent 是逐行照抄了旁边已有的方法。

第 2 轮,共 3 轮

A · IsWhiteSpaceByte()


        {
    // Check for ASCII whitespace characters: space (0x20),
    // tab (0x09), newline (0x0A), carriage return (0x0D),
    // form feed (0x0C), and vertical tab (0x0B)
    // For non-ASCII bytes, convert to char and check with
    // char.IsWhiteSpace
    return b <= 127 ? char.IsWhiteSpace((char)b) : false;
}
      

B · SkipWhiteSpace()


        {
    // Create local copy to avoid bounds checks.
    ReadOnlySpan<byte> localBuffer = _buffer;
    for (; _consumed < localBuffer.Length; _consumed++)
    {
        byte val = localBuffer[_consumed];

// JSON RFC 8259 section 2 says only these 4
        // characters count, not all of the Unicode
        // defintions of whitespace.
        if (val != JsonConstants.Space &&
            val != JsonConstants.CarriageReturn &&
            val != JsonConstants.LineFeed &&
            val != JsonConstants.Tab)
        {
            break;
        }

if (val == JsonConstants.LineFeed)
        {
            _lineNumber++;
            _bytePositionInLine = 0;
        }
        else
        {
            _bytePositionInLine++;
        }
    }
}
      

A 的注释说非 ASCII 字节会用 char.IsWhiteSpace 检查,但代码对它们返回 false。这是破绽吗?人也会留下错误的注释,而且这段还通过了审查。

第 3 轮,共 3 轮

A · normalizeGitRepoPath()


        {
    const trimmed =
        path.replace(/\/+/g, '/').replace(/\/+$/g, '');
    if (!trimmed.toLowerCase().endsWith('.git')) {
        return undefined;
    }

const withLeadingSlash =
        trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
    const pathWithoutGit = withLeadingSlash.slice(1, -4);
    if (!pathWithoutGit || !pathWithoutGit.includes('/')) {
        return undefined;
    }

return withLeadingSlash;
}
      

B · normalizeGitRepoPath()


        {
    const gitSuffix = '.git';
    const trimmed =
        path.replace(/\/+/g, '/').replace(/\/+$/g, '');

const withLeadingSlash =
        trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
    // Strip .git suffix (if present) only for the purposes
    // of validating path depth.
    const pathWithoutGit =
        withLeadingSlash.toLowerCase().endsWith(gitSuffix)
            ? withLeadingSlash.slice(1,
                withLeadingSlash.length - gitSuffix.length)
            : withLeadingSlash.slice(1);
    if (!pathWithoutGit || !pathWithoutGit.includes('/')) {
        return undefined;
    }

return withLeadingSlash;
}
      

具名常量和解释性注释让人觉得是 AI 写的?猜得合理。但 A 也不能证明是人写的:它的提交信息写着“(提交信息由 Copilot 生成)”,而且没有任何记录说明代码是谁写的。coderot 会把 A 计为未知。

文章标题:Show HN: Coderot —— 为任意 GitHub 仓库展示 AI 份额及其随时间的复杂度变化

正文: 按提交时的状态呈现方法体,并对过长的行进行折行显示。

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗