📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Coverage on new code keeps failing the gate for DTO and EF Core migration files. What do you do?

Intermediate Theory Intermediate

🎯 Key points

  • Use sonar.coverage.exclusions (coverage only), not sonar.exclusions (removes analysis too)
  • Exclude generated code: EF Core Migrations folder, model snapshot, *.Designer.cs
  • Plain property-only DTOs: exclude by convention or accept; they carry no behaviour
  • DTOs with validation, mapping or computed properties have logic: test it or move it to a validator/mapper
  • Keep the threshold; change exclusions only by reviewed PR with a reason

⏱ 30-second answer

Separate generated or declarative files from code with behaviour. EF Core migrations, *.Designer.cs and model snapshots are generated: exclude them from coverage only with sonar.coverage.exclusions (e.g. **/Migrations/**), keep them in analysis, and record why in the repo. Plain DTOs (records with properties) usually have no logic worth testing; if they're failing the gate, check whether they actually contain validation, mapping or computed properties. If they do, that logic needs tests (validator tests, mapping tests), and it may belong in a validator or mapper rather than the DTO. Don't lower the threshold for everything; change exclusions only through a reviewed PR.

🔍 What the interviewer is checking

Checks they tune exclusions deliberately rather than lowering the bar

↩ Usually asked after

More in Static Analysis

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me