Skip to content

feat(cmd): add no-review cmd - #835

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
Syt3s:feat/add-no-review-filter
Aug 12, 2026
Merged

feat(cmd): add no-review cmd#835
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
Syt3s:feat/add-no-review-filter

Conversation

@Syt3s

@Syt3s Syt3s commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

Adds --no-filter flag to ocr review, allowing users to skip the REVIEW_FILTER_TASK post-processing phase — eliminating one LLM call per reviewed file and reducing token consumption.

The REVIEW_FILTER_TASK runs after each file's main review loop to filter out false-positive comments. Every reviewed file triggers exactly one additional LLM call for this phase. While effective for trimming low-quality comments, this per-file call adds up quickly — a 20-file PR costs 20 extra LLM round-trips even when the filter produces no actionable removals.

ocr scan already provides --no-plan, --no-dedup, and --no-summary flags to skip optional LLM stages, but ocr review had no equivalent. This PR closes the gap by following the same established pattern.

Design: mirrors the existing --no-dedup pattern from internal/scan/agent.go. The skip check lives inside executeReviewFilter, placed after the ReviewFilterTask == nil guard (so users aren't spammed with misleading skip messages when the template doesn't configure a filter task) and after the telemetry span is created (so the skip is still observable in traces via the skipped=true span attribute). When the flag is set, a log line [ocr] Review filter skipped for <file> (--no-filter) is emitted and the function returns immediately.

Files changed (4 files, 6 code locations):

File Change
internal/agent/agent.go Added SkipFilter bool to Args struct with doc comment
internal/agent/agent.go (executeReviewFilter) Added early-return check after the nil-template guard and span setup; sets skipped=true span attr
cmd/opencodereview/review_cmd.go Added noFilter bool to reviewOptions; wired to Args.SkipFilter
cmd/opencodereview/shared_flags.go Registered --no-filter bool flag (default false) in registerReviewFlags
internal/agent/coverage_test.go Added TestExecuteReviewFilter_SkipFilter with 5 sub-tests

No changes to internal/scan/, internal/llmloop/, internal/tool/, internal/diff/, or internal/config/. Zero new third-party Go dependencies.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

All tests use fakeAgentClient (an in-package mock with a calls counter) — no real LLM configuration needed. The counter-argument test (AC-3, no flag) proves the mock is correctly invoked when the filter runs, so the zero-call assertions in AC-1/2/4/5 are meaningful.

New tests (5 sub-tests in TestExecuteReviewFilter_SkipFilter):

Sub-test Verifies
AC-1: SkipFilter disables the filter With SkipFilter=true + ReviewFilterTask present + comments exist → client.calls == 0, comments untouched
AC-2: All comments preserved when skipped 3 comments added → all 3 remain after skip
AC-3: Default (no SkipFilter) still runs filter SkipFilter zero-value (false) → client.calls > 0, comments filtered normally (backward compat)
AC-4: SkipFilter is reached when ReviewFilterTask is non-nil SkipFilter=true + non-nil ReviewFilterTask + 1 comment → client.calls == 0, comment preserved (exercises the skip branch, not the nil-template guard)
AC-5: Skip takes priority over no comments SkipFilter=true + zero comments → client.calls == 0

Regression: all 6 existing TestExecuteReviewFilter_* tests pass unchanged (NoFilterTask, NoComments, RemovesComments, LLMError, WithTimeout, plus the existing timeout variant).

  • make test passes locally
  • Manual testing (describe below)

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

Related Issues

closes #833

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 2 issue(s) in this PR.

  • ✅ Successfully posted inline: 1 comment(s)
  • ❌ Failed to post inline: 1 comment(s)

[bug · low]

📄 internal/agent/agent.go (L1240-L1249)

⚠️ GitHub could not post this as an inline comment: Lines 1240-1249 could not be resolved (outside PR diff hunks)

The SkipReviewFilter check is placed before the nil/empty check for ReviewFilterTask. When the template has no REVIEW_FILTER_TASK defined (ft == nil), the function would previously return silently. With this ordering, it will instead print a misleading "Review filter skipped" message for every file, even though no filter was ever going to run. Move this block after the ft == nil || len(ft.Messages) == 0 check so the skip message is only emitted when an actual filter task is being bypassed.

💡 Suggested Change

Before:

	if a.args.SkipReviewFilter {
		telemetry.SetAttr(span, "skipped", true)
		fmt.Fprintf(stdout.Writer(), "[ocr] Review filter skipped for %s (--no-review-filter)\n", newPath)
		return
	}

	ft := a.args.Template.ReviewFilterTask
	if ft == nil || len(ft.Messages) == 0 {
		return
	}

After:

	ft := a.args.Template.ReviewFilterTask
	if ft == nil || len(ft.Messages) == 0 {
		return
	}

	if a.args.SkipReviewFilter {
		telemetry.SetAttr(span, "skipped", true)
		fmt.Fprintf(stdout.Writer(), "[ocr] Review filter skipped for %s (--no-review-filter)\n", newPath)
		return
	}

Comment thread cmd/opencodereview/shared_flags.go Outdated
addBackgroundFlags(cmd, &opts.background, &opts.backgroundFile)
addProviderFlag(cmd, &opts.provider)
addModelFlag(cmd, &opts.model)
cmd.Flags().BoolVar(&opts.noReviewFilter, "no-review-filter", false, "skip the per-file REVIEW_FILTER_TASK")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[maintainability · low]
The skip check happens before validating whether a review filter task actually exists. This means users will see "Review filter skipped for " messages for every file even when REVIEW_FILTER_TASK is not configured in the template. Consider moving the SkipReviewFilter check after the ft == nil || len(ft.Messages) == 0 validation to avoid spamming users with misleading skip messages when there was nothing to skip.

@Syt3s
Syt3s force-pushed the feat/add-no-review-filter branch from 5541457 to 240f450 Compare August 11, 2026 03:07

@wu21-web wu21-web left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job there, no issues!

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, nice PR! One small naming suggestion:

The existing skip flags follow a pattern of --no- + the core keyword from the task name:

  • PLAN_TASK--no-plan / SkipPlan
  • DEDUP_TASK--no-dedup / SkipDedup
  • PROJECT_SUMMARY_TASK--no-summary / SkipSummary

For REVIEW_FILTER_TASK, following the same convention would give us --no-filter / noFilter / SkipFilter rather than --no-review-filter / noReviewFilter / SkipReviewFilter.

The review- prefix feels redundant here since this flag only exists on the ocr review subcommand anyway — there's no ambiguity about which filter we're skipping. Shorter is also easier to type :)

Would you mind renaming to --no-filter for consistency with the rest of the family?

@Syt3s
Syt3s force-pushed the feat/add-no-review-filter branch from 240f450 to 4c9f335 Compare August 11, 2026 08:55
@Syt3s

Syt3s commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Hi @lizhengfeng101, thanks for the review and the great naming suggestion! 🙏

That makes total sense — keeping the skip flags consistent with the existing --no-* convention keeps things cleaner and easier to remember. I've renamed --no-review-filter to --no-filter across the flag name, variable name, and the corresponding SkipFilter helper. Please take another look when you have a moment.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Syt3s
Syt3s force-pushed the feat/add-no-review-filter branch from 4c9f335 to 3b15f07 Compare August 12, 2026 01:28
@Syt3s

Syt3s commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@Syt3s CI / test (pull_request)Failing

fixed

@Syt3s
Syt3s requested a review from lizhengfeng101 August 12, 2026 04:28

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Syt3s, nice work addressing the earlier feedback — the check ordering and naming are both solid now. A few things I'd like cleaned up before we merge:

1. PR description is stale

The body still references --no-review-filter and SkipReviewFilter in several places (the design section, the files-changed table, etc.), but the code now uses --no-filter / SkipFilter. Would you mind updating the description to match? Once this merges, the PR becomes the historical record — future readers shouldn't have to diff the description against the code to figure out what actually landed.

2. AC-4 test name contradicts the implementation

t.Run("AC-4: Skip takes priority over nil ReviewFilterTask", ...)

After you moved the SkipFilter check below the nil-template guard (the right call per the bot's feedback), it's actually the nil check that returns first — SkipFilter is never even evaluated in this path. The test still passes, but the name claims the opposite causality. Something like "AC-4: No LLM call when SkipFilter=true and ReviewFilterTask is nil" would accurately describe what's being asserted.

3. AC-4 doesn't exercise the SkipFilter path

Related to the above — because ReviewFilterTask is nil, the function bails out before reaching the SkipFilter branch. You could set SkipFilter to false and the test would still pass identically. So this sub-test isn't really adding coverage for the skip logic; it's a duplicate of the existing TestExecuteReviewFilter_NoFilterTask. Consider either removing it or giving it a non-nil ReviewFilterTask (so the skip check is actually reached and meaningfully tested).


Everything else looks good. Thanks for iterating on this!

@Syt3s
Syt3s force-pushed the feat/add-no-review-filter branch from 3b15f07 to 41c4eeb Compare August 12, 2026 07:35
@Syt3s
Syt3s requested a review from lizhengfeng101 August 12, 2026 07:37

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three issues addressed — description is accurate, AC-4 now exercises the actual SkipFilter branch with a meaningful assertion, and the naming is consistent throughout. LGTM, thanks for the quick turnaround!

@lizhengfeng101
lizhengfeng101 merged commit 552dc95 into alibaba:main Aug 12, 2026
7 checks passed
wu21-web added a commit to wu21-web/open-code-review that referenced this pull request Aug 12, 2026
commit 140871d
Author: Syt3s <lkxyout@gmail.com>
Date:   Wed Aug 12 18:03:34 2026 +0800

    feat(cmd): add SARIF output format (alibaba#820)

commit 552dc95
Author: Syt3s <lkxyout@gmail.com>
Date:   Wed Aug 12 16:44:35 2026 +0800

    feat(cmd): add no-review cmd (alibaba#835)

    * feat(cmd): add no-review cmd

    * docs(flags): improve --no-filter help text for clarity

    ---------

    Co-authored-by: kite <lizhengfeng.lzf@alibaba-inc.com>

commit 980f21d
Author: kite <254839944+lizhengfeng101@users.noreply.github.com>
Date:   Wed Aug 12 15:58:23 2026 +0800

    chore: remove leftover Chinese from the Go core, CI examples and pages comments (alibaba#861)

    * docs(comments): translate Chinese comments to English

    Rewrite the remaining Chinese code comments outside the VSCode extension
    in English, so the Go core and the pages site read consistently.

    - allowed_ext.go: translate the default_exclude_patterns.json package doc.
      Quote the wildcards ("*", "**", "{a,b,c}") so gofmt stops reflowing the
      leading "*" as a markdown bullet, which had swallowed the first entry's
      wildcard and broken the list alignment in godoc.
    - HighlightsSection.tsx: translate three comments in parseStatValue and
      CountUpValue.

    * docs(examples): use "Chinese" instead of "中文" in OCR_LANGUAGE examples

    The language config value is fed to the LLM, which understands "Chinese"
    just as well, and "Chinese" is what the rest of the project already uses
    (skills/open-code-review/SKILL.md, config_cmd_test.go, ApplyLanguage).
    Keeps the GitLab CI example's inline docs fully English.

    * fix(agent): drop the unreachable Chinese branch from planBlockPattern

    task_template.json ships a single English template ("### Review Plan
    (Optional)") and is embedded via go:embed with no override path, so the
    "审查计划" alternative could never match anything. It came from the
    pre-open-source template and survived the alibaba#33 fix as dead defensive code.

    Drops the two test cases that only exercised that alternative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat/add-no-review-filter

3 participants