Skip to content

Apply the small-value-space guard to null-valued constants in no-duplicate-constant-values - #51542

Merged
pelikhan merged 2 commits into
mainfrom
copilot/fix-no-duplicate-constant-values
Aug 9, 2026
Merged

Apply the small-value-space guard to null-valued constants in no-duplicate-constant-values#51542
pelikhan merged 2 commits into
mainfrom
copilot/fix-no-duplicate-constant-values

Conversation

Copilot AI commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

no-duplicate-constant-values raises the minimum duplicate-group size to 3 for numbers and booleans to avoid coincidental matches in small value spaces, but null literals key to object:null and so fell through to the generic threshold of 2. null has exactly one possible value — a smaller space than booleans — so it is the primitive most prone to the false positive the boolean guard exists to prevent:

// previously reported as a duplicate at group size 2
const CACHED_TOKEN = null;
const PENDING_RESULT = null;

Changes

  • src/rules/no-duplicate-constant-values.ts — added MIN_NULL_DUPLICATE_GROUP_SIZE = 3 (and a NULL_VALUE_KEY constant) with a comment mirroring the existing boolean rationale. Extracted the threshold selection out of the inline nested ternary into getMinDuplicateGroupSize(valueKey), which now covers the null case. Matches exactly on object:null rather than an object: prefix, since regexps are keyed separately.
  • src/rules/no-duplicate-constant-values.test.ts — valid case for two null constants; invalid case for three, mirroring the boolean test structure.
  • README.md — rule description now lists null alongside numeric and boolean in the raised-threshold sentence.

String, number, boolean, and regexp behavior is unchanged. undefined is an identifier rather than a literal and was already out of scope.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix no-duplicate-constant-values rule with null-valued constants Apply the small-value-space guard to null-valued constants in no-duplicate-constant-values Aug 9, 2026
Copilot AI requested a review from pelikhan August 9, 2026 06:34
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: bug
  • Risk: low
  • Priority: low
  • Score: 12/100 (impact 5 + urgency 5 + quality 2)
  • Recommended action: defer
    Batch: wip-inprogress\n
    WIP, agent just started, empty diff, CI in-progress.

Generated by 🔧 PR Triage Agent · auto · 58.3 AIC · ⌖ 2.48 AIC · ⊞ 8K ·

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🎉 Thanks for this contribution! This PR looks great and is ready for review.

Summary: The fix properly extends the small-value-space guard from numeric and boolean constants to null values, which have the smallest possible value space (one value). This prevents false positives in the no-duplicate-constant-values linter rule.

What stands out:

This is a solid, focused fix that improves the linter's accuracy. Well done!

Generated by ✅ Contribution Check · auto · 96.3 AIC · ⌖ 2.88 AIC · ⊞ 8.8K ·

@pelikhan
pelikhan marked this pull request as ready for review August 9, 2026 11:12
Copilot AI balanced review requested due to automatic review settings August 9, 2026 11:12
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • api.individual.githubcopilot.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.individual.githubcopilot.com"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship. Reviewed the 3-file diff (README sentence, one test case, and a getMinDuplicateGroupSize extraction that replaced a nested ternary with an equally-sized named function). No dead code, speculative flexibility, or reinvented stdlib found.

Generated by Ponytail Reviewer for #51542

Copilot AI 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.

Pull request overview

Updates the ESLint rule to reduce false positives for repeated null constants.

Changes:

  • Applies a minimum duplicate-group size of three to null.
  • Adds valid and invalid null test cases.
  • Documents the updated threshold behavior.
Show a summary per file
File Description
eslint-factory/src/rules/no-duplicate-constant-values.ts Adds and applies the null threshold.
eslint-factory/src/rules/no-duplicate-constant-values.test.ts Tests groups of two and three null constants.
eslint-factory/README.md Documents null threshold behavior.

Review details

Tip

Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions github-actions Bot 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.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — approving.

📋 Key Themes & Highlights

Positive Highlights

  • ✅ Root cause properly addressed: null keys as object:null and now gets the same guard as booleans and numbers
  • ✅ Clean extraction of the nested ternary into getMinDuplicateGroupSize() — improves readability and extensibility
  • NULL_VALUE_KEY constant avoids a magic string and makes the exact-match intent explicit
  • ✅ Tests mirror the boolean guard test structure, covering both the valid (2 constants) and invalid (3 constants) case
  • ✅ README updated in the same commit

Minor Observation

The two-null valid case is asserted twice: in the catch-all valid block and in the dedicated null threshold test. Neither is incorrect, but the first occurrence is slightly redundant — removing it from the catch-all would keep each test focused on a single concern.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 15.4 AIC · ⌖ 7.45 AIC · ⊞ 7.1K
Comment /matt to run again

@github-actions github-actions Bot 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.

The implementation is correct and well-reasoned. null has a value space of 1, making the same minimum-group-size guard appropriate as for booleans. The refactoring into getMinDuplicateGroupSize also improves readability. Tests and docs are updated consistently.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 12.5 AIC · ⌖ 6.73 AIC · ⊞ 5.5K

@pelikhan
pelikhan merged commit a0d8fec into main Aug 9, 2026
48 checks passed
@pelikhan
pelikhan deleted the copilot/fix-no-duplicate-constant-values branch August 9, 2026 11:21
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.86.2

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

Projects

None yet

3 participants