Skip to content

Commit

Permalink
treewide: Fix BugproneMissingSwitchDefaultCase for linter
Browse files Browse the repository at this point in the history
The to be fixed cases can fall in three categories:
- GUI switch statements for controls and window hooks: We always want to
  not do anything in the default clause
- Cases were we iterated over all possible values, this needs an
  assertion or a FAIL statement for the tests
- Cases were we don't want to do anything for certain values. This is
  mostly done with a comment.
  • Loading branch information
t-b committed Feb 10, 2025
1 parent 9e531cb commit 728a51e
Show file tree
Hide file tree
Showing 54 changed files with 675 additions and 25 deletions.
3 changes: 2 additions & 1 deletion Packages/MIES/MIES_AmplifierInteraction.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ Function AI_UpdateAmpModel(string device, string ctrl, variable headStage, [vari
case "button_DataAcq_AutoPipOffset_VC":
runMode = TP_StopTestPulseFast(device)
default:
// do nothing
// do nothing
break
endswitch

for(i = 0; i < NUM_HEADSTAGES; i += 1)
Expand Down
33 changes: 33 additions & 0 deletions Packages/MIES/MIES_AnalysisBrowser.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,9 @@ static Function/S AB_LoadLabNotebookFromFile(string discLocation)
case ANALYSISBROWSER_FILE_TYPE_NWBv2:
deviceList = AB_LoadLabNotebookFromNWB(map[%DiscLocation])
break
default:
ASSERT(0, "Unsupported file type")
break
endswitch

return deviceList
Expand Down Expand Up @@ -2661,6 +2664,8 @@ Function AB_ButtonProc_ExpandAll(STRUCT WMButtonAction &ba) : ButtonControl
AB_ExpandListColumn(EXPERIMENT_TREEVIEW_COLUMN)
AB_ExpandListColumn(DEVICE_TREEVIEW_COLUMN)
break
default:
break
endswitch

return 0
Expand All @@ -2675,6 +2680,8 @@ Function AB_ButtonProc_CollapseAll(STRUCT WMButtonAction &ba) : ButtonControl
AB_CollapseListColumn(DEVICE_TREEVIEW_COLUMN)
AB_CollapseListColumn(EXPERIMENT_TREEVIEW_COLUMN)
break
default:
break
endswitch

return 0
Expand Down Expand Up @@ -2702,6 +2709,8 @@ Function AB_ButtonProc_LoadSweeps(STRUCT WMButtonAction &ba) : ButtonControl
KillWindow $graph
endif
break
default:
break
endswitch

return 0
Expand All @@ -2714,6 +2723,8 @@ Function AB_ButtonProc_LoadBoth(STRUCT WMButtonAction &ba) : ButtonControl
case 2:
PGC_SetAndActivateControl(ba.win, "button_load_stimsets")
PGC_SetAndActivateControl(ba.win, "button_load_sweeps")
default:
break
endswitch

return 0
Expand All @@ -2733,6 +2744,8 @@ Function AB_ButtonProc_LoadStimsets(STRUCT WMButtonAction &ba) : ButtonControl
WBP_CreateWaveBuilderPanel()
endif
break
default:
break
endswitch

return 0
Expand Down Expand Up @@ -2784,6 +2797,8 @@ Function AB_ButtonProc_Refresh(STRUCT WMButtonAction &ba) : ButtonControl

AB_UpdateColors()
break
default:
break
endswitch

return 0
Expand Down Expand Up @@ -2818,6 +2833,8 @@ Function AB_ButtonProc_OpenFolders(STRUCT WMButtonAction &ba) : ButtonControl
endfor
KillPath/Z $symbPath
break
default:
break
endswitch

return 0
Expand All @@ -2844,6 +2861,8 @@ Function AB_ButtonProc_Remove(STRUCT WMButtonAction &ba) : ButtonControl
endfor
AB_SaveSourceListInSettings()

break
default:
break
endswitch

Expand Down Expand Up @@ -2883,6 +2902,8 @@ Function AB_ButtonProc_AddFolder(STRUCT WMButtonAction &ba) : ButtonControl
Make/FREE/T wFolder = {folder}
AB_AddExperimentEntries(ba.win, wFolder)
break
default:
break
endswitch

return 0
Expand Down Expand Up @@ -2921,6 +2942,8 @@ Function AB_ButtonProc_AddFiles(STRUCT WMButtonAction &ba) : ButtonControl
WAVE/T selFiles = ListToTextWave(fileList, "\r")
AB_AddFiles(ba.win, selFiles)
break
default:
break
endswitch

return 0
Expand Down Expand Up @@ -3009,6 +3032,8 @@ Function AB_ButtonProc_SelectStimSets(STRUCT WMButtonAction &ba) : ButtonControl
expBrowserSel[indizes[i]][] = expBrowserSel[p][q] | LISTBOX_SELECTED
endfor

break
default:
break
endswitch

Expand Down Expand Up @@ -3057,6 +3082,8 @@ Function AB_ListBoxProc_ExpBrowser(STRUCT WMListboxAction &lba) : ListBoxControl
endif
AB_UpdateColors()

break
default:
break
endswitch

Expand Down Expand Up @@ -3142,6 +3169,8 @@ Function AB_ButtonProc_OpenCommentNB(STRUCT WMButtonAction &ba) : ButtonControl
NewNoteBook/K=1/F=0/OPTS=(2^2 + 2^3)/N=$commentNotebook/W=(0, 0, 300, 400) as titleString
ReplaceNotebookText(commentNotebook, comment)
break
default:
break
endswitch

return 0
Expand Down Expand Up @@ -3182,6 +3211,8 @@ Function AB_ButtonProc_ResaveAsNWB(STRUCT WMButtonAction &ba) : ButtonControl
AB_ReExport(i, overwrite)
endfor
break
default:
break
endswitch
End

Expand Down Expand Up @@ -3505,6 +3536,8 @@ Function AB_WindowHook(STRUCT WMWinHookStruct &s)
AB_MemoryFreeMappedDF()
AB_RemoveEmptyWorkingDF()

break
default:
break
endswitch

Expand Down
4 changes: 4 additions & 0 deletions Packages/MIES/MIES_AnalysisBrowser_SweepBrowser.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ Function SB_PopupMenuSelectSweep(STRUCT WMPopupAction &pa) : PopupMenuControl
UpdateSweepPlot(win)
endif

break
default:
break
endswitch
End
Expand All @@ -654,6 +656,8 @@ Function SB_ButtonProc_ExportTraces(STRUCT WMButtonAction &ba) : ButtonControl
graph = GetMainWindow(ba.win)
SBE_ShowExportPanel(graph)
break
default:
break
endswitch

return 0
Expand Down
13 changes: 13 additions & 0 deletions Packages/MIES/MIES_AnalysisBrowser_SweepBrowser_Export.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,9 @@ Function SBE_PopMenu_ExportTargetAxis(STRUCT WMPopupAction &pa) : PopupMenuContr
case "popup_sweep_export_x_axis":
list = "setvar_sweep_export_new_x_name"
break
default:
ASSERT(0, "Unknown control name")
break
endswitch

if(!cmpstr(popStr, "New"))
Expand All @@ -582,6 +585,8 @@ Function SBE_PopMenu_ExportTargetAxis(STRUCT WMPopupAction &pa) : PopupMenuContr
DisableControls(win, list)
endif

break
default:
break
endswitch

Expand All @@ -603,6 +608,8 @@ Function SBE_PopMenu_ExportTargetGraph(STRUCT WMPopupAction &pa) : PopupMenuCont
DisableControl(win, "setvar_sweep_export_datafolder")
endif

break
default:
break
endswitch

Expand All @@ -621,6 +628,8 @@ Function SBE_ButtonProc_PerformExport(STRUCT WMButtonAction &ba) : ButtonControl
SBE_FillExportSettings(win, sett)
SBE_ExportSweepBrowser(sett)
break
default:
break
endswitch

return 0
Expand All @@ -646,6 +655,8 @@ Function SBE_CheckProc_UsePulseForXRange(STRUCT WMCheckboxAction &cba) : CheckBo
DisableControls(win, listXPulses)
endif
break
default:
break
endswitch

return 0
Expand All @@ -666,6 +677,8 @@ Function SBE_PopMenuProc_PulsesADTrace(STRUCT WMPopupAction &pa) : PopupMenuCont
numPulses = DimSize(pulseStartTimes, ROWS)
SetVariable setvar_sweep_export_num_pulses, win=$pa.win, limits={1, numPulses, 1}

break
default:
break
endswitch

Expand Down
3 changes: 2 additions & 1 deletion Packages/MIES/MIES_AnalysisFunctionHelpers.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,8 @@ Function AFH_LastSweepInSet(string device, variable sweepNo, variable headstage,
sweepOffset = 1
break
default:
// do nothing
// do nothing
break
endswitch

DAC = AFH_GetDACFromHeadstage(device, headstage)
Expand Down
3 changes: 3 additions & 0 deletions Packages/MIES/MIES_AnalysisFunctions.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ Function MeasureMidSweepTiming_V3(string device, STRUCT AnalysisFunction_V3 &s)

lastCall = GetReferenceTime()
break
default:
// do nothing
break
endswitch

return 0
Expand Down
8 changes: 8 additions & 0 deletions Packages/MIES/MIES_AnalysisFunctions_Dashboard.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,8 @@ Function AD_ListBoxProc(STRUCT WMListboxAction &lba) : ListBoxControl
case 5: // cell selection plus Shift key
AD_SelectResult(lba.win)
break
default:
break
endswitch

return 0
Expand All @@ -1366,6 +1368,8 @@ Function AD_CheckProc_PassedSweeps(STRUCT WMCheckboxAction &cba) : CheckBoxContr
case 2: // mouse up
AD_SelectResult(cba.win)
break
default:
break
endswitch

return 0
Expand All @@ -1377,6 +1381,8 @@ Function AD_CheckProc_FailedSweeps(STRUCT WMCheckboxAction &cba) : CheckBoxContr
case 2: // mouse up
AD_SelectResult(cba.win)
break
default:
break
endswitch

return 0
Expand All @@ -1399,6 +1405,8 @@ Function AD_CheckProc_Toggle(STRUCT WMCheckboxAction &cba) : CheckBoxControl
DisableControls(win, "check_BrowserSettings_DB_Failed;check_BrowserSettings_DB_Passed")
endif

break
default:
break
endswitch

Expand Down
12 changes: 6 additions & 6 deletions Packages/MIES/MIES_AnalysisFunctions_MultiPatchSeq.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ Function/S MSQ_FastRheoEst_CheckParam(string name, STRUCT CheckParametersStruct
return "Not valid."
endif
break
default:
// other parameters are not checked
return ""
endswitch

// other parameters are not checked
return ""
End

/// @brief Analysis function to find the smallest DAScale where the cell spikes
Expand Down Expand Up @@ -1054,10 +1054,10 @@ Function/S MSQ_DAScale_CheckParam(string name, STRUCT CheckParametersStruct &s)
return "Wave must neither have NaNs nor Infs"
endif
break
default:
// other parameters are not checked
return ""
endswitch

// other parameters are not checked
return ""
End

/// @brief Analysis function to apply a list of DAScale values to a range of sweeps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,9 @@ Function/S SC_SpikeControl_CheckParam(string name, STRUCT CheckParametersStruct
return "Invalid value " + num2str(val)
endif
break
default:
// no checks for other parameters
break
endswitch

strswitch(name)
Expand Down
Loading

0 comments on commit 728a51e

Please sign in to comment.