Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insights(sus): remove unused parameter alert #45530

Merged
merged 4 commits into from
Dec 12, 2022

Conversation

jhchabran
Copy link
Member

@jhchabran jhchabran commented Dec 12, 2022

Stumbled across this while re-enabling linters. I'm not sure to fully understand the logic and as I'm focused on the linters themselves, I'd rather let you have a second look to ensure nothing fishy is happening there.

The unkeyed structs changes are unrelated, that's just me grinding through the warnings.

  • TODO remove the sus prefixing this commit

Test plan

CI + careful review from @sourcegraph/code-insights

@@ -154,7 +153,7 @@ func (r *searchAggregateResolver) Aggregations(ctx context.Context, args graphql
searchClient := streaming.NewInsightsSearchClient(r.postgresDB)
searchResultsAggregator := aggregation.NewSearchResultsAggregatorWithContext(requestContext, tabulationFunc, countingFunc, r.postgresDB)

alert, err := searchClient.Search(requestContext, string(modifiedQuery), &r.patternType, searchResultsAggregator)
Copy link
Member Author

Choose a reason for hiding this comment

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

@leonore here is the suspicious thing

Copy link
Contributor

Choose a reason for hiding this comment

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

what linter did you re-enable? it's curious that this is the line it modifies when we use the same syntax for declaring errors across other calls (e.g. https://sourcegraph.com/github.com/sourcegraph/sourcegraph@7794a49876469af1922c776b48f79c1f9f713af9/-/blob/enterprise/internal/insights/resolvers/aggregates_resolvers.go?L142)

Copy link
Member Author

Choose a reason for hiding this comment

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

it's unparam

   enterprise/internal/insights/resolvers/aggregates_resolvers.go:236:23: `searchSuccessful` - `alert` is unused (unparam)
   func searchSuccessful(alert *search.Alert, tabulationErrors []error, shardTimeoutOccurred, runningWithExtendedTimeout, resultLimitHit bool) (bool, notAvailableReason) {
                         ^

And there are some others, which I'm putting here just in case:

   enterprise/internal/insights/resolvers/insight_view_resolvers.go:625:203: `updateCaptureGroupInsight` - `backfiller` is unused (unparam)
   func updateCaptureGroupInsight(ctx context.Context, input graphqlbackend.LineChartSearchInsightDataSeriesInput, existingSeries []types.InsightViewSeries, view types.InsightView, tx *store.InsightStore, backfiller *background.ScopedBackfiller, seriesFillStrategy fillSeriesStrategy) error {
                                                                                                                                                                                                             ^
   enterprise/internal/insights/resolvers/insight_view_resolvers.go:651:202: `updateSearchOrComputeInsight` - `backfiller` is unused (unparam)
   func updateSearchOrComputeInsight(ctx context.Context, input graphqlbackend.UpdateLineChartSearchInsightInput, existingSeries []types.InsightViewSeries, view types.InsightView, tx *store.InsightStore, backfiller *background.ScopedBackfiller, seriesFillStrategy fillSeriesStrategy) error {
                                                                                                                                                                                                            ^
   enterprise/internal/insights/resolvers/insight_view_resolvers.go:1236:167: `v1HistoricFill` - `insightEnqueuer` is unused (unparam)
   func v1HistoricFill(ctx context.Context, deprecateJustInTime bool, series types.InsightSeries, tx *store.InsightStore, scopedBackfiller *background.ScopedBackfiller, insightEnqueuer *background.InsightEnqueuer) error {
                                                                                                                                                                         ^
   enterprise/internal/insights/resolvers/insight_view_resolvers.go:1252:195: createAndAttachSeries - result 0 (*github.com/sourcegraph/sourcegraph/enterprise/internal/insights/types.InsightSeries) is never used (unparam)
   func createAndAttachSeries(ctx context.Context, tx *store.InsightStore, startSeriesFill fillSeriesStrategy, view types.InsightView, series graphqlbackend.LineChartSearchInsightDataSeriesInput) (*types.InsightSeries, error) {

Copy link
Contributor

Choose a reason for hiding this comment

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

ty! I know the logic behind most of these and can resolve those issues, just want to confirm with @chwarwick why we don't assert on the alert in searchSuccessful?

Copy link
Contributor

Choose a reason for hiding this comment

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

@leonore I believe the only alert at the time was the timeout, and in general because alerts come with results we decided it was better to show what results we got than to show an error unlike in a the other insight case where we want to hold off and ensure there was a full exhaustive result.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, in that case I'll just remove the parameter from the function then

Copy link
Contributor

Choose a reason for hiding this comment

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

the PR already removes it actually, @chwarwick since half of this PR is now my code can you review and approve if it looks good?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd appreciate it if we could go quick on this, as I'll get blocked in merging the upcoming PR for linters if this sticks around too long :)

Copy link
Member Author

Choose a reason for hiding this comment

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

👀 #45548

@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Dec 12, 2022

Codenotify: Notifying subscribers in CODENOTIFY files for diff 7794a49...8e21ab1.

Notify File(s)
@sourcegraph/code-insights-backend enterprise/internal/insights/resolvers/aggregates_resolvers.go
enterprise/internal/insights/resolvers/insight_view_resolvers.go
enterprise/internal/insights/resolvers/insight_view_resolvers_test.go
enterprise/internal/insights/store/store_test.go

@jhchabran jhchabran merged commit 9dabaf7 into main Dec 12, 2022
@jhchabran jhchabran deleted the jh/grind-unused/insights-alert branch December 12, 2022 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants