Skip to content

ref(ui): Remove unused optional arguments and fields - #122373

Open
JonasBa wants to merge 9 commits into
getsentry:masterfrom
JonasBa:jonas/unused-optional-args-cleanup
Open

ref(ui): Remove unused optional arguments and fields#122373
JonasBa wants to merge 9 commits into
getsentry:masterfrom
JonasBa:jonas/unused-optional-args-cleanup

Conversation

@JonasBa

@JonasBa JonasBa commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #122234. This diff comes from an experimental CLI. It looks at every place a component or function is used, checks which props and optional arguments are actually passed in, and flags the ones that never are.

Summary

  • Remove unused optional arguments and object fields across static/app, static/gsApp, and static/gsAdmin.
  • Keep public component/hook/class options (onError, onSuccess, onClose, size, mutation option bags, etc.) even when nothing passes them today.
  • Where an internal helper still dropped a defaulted argument, lift the old default to a file-level const so the name stays (TRUNCATE_TEXT_MAX_LENGTH, tick intervals, etc.).
  • Restore Duration HTML attribute forwarding: Tooltip skipWrapper clones hover handlers onto the child, so dropping {...props} broke the duration tooltip.

Test plan

  • Spot-check a few high-traffic call sites that lost optional args.
  • Confirm public hooks still accept onError/onSuccess (useHandleAssigneeChange, detector form submit, assign-issue mutation).
  • CI typecheck / frontend tests.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Made with Cursor

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Aug 20, 2026
@nsdeschenes nsdeschenes added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Aug 21, 2026
@nsdeschenes
nsdeschenes marked this pull request as ready for review August 21, 2026 13:25
@nsdeschenes
nsdeschenes requested review from a team as code owners August 21, 2026 13:25
@nsdeschenes nsdeschenes self-assigned this Aug 21, 2026
@nsdeschenes
nsdeschenes marked this pull request as draft August 21, 2026 13:51
@github-actions github-actions Bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Aug 25, 2026

@nsdeschenes nsdeschenes 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.

Had an async chat regarding concerns around losing semantics when dropping arguments that have defaults values.

@JonasBa is gonna take another stab at this, to help reduce that lost value

@JonasBa

JonasBa commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@nicholas-codecov @TkDodo I've reran the mod to preserve semantics, let me know if there's anything else I should change 🙏🏼

@JonasBa
JonasBa marked this pull request as ready for review August 25, 2026 18:22
@JonasBa
JonasBa requested a review from a team as a code owner August 25, 2026 18:22
@JonasBa
JonasBa marked this pull request as draft August 25, 2026 18:23
@JonasBa

JonasBa commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up production-only unused-arg layer: #122624

@JonasBa

JonasBa commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@TkDodo @nicholas-codecov I have a followup that treats test usage as dead code (similar to knip), which hopefully drops another 3k loc. #122624

@TkDodo
TkDodo marked this pull request as ready for review August 26, 2026 06:26
Comment thread static/app/utils/performance/contexts/metricsEnhancedPerformanceDataContext.tsx Outdated

config.onHighlight?.(datum);
}
onHighlight(_dataIndex: number): void {}

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.

Time series highlight callback is a no-op

Medium Severity

Area and Line onHighlight implementations were replaced with empty bodies, so config.onHighlight never runs. Hover/highlight handlers on those plottables, including the documented time-series widget story, will not fire.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit dc8a6d8. Configure here.

@TkDodo TkDodo 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.

went over 1/3 of the code, will look at the rest later, but there are some issues I found with this:

Comment thread static/app/components/searchQueryBuilder/tokens/filter/utils.tsx
Comment thread static/app/components/core/chat/thinkingBlock.tsx
Comment thread static/app/components/events/interfaces/spans/waterfallModel.tsx
Comment thread static/app/utils/discover/urls.tsx Outdated
Comment thread static/app/utils/performance/contexts/metricsEnhancedPerformanceDataContext.tsx Outdated
Comment thread static/app/utils/profiling/hooks/useProfileEventsStats.tsx Outdated
@JonasBa

JonasBa commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

@TkDodo addressed the open comments on this pass:

  • restored setIsMetricsExtractedData(mapKey, value: boolean) so dashboard widgets still record extracted-metrics
  • dropped unused traceInfo from SpanTreeModel / WaterfallModel
  • simplified the discover event-details query object
  • removed redundant enabled: true on useProfileEventsStats

Left shouldEscapeTagValue's options arg — escapeTagValueForSearch still passes {allowArrayValue, forceQuote}.

@JonasBa JonasBa 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.

went over the rest of this PR (the files after the first pass). same class of issues: empty callbacks that still exist on the public type, and leftover undefined / enabled: true after dropping an unused arg.


config.onHighlight?.(datum);
}
onHighlight(_dataIndex: number): void {}

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.

this is wrong. onHighlight is now a no-op, but ContinuousTimeSeriesConfig.onHighlight is still a public option and Bars.onHighlight still forwards it:

onHighlight(dataIndex: number): void {
const {config = {}} = this;
const datum = this.timeSeries.values.at(dataIndex);
if (!datum) {
return;
}
config.onHighlight?.(datum);
}

the Highlighting story also says all plottables support this. restore the merged-index lookup (incomplete series prepend a point, so dataIndex is not a raw series index) or drop the option from the shared config and from Area/Line together.


config.onHighlight?.(datum);
}
onHighlight(_seriesDataIndex: number): void {}

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.

same as Area — empty onHighlight while Bars still implements the shared config. restore or delete both together.

projectSlug: project.slug,
},
{enabled: hasFeatureFlag}
{enabled: true}

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.

this can also go because enabled: true is the default. leftover from dropping hasFeatureFlag — current callers (cursorIntegrationCta / claudeCodeIntegrationCta) never passed featureFlag, so this is just noise.

subject: ctxKey,
value: data[ctxKey],
meta: meta?.[ctxKey]?.[''],
meta: undefined,

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.

this is technically correct, but meta is never passed — getPlatformContextData only calls getSpringContextData({data}). same leftover as homepage: undefined:

Suggested change
meta: undefined,
value: data[ctxKey],

): TokenResult<Token.VALUE_TEXT_LIST> | null {
try {
return parse(value, {TokenConverter, config, startRule: 'text_in_list'});
return parse(value, {TokenConverter, config: undefined, startRule: 'text_in_list'});

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.

config: undefined is leftover from dropping the unused config arg. callers only pass the string (valueCombobox, replaceCommaSeparatedValue), and the grammar already defaults config = {}. omit the key.

// In group-id mode the page-filters project selection must not hide
// the deep-linked issue — the backend still enforces access.
project: pinnedGroupIds ? -1 : (projects ?? -1),
group: undefined,

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.

group: undefined and enabled: true below are leftovers from dropping groupIds / enabled. the only caller is autofixIssuesDemo/index.tsx with {query, cursor}. don't put undefined into the query object; enabled: true is the react-query default.

useCache,
enabled,
useCache: true,
enabled: true,

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.

same leftover as useProfileEventsStats: enabled was dropped from this hook because useIssueListFilterKeys never passed it, then inlined enabled: true. useFetchOrganizationTags already treats omitted enabled as on, and useCache already defaults to true. drop both always-true args here and on the issue-platform call.

Jonas Badalic and others added 9 commits August 26, 2026 11:27
…vided.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…ooltips.

Co-authored-by: Cursor <cursoragent@cursor.com>
Rescanned with unused-props after Dominik's merge. Delete optional
arguments and fields nothing still provides, and inline the old defaults
so runtime behavior stays the same.
Keep unused optional callbacks and component/hook options in place so
call sites can still pass onError/onSuccess/onClose later. Where an
internal helper inlined a default, lift it to a file-level const so
the old argument name is not lost (e.g. truncateText maxLength).
The widget viewer modal still passes aliases into the loading
placeholder. Removing the optional prop was a type error.
Restore the metrics extracted-data setter boolean, drop leftover
traceInfo plumbing, and remove remaining homepage/enabled noise.

Co-authored-by: Cursor <cursoragent@cursor.com>
Area/Line still advertise ContinuousTimeSeriesConfig.onHighlight; empty
bodies lost that. Also remove leftover enabled:true / undefined keys.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JonasBa
JonasBa force-pushed the jonas/unused-optional-args-cleanup branch from bebe8a5 to db4ffbd Compare August 26, 2026 18:28
@TkDodo

TkDodo commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

bugbot run

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit db4ffbd. Configure here.

@TkDodo TkDodo 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.

This is 🔥 . Just went over it again and have a few more findings:

this.addOp('OR');
}
this.addFilterValue(key, values[i]!, shouldEscape);
this.addFilterValue(key, values[i]!, true);

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.

true is the default value in this.addFilterValue as well:

Suggested change
this.addFilterValue(key, values[i]!, true);
this.addFilterValue(key, values[i]!);

`${makeAutomationBasePathname(orgSlug)}new/?${qs.stringify(query)}`
);
export const makeAutomationCreatePathname = (orgSlug: string) => {
return normalizeUrl(`${makeAutomationBasePathname(orgSlug)}new/?${qs.stringify({})}`);

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.

qs.stringify({}) is a sus leftover. I guess we just want:

Suggested change
return normalizeUrl(`${makeAutomationBasePathname(orgSlug)}new/?${qs.stringify({})}`);
return normalizeUrl(`${makeAutomationBasePathname(orgSlug)}new/`);

Comment on lines 89 to +118
@@ -123,7 +115,7 @@ function WidgetLayout(props: Widget) {
)}

{props.Footer && (
<FooterWrapper noPadding={props.noFooterPadding}>
<FooterWrapper>

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.

Header and FooterWrapper still have the prop defined even though they never get it passed ,e.g.:

export const FooterWrapper = styled('div')<{noPadding?: boolean}>`
  margin: 0;
  border-top: 1px solid ${p => p.theme.tokens.border.primary};
  padding: ${p =>
    p.noPadding
      ? 0
      : `${p.theme.space.md} ${p.theme.space.xl} ${p.theme.space.md} ${p.theme.space.xl}`};
`;

}
if (billingInterval === 'monthly') {
return toDollars(cents * 12, decimals);
return toDollars(cents * 12, 0);

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.

decimals defaults to 0 so we don’t need to pass it#

Suggested change
return toDollars(cents * 12, 0);
return toDollars(cents * 12);

maybe we should have a no-exact-default-value lint rule that checks if you pass a hardcoded value to an optional param that is equal to its default value 🤔 ?

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.

of course I nerd-sniped myself into making one:

return toDollars(cents * 12, 0);
}
return toDollars(cents, decimals);
return toDollars(cents, 0);

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.

Suggested change
return toDollars(cents, 0);
return toDollars(cents);

}: {
product: AddOnCategory;
withPunctuation: boolean;
includedBudget?: string;

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.

just saying it’s wild that this isn’t flagged by some lint rule already. like the prop isn’t destructed at all so why is it there lol

size="sm"
href={href}
to={to ?? ''}
to=""

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.

I think we can omit this param if we pass an href

let effectiveReservedSpend: number | undefined;

if (
(effectiveReservedCpe === undefined || effectiveReservedSpend === undefined) &&

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.

at this point, effectiveReservedSpend is always undefined

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

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants