Skip to content

Remove dead code and unused imports across server src - #187

Closed
buzz-code wants to merge 2 commits into
mainfrom
claude/refactor-tech-debt
Closed

buzz-code wants to merge 2 commits into
mainfrom
claude/refactor-tech-debt

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

What changed

Small, conservative dead-code cleanup in server/src, found via grep (to confirm each symbol was truly unused) and a tsc --noUnusedLocals --noUnusedParameters pass:

  • Dead commented-out code

    • klassAttendanceReport.ts: removed leftover commented-out header-row variables/entries (hoursRow, topicRow, lessonCountRow, teacherRow, separatorRow) from an earlier table layout; also dropped the now-unused formatTime import (it was only referenced from the removed comment).
    • StudentByYear.entity.ts: removed an abandoned commented-out @ManyToOne/@JoinColumn relation. Unlike the similar-looking pattern in User.entity.ts (which I left alone — those commented decorators keep typed fields that other entities' inverse relations actually reference), nothing in the codebase references a .student relation off StudentByYear, so this one was genuinely dead.
  • Unused imports (verified unused via grep, each file's raw-SQL/query-builder view expression doesn't touch them): AttReportAndGrade.entity.ts, LessonKlassName.entity.ts, TeacherGradeReportStatus.entity.ts, TeacherReportStatus.entity.ts, User.entity.ts (Klass, Lesson, StudentKlass, OneToMany), AbsenceType.entity.ts (IsUniqueCombination), ReportGroupSession.entity.ts (fillDefaultYearValue), student-percent-report.config.ts (AttGradeEffect), studentReportData.util.ts (Any), lessonSignaturePdfReport.tsx (ReportGroupSession).

  • Unused destructured locals: userId in teacherReportFile.ts (code already uses params.userId instead), emptyCellStyle/key in studentReportCardReact.tsx, id/entityName in lessonSignaturePdfReport.tsx.

What I deliberately left alone

  • CrudRequest<any, any> and similar framework-generic any usage — consistent, intentional pattern across every entity-module config; narrowing it would require guessing per-entity DTO shapes.
  • Commented-out approvedAbsCount/sheetName export-header entries in att-report.config.ts / att-report-with-report-month.config.ts — mirrored by matching commented <NumberField>s in the client entities, so this reads as a deliberate "hide column, keep for later" pattern rather than accidental leftovers.
  • gradeAvg/lessonsCount unused destructure in michlolPopulatedFile.ts — guarded by an explicit // TODO add param here to use lastGrade or gradeAvg comment.
  • Several unused function parameters in entity-module configs (entityColumns, importFields, filter) — required to match base-class/interface method signatures by position.
  • migrations/ — dozens of historical migration files have an unused dbName local, but rewriting one-time DB scripts wholesale isn't a "surgical" change, so left untouched.
  • client/ and client/shared/server/shared (out of scope per instructions; not touched).

Verification

  • tsc --noEmit (server): clean.
  • yarn test (server): 118 suites / 1034 tests passed, both before and after these changes.
  • No public API, entity schema, or exported interface changes — every edit removes something unreferenced.

🤖 Generated with Claude Code

https://claude.ai/code/session_013ogK8XQU9EwAhU3KcbCUMB


Generated by Claude Code

- Delete leftover commented-out header-row placeholders in
  klassAttendanceReport.ts (unused formatTime import too, only
  referenced from the removed comment).
- Delete an abandoned commented-out @manytoone relation in
  StudentByYear.entity.ts (view entity - relation never worked and
  nothing references it), plus its now-unused typeorm imports.
- Remove unused typeorm/entity imports in AttReportAndGrade.entity.ts,
  LessonKlassName.entity.ts, TeacherGradeReportStatus.entity.ts,
  TeacherReportStatus.entity.ts, and User.entity.ts (verified via
  `tsc --noUnusedLocals`, each confirmed unused by grep).
- Remove unused imports IsUniqueCombination (AbsenceType.entity.ts),
  fillDefaultYearValue (ReportGroupSession.entity.ts), AttGradeEffect
  (student-percent-report.config.ts), Any (studentReportData.util.ts),
  ReportGroupSession (lessonSignaturePdfReport.tsx).
- Drop unused destructured locals: userId in teacherReportFile.ts,
  emptyCellStyle/key in studentReportCardReact.tsx, id/entityName in
  lessonSignaturePdfReport.tsx.

No behavior change - all findings verified unused via grep and a
tsc --noUnusedLocals --noUnusedParameters pass; server test suite
(118 suites / 1034 tests) passes before and after.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ogK8XQU9EwAhU3KcbCUMB
Copilot AI lite review requested due to automatic review settings September 12, 2026 06:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are limited to verified dead-code cleanup, with successful type-checking and tests; remaining feedback is minor.

Pull request overview

This PR removes verified dead code and unused imports across server/src without changing APIs or schemas.

Changes:

  • Removes obsolete commented-out code.
  • Removes unused imports and locals.
  • Simplifies attendance report construction.
  • Server type-checking and 118 test suites passed.
File summaries
File Summary
server/src/utils/studentReportData.util.ts Removes unused import.
server/src/reports/teacherReportFile.ts Removes unused local.
server/src/reports/studentReportCardReact.tsx Removes unused destructured values.
server/src/reports/lessonSignaturePdfReport.tsx Removes unused import and locals.
server/src/reports/klassAttendanceReport.ts Removes dead header code and import.
server/src/entity-modules/student-percent-report.config.ts Removes unused import.
server/src/db/view-entities/TeacherReportStatus.entity.ts Removes unused imports.
server/src/db/view-entities/TeacherGradeReportStatus.entity.ts Removes unused imports.
server/src/db/view-entities/StudentByYear.entity.ts Removes obsolete relation comments and imports.
server/src/db/view-entities/LessonKlassName.entity.ts Removes unused imports.
server/src/db/view-entities/AttReportAndGrade.entity.ts Removes unused imports.
server/src/db/entities/User.entity.ts Removes unused relation imports.
server/src/db/entities/ReportGroupSession.entity.ts Removes unused import.
server/src/db/entities/AbsenceType.entity.ts Removes unused validator import.
Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@@ -702,7 +701,6 @@ interface StudentRecordsTableProps {
const StudentRecordsTable: React.FC<StudentRecordsTableProps> = ({
studentRecords,
entityConfig,
`;

const { fullCellStyle, rightAlignFullCellStyle, emptyCellStyle } = useCellStyles();
const { fullCellStyle, rightAlignFullCellStyle } = useCellStyles();
- lessonSignaturePdfReport.tsx: StudentRecordsTable no longer reads
  entityName, but the prop stayed required in its interface and both
  call sites still passed it. Removed the dead prop end-to-end.
- studentReportCardReact.tsx: useCellStyles() still built and returned
  emptyCellStyle even though its only consumer stopped destructuring
  it. Removed the now-unused style.

Addresses Copilot review comments on PR #187.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ogK8XQU9EwAhU3KcbCUMB
@buzz-code

Copy link
Copy Markdown
Owner Author

נסגר ככפילות: כל השינויים כאן כלולים ב-#178 (tech-debt cleanup רחב יותר, 51 קבצים).

@buzz-code buzz-code closed this Sep 22, 2026
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.

3 participants