Skip to content

fix(sonar): tier-3 mechanical fixes — 25 issues (risky + 1 bug) - #228

Open
huandrey wants to merge 36 commits into
mainfrom
fix/sonar-risky-20260902150007
Open

huandrey wants to merge 36 commits into
mainfrom
fix/sonar-risky-20260902150007

Conversation

@huandrey

@huandrey huandrey commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

SonarQube auto-fix — tier 3 escalation (risky + 1 bug), Mechanical difficulty

Generated by sonar-autofix Phase 3. Every one of these Tier-3 issues was first analyzed (Impact/Difficulty/Approach/Context), and only the ones classified Mechanical were escalated to fix+judge. Each commit resolves one issue and was independently reviewed by a judge-agent, which empirically re-ran ESLint against pre/post-fix file content, and re-verified "unused PropType" claims by grepping the whole react/ tree (including context/HOC injection paths) rather than trusting the fix-agent's own report — precisely because one true positive of that shape was already found and filed separately (see below).

2 issues were rejected by the judge and are NOT in this PR, both javascript:S6747 (SVG mask-type property) in PinLocationUnknown.js:37 and PinNoPickups.js:36: the proposed mask-type → maskType rename does not fix the underlying "unknown property" condition (React still doesn't recognize maskType either) and actually regresses behavior — it changes the rendered DOM attribute and introduces a new React dev-console warning that didn't exist before. Left untouched; needs a different fix (likely dangerouslySetInnerHTML or wrapping the value so React skips its SVG-attribute translation).

Rule File Line Issue
javascript:S7724 react/mocks/vtex.address-form.js 21 name the suppressed rule
javascript:S6774 react/assets/components/RefreshIcon.js 5 add missing PropType classes
javascript:S6774 react/assets/components/SearchOverlay.js 8 add missing PropType searchedAreaNoPickups
javascript:S6767 react/assets/components/Spinner.js 73 remove dead PropType block
css:S4657 react/components/GeolocationStatus.css 38 dead margin-bottom removed (the shorthand already zeroed it, so the rendering is unchanged)
javascript:S1301 react/components/Button.js 20 switch→if readability
javascript:S7724 ×3 react/components/Button.js 43,44,46 dead unscoped eslint-disable removed (verified unused via --report-unused-disable-directives)
javascript:S7724 ×2 + S6767 react/components/Input.js 38,39 dead unscoped eslint-disable removed; unused disabled PropType removed
javascript:S6767 ×4 react/components/PickupPointInfo.js 259,265,269,271 dead PropTypes removed
javascript:S6767 react/components/PickupPointsList.js 201 dead PropType changeActivePickupDetails removed
css:S4666 react/components/SearchForm.css 93 duplicate-selector merge on .askGeolocationBtn
javascript:S7724 react/components/SearchForm.js 197 named the suppressed rule (react/no-unused-prop-types)
javascript:S6767 ×3 react/components/SearchForm.js 211,212,214 dead PropTypes removed (setActiveState,setGeolocationStatus,status)
javascript:S6775 react/components/SearchingState.js 38 dropped .isRequired on isFullPage — it's genuinely optional per call sites
javascript:S6767 ×2 react/components/SidebarStateHandler.js 106,111 dead PropTypes removed (pickupOptions,selectedPickupPoint)
javascript:S7724 react/containers/IntlContainer.js 35 named the suppressed rule (camelcase, required by UNSAFE_ lifecycle prefix)

Skipped in this group: 2 (both javascript:S6747, see above — rejected by judge, not attempted elsewhere).

Changes after review (2026-09-10)

  • Backed out the 6 css:S7924 contrast fixes (Button.css, PickupTabs.css ×2, SearchArea.css, SearchForm.css ×2). They change brand colors in every store's checkout, so they need a design decision, not an auto-fix. They will be marked Accepted in SonarQube.
  • GeolocationStatus.css: the first fix expanded the shorthand, which made margin-bottom: 30px take effect and shifted the layout. Now the dead declaration is removed and the rendering is identical to main.
  • Input.js: removed the unused disabled PropType. It was the new issue failing the Quality Gate: the removed eslint-disable-line was hiding exactly this S6767.

Related: filed #227 separately for react/components/SearchArea.js's shouldShow PropType — deleting it would have masked a real prop-wiring bug (parent passes shouldShow, component reads a differently-named shouldSearchArea from context), so it was excluded from this auto-fix pass and filed as a real bug instead.

…orm mock

Blanket `// eslint-disable-next-line` silenced every rule for the React
import; scoped it to the one rule it actually suppresses (no-unused-vars).

File: react/__mocks__/vtex.address-form.js:21
Rule: javascript:S7724
…on's classes prop

Verified the only consumer (react/components/SearchArea.js) passes
`classes={styles.refreshIcon}` as expected; the prop was genuinely used
but never declared in props validation.

File: react/assets/components/RefreshIcon.js:5
Rule: javascript:S6774
…rlay's injected prop

Verified `searchedAreaNoPickups` is injected via ModalState's injectState
HOC (matches the `boolean` field of the same name in modalStateContext.tsx)
and genuinely used in render; it was just missing from props validation.

File: react/assets/components/SearchOverlay.js:8
Rule: javascript:S6774
Verified across react/: Spinner is only used in SearchingState.js and
PickupPointsList.js, neither passes `block`; Spinner's render() never
reads this.props.block and does not spread props onto the <svg>. Removed
the unused propType and its matching defaultProp.

File: react/assets/components/Spinner.js:73
Rule: javascript:S6767
…G AA contrast

White text (#fff) on the old #368df7 background was 3.33:1, below the
4.5:1 minimum for normal text. Darkened to #1f6fdb (4.82:1). Also
darkened the :hover background from #2c7de0 to #175ec0 (6.18:1) so hover
stays darker than the new base color instead of becoming lighter.

File: react/components/Button.css:29
Rule: css:S7924
…argin-bottom

The `margin: -15px auto 0;` shorthand set margin-bottom to 0, completely
overriding the margin-bottom: 30px declared on the previous line (dead
declaration). Replaced with explicit longhand margin-top/-right/-bottom/
-left so both the top pull-up and the bottom spacing take effect.

File: react/components/GeolocationStatus.css:38
Rule: css:S4657
…e in Button

The switch in Button's render had only one case clause ('secondary') plus a
default, which is overkill for a single condition. Replaced it with an
if/else on kind === 'secondary' to improve readability.

File: react/components/Button.js:20
Rule: javascript:S1301
… Button disabled propType

The `// eslint-disable-line` on the `disabled` propType named no rule, so it
silently suppressed every ESLint rule for that line. Verified with
`eslint --report-unused-disable-directives` that no rule currently fires
there (disabled is used in render and typed correctly), so the directive was
dead weight rather than a real suppression need — removed it instead of
inventing a rule name.

File: react/components/Button.js:43 (originally; now line 39 after the S1301 fix)
Rule: javascript:S7724
… Button inline propType

Same issue as the disabled propType: the bare `// eslint-disable-line`
named no rule. `eslint --report-unused-disable-directives` confirms no
rule fires on this line under the current config, so the directive was
dead and was removed rather than assigned a fabricated rule name.

File: react/components/Button.js:44 (originally; now line 39 after prior fixes)
Rule: javascript:S7724
… Button large propType

Same issue as the disabled/inline propTypes: the bare `// eslint-disable-line`
named no rule. `eslint --report-unused-disable-directives` now runs clean on
Button.js, confirming the directive was dead and safe to remove.

File: react/components/Button.js:46 (originally; now line 39 after prior fixes)
Rule: javascript:S7724
… Input autoFocus propType

The bare `// eslint-disable-line` on the autoFocus propType named no rule.
`eslint --report-unused-disable-directives` confirms no rule currently
fires there, so the directive was dead and removed instead of guessing a
rule name to keep.

File: react/components/Input.js:38
Rule: javascript:S7724
… Input disabled propType

Same issue as autoFocus: the bare `// eslint-disable-line` on the disabled
propType named no rule. `eslint --report-unused-disable-directives` now
runs clean on Input.js, confirming the directive was dead and safe to
remove.

File: react/components/Input.js:39
Rule: javascript:S7724
…PickupPointId' from PickupPointInfo

File: react/components/PickupPointInfo.js:259
Rule: javascript:S6767
…arState' from PickupPointInfo

File: react/components/PickupPointInfo.js:265
Rule: javascript:S6767
…rom PickupPointInfo

Also drops the now-orphaned showAddress entry in defaultProps, since it
is the same unused prop declaration split across the two required
PropTypes API locations.

File: react/components/PickupPointInfo.js:269
Rule: javascript:S6767
…tails' from PickupPointInfo

File: react/components/PickupPointInfo.js:271
Rule: javascript:S6767
…ckupDetails' from PickupPointsList

File: react/components/PickupPointsList.js:201
Rule: javascript:S6767
…trast

White text (#fff) on the previous #357edd background only reached a
~4.06:1 contrast ratio, below the WCAG AA minimum of 4.5:1 for normal
text. Darkening the active tab background/border to #3071c7 raises the
ratio to ~4.87:1 while keeping the same hue.

File: react/components/PickupTabs.css:27
Rule: css:S7924
…r AA contrast

File: react/components/PickupTabs.css:38
Rule: css:S7924
…lor for AA contrast

File: react/components/SearchArea.css:21
Rule: css:S7924
…ontrast

File: react/components/SearchForm.css:82
Rule: css:S7924
Merged the second .askGeolocationBtn block's opacity: 0.9 declaration
into the first occurrence and removed the redundant duplicate selector.

File: react/components/SearchForm.css:93
Rule: css:S4666
…r AA contrast

File: react/components/SearchForm.css:99
Rule: css:S7924
…ocation's eslint-disable

The bare `eslint-disable-line` suppressed react/no-unused-prop-types
without naming it, silently hiding any other lint issue on that line.

File: react/components/SearchForm.js:197
Rule: javascript:S7724
…from SearchForm

Verified setActiveState is never read inside SearchForm.js (no
destructure, no this.props access); the real consumers are
Geolocation.js, ErrorState.js and PickupSidebar.js, which receive it
independently.

File: react/components/SearchForm.js:211
Rule: javascript:S6767
…pType from SearchForm

Verified setGeolocationStatus is never read inside SearchForm.js (no
destructure, no this.props access); the real consumer is
Geolocation.js, which receives it independently via injectGeolocation.

File: react/components/SearchForm.js:212
Rule: javascript:S6767
…earchForm

The 'status' prop was declared in SearchForm.propTypes but never read inside
the component. Geolocation permission state is provided instead via the
injectGeolocation HOC as 'permissionStatus', which is what render() and
handleGeolocationClick actually consume. Confirmed dead: no reference to
this.props.status anywhere in SearchForm.js, and EmptySearch.js's
status={geolocationStatus} passthrough is redundant leftover from before the
HOC-based permissionStatus wiring was introduced.

File: react/components/SearchForm.js:214
Rule: javascript:S6767
isFullPage was declared PropTypes.bool.isRequired while also having a
default of true, which is contradictory (a required prop can't have a
default). Checked all call sites: StateHandler.js renders <SearchingState
activeState={activeState} /> without isFullPage (relying on the true
default), while SidebarStateHandler.js explicitly passes isFullPage={false}.
Since it is not always provided by every caller, the prop is genuinely
optional — dropped isRequired and kept the default.

File: react/components/SearchingState.js:38
Rule: javascript:S6775
… from SidebarStateHandler

'pickupOptions' was declared as a required prop but never read in
SidebarStateHandler.render(). Verified this is not masking a wiring bug:
the LIST case renders <PickupPointsList>, and PickupPointsList is itself
wrapped with injectState (react/modalStateContext.tsx), which spreads the
full ModalState context — including pickupOptions — onto its own props
after any explicitly passed props. So PickupPointsList already receives
pickupOptions directly from context regardless of what SidebarStateHandler
does with it, making the local declaration here dead.

File: react/components/SidebarStateHandler.js:106
Rule: javascript:S6767
…opType from SidebarStateHandler

'selectedPickupPoint' was declared in propTypes but never read in
SidebarStateHandler.render(). Same safety check applied as for
'pickupOptions': the DETAILS case renders <PickupPointDetails>, which is
wrapped with injectState and therefore receives selectedPickupPoint
directly from the shared ModalState context (react/modalStateContext.tsx),
independent of whatever SidebarStateHandler does with its own prop of the
same name. No downstream logic depends on SidebarStateHandler forwarding
this value, so the declaration here is genuinely dead.

File: react/components/SidebarStateHandler.js:111
Rule: javascript:S6767
The eslint-disable-next-line above UNSAFE_componentWillReceiveProps was
bare, disabling every rule for that line instead of the one it actually
needs. Ran eslint against the method name alone (temporarily removing the
disable) to confirm the only violation is 'camelcase', triggered by the
required UNSAFE_ lifecycle prefix. Scoped the disable to that rule.

File: react/containers/IntlContainer.js:35
Rule: javascript:S7724
@huandrey
huandrey requested a review from a team as a code owner September 2, 2026 18:02
@vtex-io-ci-cd

vtex-io-ci-cd Bot commented Sep 2, 2026

Copy link
Copy Markdown

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-pr-sentinel

Copy link
Copy Markdown

🛡️ SDD Check — action required

I couldn't detect an SDD in this PR. Please check one option below (requires write access to the repo):

  • SDD lives in another PR — paste the SDD PR URL here:
  • This PR doesn't need an SDD
  • SDD applies, but I'm not adopting it in this PR

@huandrey huandrey added the sonar label Sep 2, 2026
@huandrey huandrey self-assigned this Sep 2, 2026
huandrey and others added 4 commits September 10, 2026 14:34
The WCAG AA contrast fixes change brand colors (primary button, pickup
tabs, search-area and geolocation buttons) in every store's checkout, so
they need a design decision rather than an auto-fix. The six S7924
findings will be marked as Accepted in SonarQube instead.

Reverts e3eb922, 70a2bda, dffebfa, 45a3181, 97380e3 and bcd08ff.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdDDu2mUJJfM3vfG227Uqr
…ng it

The shorthand below it has always zeroed margin-bottom, so production
renders the shadow with a 0 bottom margin. Expanding the shorthand made
the 30px effective and shifted the layout; removing the dead declaration
fixes the finding while keeping the current rendering.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdDDu2mUJJfM3vfG227Uqr
Input never reads or forwards `disabled`; the removed eslint-disable was
hiding exactly this finding, which the PR quality gate surfaced as new.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdDDu2mUJJfM3vfG227Uqr
@huandrey huandrey changed the title fix(sonar): tier-3 mechanical fixes — 31 issues (risky + 1 bug) fix(sonar): tier-3 mechanical fixes — 25 issues (risky + 1 bug) Sep 10, 2026

@huandrey huandrey left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Self-review follow-up (commits 66ae083..fd6e3dc). Three changes since the first version:

  1. Backed out all 6 css:S7924 (contrast) fixes. They changed brand colors (primary button, tabs, search area, geolocation button) in every store's checkout. That needs design/PO sign-off, not an auto-fix. They will be marked Accepted in SonarQube.
  2. GeolocationStatus.css: see the inline note.
  3. Input.js: see the inline note. This was the 1 new issue failing the Quality Gate.

width: 30px;
height: 30px;
border-radius: 80px;
margin-bottom: 30px;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The first version expanded margin: -15px auto 0 into longhands, which made margin-bottom: 30px take effect. The shadow had always rendered with a 0 bottom margin (the shorthand below always won), so that was a silent layout change. Now the dead declaration is removed instead: S4657 is fixed and the rendering stays identical to main.

Comment thread react/components/Input.js
address: AddressShapeWithValidation,
autoFocus: PropTypes.bool, // eslint-disable-line
disabled: PropTypes.bool, // eslint-disable-line
autoFocus: PropTypes.bool,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The unused disabled PropType is removed as well: Input never reads or forwards it (it has no ...rest on <input>). Sonar flagged it as a new issue (S6767) once the // eslint-disable-line that was hiding it came out. That was the finding failing the gate.

@sonar-workflows

Copy link
Copy Markdown

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant