Skip to content

BUG: Remove return-void-expression that caused dead code (clazy returning-void-expression)#1377

Merged
jamesobutler merged 1 commit intocommontk:masterfrom
BRAINSia:pr/returning-void-expression
Mar 28, 2026
Merged

BUG: Remove return-void-expression that caused dead code (clazy returning-void-expression)#1377
jamesobutler merged 1 commit intocommontk:masterfrom
BRAINSia:pr/returning-void-expression

Conversation

@hjmjohnson
Copy link
Copy Markdown
Contributor

@hjmjohnson hjmjohnson commented Mar 24, 2026

Cherry-picked from #1372, part of a systematic clazy static analysis effort to improve CTK for Slicer compatibility and Qt6 migration.

What this changes

Seven functions used return voidFunc() where the function itself returns void. In several cases, code after the return — including emit signal calls — was unreachable dead code. The fix separates the void call from the return statement so all subsequent code executes.

Why

Real bugs — signals after return voidFunc() were silently never emitted. The pattern compiles without warning but is semantically wrong: the return causes an early exit before the signals fire. Identified by the clazy returning-void-expression check.

Testing

  • Builds cleanly with zero new compiler warnings
  • Existing tests pass (no regressions)

🤖 Identified via clazy static analysis using CTK-claude-skills

@hjmjohnson hjmjohnson changed the title BUG BUG: Remove return-void-expression that caused dead code (clazy returning-void-expression) Mar 24, 2026
@hjmjohnson hjmjohnson marked this pull request as ready for review March 26, 2026 13:33
…ning-void-expression)

Functions declared as returning void were using 'return f()' where f() is
also void. In several cases this pattern prevented signals from ever being
emitted: the signal emission appeared after the return statement and was
never reached.

Affected functions:
- ctkErrorLogAbstractModel::setFilePath() — FileLogger signal dead code
- ctkDICOMTableView: headerWidget visibility signal unreachable
- ctkDICOMVisualBrowserWidget: server removal signals unreachable (3 funcs)
- ctkAddRemoveComboBox: combo index/text signals unreachable (2 funcs)
- ctkCheckableComboBox: check state signal unreachable
- ctkDirectoryButton: icon change signal unreachable
- ctkSliderWidget: spinbox alignment signal unreachable

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jamesobutler jamesobutler force-pushed the pr/returning-void-expression branch from 6d65d7c to 081e648 Compare March 28, 2026 13:53
@jamesobutler jamesobutler enabled auto-merge (rebase) March 28, 2026 13:54
@jamesobutler jamesobutler merged commit 7b5cd13 into commontk:master Mar 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants