Skip to content

chore(eslint): enable no-useless-assignment rule#1055

Draft
carlosthe19916 wants to merge 5 commits into
guacsec:mainfrom
carlosthe19916:hotfix/enable-no-useless-assignment
Draft

chore(eslint): enable no-useless-assignment rule#1055
carlosthe19916 wants to merge 5 commits into
guacsec:mainfrom
carlosthe19916:hotfix/enable-no-useless-assignment

Conversation

@carlosthe19916
Copy link
Copy Markdown
Collaborator

@carlosthe19916 carlosthe19916 commented May 27, 2026

Summary

  • Remove the no-useless-assignment override from ESLint config
  • Replace useless initial assignments with const + ternary or uninitialized let declarations

Test plan

  • npm run lint passes with 0 warnings

🤖 Generated with Claude Code

Summary by Sourcery

Enable the ESLint no-useless-assignment rule by removing its override and updating code to avoid unnecessary variable reassignments.

Enhancements:

  • Simplify conditional value computation by using direct const assignments with ternaries instead of mutable temporaries.
  • Remove unused initializations by declaring variables without default values where they are later assigned conditionally.
  • Streamline local sorting logic by creating sorted arrays directly instead of reassigning existing variables.
  • Improve download verification error handling by returning early on success and preserving the original error as the cause in thrown errors.

Build:

  • Update ESLint configuration to stop disabling the no-useless-assignment rule.

Remove initial values that are immediately overwritten in both
branches of if/else blocks, using const + ternary or uninitialized let.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 27, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Enables the ESLint no-useless-assignment rule by removing its override and refactors several TypeScript/Playwright helpers and hooks to eliminate unnecessary initial variable assignments in favor of direct const initialization, uninitialized lets, and cleaner return/throw flows.

File-Level Changes

Change Details Files
Refactor severity text construction in vulnerability explorer step to avoid temporary mutable variable.
  • Replace mutable let severity plus if/else assignments with a single const severity using a ternary expression
  • Preserve existing branching logic for "Unknown" vs scored severities while simplifying control flow
e2e/tests/ui/features/@vulnerability-explorer/vulnerability-explorer.step.ts
Simplify error notification title resolution hook to initialize once via ternary.
  • Replace let title plus conditional reassignment with const title using ternary on typeof message
  • Keep behavior identical for string messages vs message callback functions while complying with no-useless-assignment
client/src/app/hooks/useNotifyErrorCallback.ts
Tighten download verification helper to return directly and surface original error as a cause.
  • Remove unnecessary filename variable and return download.suggestedFilename() directly inside try block
  • Wrap thrown error with a more descriptive message and pass original error via the cause option
e2e/tests/ui/pages/Helpers.ts
Adjust SBOM vulnerability mapping helpers to declare advisory-related variables without useless initializers.
  • Change opinionatedAdvisory from let ... = null to uninitialized let with same nullable type
  • Change opinionatedScore from let ... = null to uninitialized let with same nullable type
  • Apply the same pattern in both domain-controls and sbom-scan hooks
client/src/app/hooks/domain-controls/useVulnerabilitiesOfSbom.ts
client/src/app/pages/sbom-scan/hooks/useVulnerabilitiesOfSbom.ts
Simplify local sort derived state helper to initialize sorted items directly from sorted copy.
  • Replace let sortedItems = items followed by reassignment with a single const sortedItems set to the sorted copy of items
  • Retain sort behavior via existing comparator and sort value extraction
client/src/app/hooks/table-controls/sorting/getLocalSortDerivedState.ts
Enable ESLint no-useless-assignment rule for the project.
  • Remove the no-useless-assignment rule override that previously disabled the rule in the shared ESLint config
eslint.config.mjs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In both useVulnerabilitiesOfSbom implementations, opinionatedAdvisory and opinionatedScore are now declared without initial values; double-check that all control-flow paths assign them before use, or initialize them to null to avoid potential undefined usage at runtime.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In both `useVulnerabilitiesOfSbom` implementations, `opinionatedAdvisory` and `opinionatedScore` are now declared without initial values; double-check that all control-flow paths assign them before use, or initialize them to `null` to avoid potential undefined usage at runtime.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@carlosthe19916 carlosthe19916 marked this pull request as draft May 27, 2026 12:14
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 50.69%. Comparing base (16a6bec) to head (a756f65).

Files with missing lines Patch % Lines
client/src/app/hooks/useNotifyErrorCallback.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1055      +/-   ##
==========================================
+ Coverage   50.68%   50.69%   +0.01%     
==========================================
  Files         253      253              
  Lines        5499     5490       -9     
  Branches     1660     1659       -1     
==========================================
- Hits         2787     2783       -4     
+ Misses       2440     2436       -4     
+ Partials      272      271       -1     
Flag Coverage Δ
e2e 68.92% <100.00%> (-0.02%) ⬇️
unit 2.01% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

carlosthe19916 and others added 3 commits May 28, 2026 17:12
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant