Skip to content

fix(reporter): Report file name collisions cause silent overwrites for files with identical basenames #24

Description

@CodeMaverick-143

Problem Description

In insight/reporter.py, reports are named purely by os.path.basename:

filename = os.path.basename(file_info["file"]) + ".md"
filepath = os.path.join(output_dir, filename)

In almost every non-trivial project, multiple files share identical basenames across different directories:

  • pkg_a/__init__.py and pkg_b/__init__.py
  • models/user.py and routes/user.py
  • components/Button.tsx and legacy/Button.tsx
  • src/index.js and test/index.js

Impact

  1. Each subsequent file with the same basename silently overwrites the report generated for earlier files.
  2. In summary.md, multiple entries point to the same overwritten file.
  3. Historical analysis of overwritten files is permanently lost.

Affected Files

  • insight/reporter.py:3-35

Proposed Solution

Option A (Preserve Directory Tree):
Mirror the source directory structure under report/ (e.g. report/models/user.py.md and report/routes/user.py.md).

Option B (Path Sanitization):
Convert relative paths into unique flat filenames (e.g. report/models_user.py.md and report/routes_user.py.md).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions