Skip to content

refactor(transcription_resizer): extract __init__ into smaller methods to fix R0915#1537

Merged
raivisdejus merged 6 commits into
chidiwilliams:mainfrom
josiasdev:refactor/remove-code-smell-transcription-resizer-extract-init-R0915
Jul 1, 2026
Merged

refactor(transcription_resizer): extract __init__ into smaller methods to fix R0915#1537
raivisdejus merged 6 commits into
chidiwilliams:mainfrom
josiasdev:refactor/remove-code-smell-transcription-resizer-extract-init-R0915

Conversation

@josiasdev

Copy link
Copy Markdown
Contributor

Why is this change necessary?

The __init__ method of TranscriptionResizerWidget had 114 statements, far exceeding Pylint's limit of 50 (R0915: too-many-statements). The method was responsible for all UI construction — labels, group boxes, layouts, checkboxes, spin boxes, buttons, and signal connections — in a single monolithic block. This violated the Single Responsibility Principle, harmed readability, and made maintenance harder.

How was this tested?

All 5 existing tests in tests/widgets/transcription_viewer/transcription_resizer_widget_test.py were run and passed before committing:
uv run python -m pytest tests/ -k "transcription_resizer" -x -q

Pylint was also re-run against the file and now gives a 10.00/10 rating with no R0915 warning.

Notes for the reviewer

The extraction is purely mechanical — each UI section (Settings, Extend Endings, Resize Options, Merge Options) was moved into its own private method (_setup_settings_section, _setup_extend_section, _setup_resize_section, _setup_merge_section). No logic, no attribute names, no signal/slot connections were changed. The refactoring is safe and straightforward.

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.87%. Comparing base (f5f67f7) to head (f40118a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1537      +/-   ##
==========================================
+ Coverage   81.81%   82.87%   +1.05%     
==========================================
  Files         108      108              
  Lines       11599    11620      +21     
==========================================
+ Hits         9490     9630     +140     
+ Misses       2109     1990     -119     
Flag Coverage Δ
Linux 81.60% <26.47%> (-0.11%) ⬇️
macOS 82.38% <100.00%> (+4.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raivisdejus
raivisdejus enabled auto-merge (squash) July 1, 2026 10:39
@raivisdejus
raivisdejus merged commit f00473f into chidiwilliams:main Jul 1, 2026
17 of 19 checks passed
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.

2 participants