Skip to content

Instantly share code, notes, and snippets.

@muthuishere
Last active June 7, 2025 09:43
Show Gist options
  • Save muthuishere/318f44a21e491e131ccd36d64961f039 to your computer and use it in GitHub Desktop.
Save muthuishere/318f44a21e491e131ccd36d64961f039 to your computer and use it in GitHub Desktop.
code_assesment_template.md

📘 Backend Code Assessment — Phase 1 (Identification Only)

Module Reviewed: inventory
Date: 7 Jun 2025


1. 🔎 Per‑Method Review Table

File Method Flow Summary DB & Collection / Table Query Pattern & Fields Indexed Fields In Loop? Dynamic Query? Caching Sonar Issues Error‑Handling Issues Unit Test Int Test
InventoryService.java calculateStock() Totals stock per clinic Mongo stock find({clinicId,itemId}) clinicId ✅, itemId ❌ Cog. Complexity 32 Broad Exception catch ✅ Partial
InventoryService.java syncInventoryWithBackend() Pushes daily inventory delta to ERP Long method 340 LOC Swallows HTTP 500
InventoryService.java getLowStockItems() Lists items below reorder level Mongo stock aggregate([...]) clinicId ✅ Large method Missing finally ✅ Full
ReportService.java generateReport() Builds CSV for dispensing MySQL dispensing SELECT * … WHERE date BETWEEN … Long method, SQL concat Swallows SQLException

2. 🗂️ Detailed Notes

📄 File: InventoryService.java

🔁 Method: calculateStock(String itemId)

Item Observation
Flow Summary Loops through clinics, queries stock per clinic, aggregates totals.
Queries stock.find({clinicId,itemId}) inside loop (≈130 iterations).
Indexed Fields clinicId ✅, itemId ❌ — leads to collection scan
Caching None
SonarQube Cognitive complexity 32, duplicated aggregation code
Error Handling Broad Exception catch logs only .getMessage()
Tests Unit test covers happy path only; no integration test

📄 File: ReportService.java

🔁 Method: generateReport(LocalDate start, LocalDate end)

Item Observation
Flow Summary Fetches dispensing rows, writes CSV to /tmp, returns link.
Query SELECT * FROM dispensing WHERE date BETWEEN ? AND ?
Indexed Fields date column not indexed — full table scan
Caching None
SonarQube SQL built via string concat → SQL‑injection flag; complexity 28
Error Handling Catches SQLException, logs, returns empty CSV
Tests No unit or integration tests

3. 📌 Quick Phase‑1 Observations

  • Query‑in‑loop + missing itemId index ⇒ major Mongo slowdown.
  • Unindexed date field in MySQL report causes full scan.
  • Methods lack tests and have broad exception handling. (Refactors deferred to Phase 2.)

📘 Backend Code Assessment — Phase 1 (Identification Only)

Goal: Capture what exists — no fixes, no refactor suggestions yet
Scope: cms-core & inventory modules (extend as needed)


1. 🔎 Per-Method Review Table

File Method Flow Summary DB & Collection / Table Query Pattern & Fields Indexed Fields In Loop? Dynamic Query? Caching Sonar Issues Error-Handling Issues Unit Test Int Test
(file) (method) (one‑line purpose) (db.collection) (pattern) (idx list) ✅/❌ ✅/❌ ✅/❌ (summary) (summary) ✅/❌ ✅/❌

2. 🗂️ Detailed Notes Template (Per File)

📄 File: <FileName>.java

🔁 Method: <methodName>(...)

Item Observation
Flow Summary e.g. “Loops through all clinics and aggregates stock”
Queries 1. collection.find({...}) — where/when
2. ...
Indexed Fields fieldA ✅, fieldB ❌
Caching None / Local / Redis (@Cacheable)
SonarQube Cognitive complexity, duplicates, security flags
Error Handling Broad catch? Swallowed exception?
Tests Unit: yes/no; Integration: yes/no

(Repeat this sub‑section for each key method in the file.)


3. 📌 Phase‑1 Tips

  • MongoDB index check: db.collection.getIndexes() or Compass → Indexes tab.
  • Query plan: db.collection.find({...}).explain("executionStats") — look for IXSCAN.
  • MySQL index check: EXPLAIN SELECT …;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment