ref(ui): Remove unused optional arguments and fields - #122373
Conversation
nsdeschenes
left a comment
There was a problem hiding this comment.
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
|
@nicholas-codecov @TkDodo I've reran the mod to preserve semantics, let me know if there's anything else I should change 🙏🏼 |
|
Follow-up production-only unused-arg layer: #122624 |
|
@TkDodo @nicholas-codecov I have a followup that treats test usage as dead code (similar to knip), which hopefully drops another 3k loc. #122624 |
|
|
||
| config.onHighlight?.(datum); | ||
| } | ||
| onHighlight(_dataIndex: number): void {} |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit dc8a6d8. Configure here.
TkDodo
left a comment
There was a problem hiding this comment.
went over 1/3 of the code, will look at the rest later, but there are some issues I found with this:
|
@TkDodo addressed the open comments on this pass:
Left |
JonasBa
left a comment
There was a problem hiding this comment.
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 {} |
There was a problem hiding this comment.
this is wrong. onHighlight is now a no-op, but ContinuousTimeSeriesConfig.onHighlight is still a public option and Bars.onHighlight still forwards it:
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 {} |
There was a problem hiding this comment.
same as Area — empty onHighlight while Bars still implements the shared config. restore or delete both together.
| projectSlug: project.slug, | ||
| }, | ||
| {enabled: hasFeatureFlag} | ||
| {enabled: true} |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
this is technically correct, but meta is never passed — getPlatformContextData only calls getSpringContextData({data}). same leftover as homepage: undefined:
| 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'}); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
…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>
bebe8a5 to
db4ffbd
Compare
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
1 issue from previous review remains unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit db4ffbd. Configure here.
TkDodo
left a comment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
true is the default value in this.addFilterValue as well:
| 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({})}`); |
There was a problem hiding this comment.
qs.stringify({}) is a sus leftover. I guess we just want:
| return normalizeUrl(`${makeAutomationBasePathname(orgSlug)}new/?${qs.stringify({})}`); | |
| return normalizeUrl(`${makeAutomationBasePathname(orgSlug)}new/`); |
| @@ -123,7 +115,7 @@ function WidgetLayout(props: Widget) { | |||
| )} | |||
|
|
|||
| {props.Footer && ( | |||
| <FooterWrapper noPadding={props.noFooterPadding}> | |||
| <FooterWrapper> | |||
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
decimals defaults to 0 so we don’t need to pass it#
| 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 🤔 ?
There was a problem hiding this comment.
of course I nerd-sniped myself into making one:
| return toDollars(cents * 12, 0); | ||
| } | ||
| return toDollars(cents, decimals); | ||
| return toDollars(cents, 0); |
There was a problem hiding this comment.
| return toDollars(cents, 0); | |
| return toDollars(cents); |
| }: { | ||
| product: AddOnCategory; | ||
| withPunctuation: boolean; | ||
| includedBudget?: string; |
There was a problem hiding this comment.
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="" |
There was a problem hiding this comment.
I think we can omit this param if we pass an href
| let effectiveReservedSpend: number | undefined; | ||
|
|
||
| if ( | ||
| (effectiveReservedCpe === undefined || effectiveReservedSpend === undefined) && |
There was a problem hiding this comment.
at this point, effectiveReservedSpend is always undefined


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
static/app,static/gsApp, andstatic/gsAdmin.onError,onSuccess,onClose,size, mutation option bags, etc.) even when nothing passes them today.TRUNCATE_TEXT_MAX_LENGTH, tick intervals, etc.).DurationHTML attribute forwarding:Tooltip skipWrapperclones hover handlers onto the child, so dropping{...props}broke the duration tooltip.Test plan
onError/onSuccess(useHandleAssigneeChange, detector form submit, assign-issue mutation).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