Search⌘ K
AI Features

Code Quality, Testing, and Reproducibility

Identify how undocumented file paths, suppressed exceptions, and tests that only check file existence can conceal failures in a submission. Write assertions that verify expected behavior, introduce controlled code mutations to verify that tests detect failures, and confirm that the project runs with a single command from a fresh repository clone so reviewers can reproduce the results without relying on undocumented setup steps.

The maintenance report runs successfully in the developer’s local environment. The report fails from a fresh repository clone because the script references /Users/dev/Downloads/assets.csv, a local file that is not included in the repository. The screenshot shows a completed report, but the reviewer cannot reproduce the result.

Another version catches all exceptions and generates an empty report instead of reporting the failure. An unreadable input file is incorrectly reported as a successful run with no assets requiring service.

A reproducible handoff requires clearly separated responsibilities, tests that detect incorrect behavior, and a verified execution path from a fresh repository clone.

For this separate assignment, read service_assets.csv and select records where status is exactly active and service_hours >= 100. Preserve the relative order of qualifying records from the input file. Use the following fixture to verify the results:

asset_id,service_hours,status
A1,120,active
A2,100,active
A3,99,active
A4,150,retired
  • Line 1: Names the three required input columns.

  • Lines 2–3: Supply the above-threshold and exact-threshold active assets.

  • Lines 4–5: Supply exclusions for insufficient hours and retired status.

The expected report has columns asset_id,service_hours and records A1,120 followed by A2,100. A valid input with no qualifying assets produces a header-only report successfully. Invalid or unreadable input must fail before report writing.

Separating code responsibilities

The tempting shortcut combines a machine-specific path, selection, and error suppression:

try:
assets = read_assets('/Users/dev/Downloads/assets.csv')
due = select_due_assets(assets)
except Exception:
due = []
write_report('service_due.csv', due)
  • Lines 1–3: Read an untracked absolute path and attempt selection.

  • Lines 4–5: Convert every failure, including programming defects, into an empty result.

  • Line 6: Write a plausible success artifact even when input handling failed.

A file-existence test accepts this failure. Repair the path, failure boundary, and assertions before considering more infrastructure.

For this workflow, one module with four named functions is enough:

  • read_assets(input_path): Read and validate the complete CSV.

  • select_due_assets(assets): Apply the status and inclusive threshold rules without filesystem effects.

  • write_report(output_path, assets): Write the customer-facing columns in order.

  • ...