Skip to content

Code cleanup, hardening, and test coverage improvements#913

Open
sreckoskocilic wants to merge 7 commits into
fman-users:mainfrom
sreckoskocilic:cleanup_and_docs_codescan
Open

Code cleanup, hardening, and test coverage improvements#913
sreckoskocilic wants to merge 7 commits into
fman-users:mainfrom
sreckoskocilic:cleanup_and_docs_codescan

Conversation

@sreckoskocilic
Copy link
Copy Markdown

Summary

Hardening (assert → raise, guards, logging)

  • model/model.pyassertraise RuntimeError/ValueError; Event-based shutdown flag; Lock for _files dict; _snapshot_files() for safe cross-thread iteration; early return in _record_files when shutdown; _on_empty_rows_inited runs callback via @run_in_main_thread; _commit_sort_updates_and_sort moves sort value writes to main thread
  • model/table.pyLock guards on Rows.__len__, __getitem__, __iter__, index; assertraise RuntimeError
  • model/worker.pytask_done() on shutdown sentinel; join() guarded by is_alive() check
  • onboarding/tutorial.py — 3 assertraise ValueError with context messages
  • usage_helper.pyassert events → early return False on empty events list
  • single_row_mode.py — null guard before remove_delegate
  • quicksearch.py — guard against row_height <= 0
  • onboarding/__init__.py — unclosed </ul> tag fix

Silent failures → logging

  • metrics.py — bare pass in track()/update_user()_LOG.debug() with exc_info; SENTINEL-based shutdown for AsynchronousMetrics thread
  • plugins/config.py — inline comments explaining swallowed exceptions → _LOG.debug()/_LOG.warning() with exc_info
  • plugins/error.py — docstring for report() exc parameter

Bug fixes

  • controller.pyfile_pathfile_url parameter rename for consistency
  • cursor_movement.pytoggle_selection now passed through in move_cursor_page_up/page_down
  • util/path.pynormalize handles chained .. segments and /.. at root
  • core/__init__.py — numeric sort padding widened from 6 to 20 digits (supports numbers up to 10^20)
  • plugins/config.pytype() ==isinstance() for proper subclass handling

Cleanup

  • controller.py — removed assert on QContextMenuEvent.reason()
  • explorer_properties.pytry/finally ensures DestroyMenu(hMenu) cleanup on Windows
  • key_event.py — "OS X" → "macOS"; updated Qt doc URL to archived 5.15 docs

New tests (39 tests added)

  • test_worker.py (new) — WorkerTest (6 tests): priority ordering, shutdown, submit-after-shutdown, exception resilience. WorkItemTest (4 tests): shutdown detection, ordering, exception capture
  • test_error.py (new) — FormatTracebackTest (3), WalkTbWithFilteringTest (3), TracebackExceptionWithTbFilterTest (5), PluginErrorHandlerTest (4): traceback filtering, chained exceptions, pending error queuing
  • test_resize_cols_to_contents.py — 2 new ResizeColumnTest methods (shrink width cap), DistributeEvenlyTest (4), DistributeExponentiallyTest (4)
  • test_model.pyModelFilesCopyTest: concurrent dict.copy() safety under mutation
  • test_plugin.pyReportExceptions tests: exception_stored, exclude_must_be_set
  • test_path.pynormalize tests for chained .. and /.. at root
  • test_quicksearch_matchers.pyContainsCharsTest (6) and ContainsSubstringTest (4)

Test plan

  • Run full test suite: all 246 tests pass, 0 failures
  • Navigate directories with deep paths containing .. segments
  • Resize columns — verify no overflow, selection toggle works with page up/down
  • Verify metrics logging appears in debug output instead of silent failures

…paring two tuples, every equality check returns True

- master -> main branch fix
- prepare_trash now calls self.move_to_trash instead of self.delete, so plugin subclasses won't permanently delete files when the user expects trashing
- NotImplementedError - unrecognized platforms fail fast with a clear message instead of a cryptic NameError
- removed shadowing basename import
- get_column_widths uses range so plugin-added columns get their widths saved/restored
…it__ always runs, even on exception.

  - util/qt/__init__.py — Added missing c_void_p import from ctypes, fixing a macOS runtime crash.
  - table.py — Fixed off-by-one: bounds check now rejects len + 1 correctly.
  - widgets.py — Added null guard on _main_window before accessing it in state change handler.
…ved, so a/b/c/../../d correctly becomes a/d.

  - session.py — Removed dead _get_startup_message method (duplicated by _show_startup_messages)
…r _files dict,

snapshot_files for safe iteration
- model/table.py — Lock guards on Rows.__len__/__getitem__/__iter__/index, assert → raise
- model/worker.py — task_done on shutdown sentinel, join guard for inactive thread
- metrics.py — silent pass → logging.debug, SENTINEL-based shutdown for AsynchronousMetrics
- plugins/config.py — bare except comments → logging, type() == → isinstance()
- controller.py — file_path → file_url rename, removed assert on context menu reason
- onboarding/tutorial.py — assert → raise ValueError with context
- usage_helper.py — assert → early return on empty events
- quicksearch.py — guard against zero row_height
- single_row_mode.py — null guard before remove_delegate
- cursor_movement.py — pass toggle_selection through page up/down
- util/path.py — normalize handles chained .. and /.. at root
- core/__init__.py — widen numeric sort padding from 6 to 20 digits
- explorer_properties.py — try/finally for menu handle cleanup
- key_event.py — OS X → macOS, updated Qt doc link
- test_quicksearch_matchers.py — added ContainsCharsTest and ContainsSubstringTest
- test_resize_cols_to_contents.py — added shrink cap tests, DistributeEvenlyTest,
DistributeExponentiallyTest
- test_model.py — added ModelFilesCopyTest for concurrent dict.copy safety
- test_plugin.py — added ReportExceptions tests (exception_stored, exclude_must_be_set)
- test_path.py — added normalize tests for chained .. and /.. at root
- test_worker.py — new: WorkerTest (6 tests) + WorkItemTest (4 tests)
- test_error.py — new: FormatTracebackTest, WalkTbWithFilteringTest, TracebackExceptionWithTbFilterTest, PluginErrorHandlerTest
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