lint - replace if/else if/else... with switch - #391
Merged
Conversation
Signed-off-by: Harper, Jason M <jason.m.harper@intel.com>
Contributor
There was a problem hiding this comment.
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 {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.