Skip to content

lint - replace if/else if/else... with switch #391

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

Merged
merged 1 commit into from
Jun 26, 2025
Merged

Conversation

harp-intel
Copy link
Contributor

No description provided.

@harp-intel harp-intel requested a review from Copilot June 26, 2025 12:58
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors a variety of conditional constructs by replacing multiple if/else statements with switch statements to improve code clarity and readability. Key changes include:

  • Replacing if/else chains with switch statements for DIMM type handling, output processing, metric parsing, and configuration settings.
  • Updating several modules (internal/report, cmd/metrics, cmd/config) to use the new switch syntax for improved maintainability.
  • Minor improvements in formatting and structure without changing core logic.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/report/table_helpers_dimm.go Refactored if/else for handling DIMM types to a switch.
internal/report/table_helpers.go Converted conditionals into switch for cleaner logic.
internal/report/table_defs.go Updated prefetcher logic from if/else to switch.
internal/report/render_html.go Switched chart type selection from if/else to switch.
internal/report/cpu_defs.go Simplified CPU definition logic with switch statements.
internal/common/targets.go Refactored architecture detection using switch.
cmd/metrics/summary.go Updated row field assignments using switch cases.
cmd/metrics/perf.go Converted conditional flag handling to switch blocks.
cmd/metrics/metrics.go Changed scope and granularity handling to switch.
cmd/metrics/metric_defs.go Replaced granularity and conditional transforms with switch statements.
cmd/metrics/metadata.go Converted script name checks to switch statements.
cmd/metrics/event_frame.go Updated event handling logic using switch-case patterns.
cmd/config/set.go Simplified mode and setting selection using switch cases.
Comments suppressed due to low confidence (1)

internal/report/table_helpers_dimm.go:314

  • Consider adding a default case to the switch on dimmType to explicitly handle unexpected values and avoid silent failures if a new DIMMType is introduced.
	switch dimmType {

@harp-intel harp-intel merged commit 9957690 into main Jun 26, 2025
4 checks passed
@harp-intel harp-intel deleted the taggedswitch branch June 26, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant