# A worked review

One complete review of a small diff, so the format and the severity bar are unambiguous. The diff is Angular; the shape of the review is the same in any stack.

## The diff

```ts
// src/app/features/orders/pages/order-list.ts
@Component({
  selector: 'app-order-list',
  imports: [CommonModule],
  template: `
    <input (input)="search($any($event.target).value)" placeholder="Search orders" />
    <div *ngFor="let o of orders; let i = index" [attr.data-i]="i" (click)="open(o)">
      <span [innerHTML]="o.customerNote"></span>
      <span>{{ formatTotal(o) }}</span>
    </div>
  `,
})
export class OrderList implements OnInit {
  orders: Order[] = [];
  constructor(private http: HttpClient) {}

  ngOnInit() {
    this.http.get<Order[]>('/api/orders').subscribe((o) => (this.orders = o));
  }
  search(q: string) {
    this.http.get<Order[]>(`/api/orders?q=${q}`).subscribe((o) => (this.orders = o));
  }
  formatTotal(o: Order) {
    return new Intl.NumberFormat('en-GB', { style: 'currency', currency: o.currency }).format(o.total);
  }
  open(o: Order) { this.router.navigate(['/orders', o.id]); }
}
```

## The findings

```
[blocker] features/orders/pages/order-list.ts:8 — `[innerHTML]` bound to `o.customerNote`, which comes
from user-entered data.
Why it matters: Angular sanitises this binding, but it strips rather than escapes, so the note renders
wrong, and the pattern is one `bypassSecurityTrustHtml` away from stored XSS in a shared list view.
Suggest:
  <span>{{ o.customerNote }}</span>
  <!-- if the note genuinely needs formatting, render structured data or sanitise server-side -->
```

```
[blocker] features/orders/pages/order-list.ts:7 — the row is a `div` with a `(click)` handler.
Why it matters: keyboard and screen-reader users cannot open an order at all; this is the page's only
primary action.
Suggest:
  <button type="button" class="order-row" (click)="open(o)">…</button>
  <!-- or <a [routerLink]="['/orders', o.id]"> so it is linkable and middle-clickable -->
```

```
[major] features/orders/pages/order-list.ts:18 — `subscribe()` in `ngOnInit` with no teardown, and the
same in `search()`.
Why it matters: each visit to this route leaks a live subscription, and a slow first response can
overwrite the result of a later search — the list shows data for a query the user has already changed.
Suggest:
  private readonly query = signal('');
  protected readonly orders = httpResource<Order[]>(
    () => `/api/orders?q=${encodeURIComponent(this.query())}`);
  // resource reloads on query change and cancels the in-flight request
```

```
[major] features/orders/pages/order-list.ts:22 — `q` is interpolated into the URL unencoded.
Why it matters: a query containing `&` or `#` silently truncates the search or injects another
parameter.
Suggest: `encodeURIComponent(q)`, or pass `{ params: { q } }` to `HttpClient.get`.
```

```
[major] features/orders/pages/order-list.ts:22 — every keystroke fires a request.
Why it matters: a ten-character search is ten requests, nine of them wasted, and the last response to
arrive wins rather than the last one asked for.
Suggest: debounce the query signal by ~300 ms before the resource reads it, and keep the input bound to
the undebounced value so typing stays responsive.
```

```
[minor] features/orders/pages/order-list.ts:4 — `CommonModule` imported wholesale, and `*ngFor` used in
a new template.
Why it matters: the whole module lands in this chunk, and the repo has otherwise moved to built-in
control flow, so this file will read as the odd one out in six months.
Suggest: `@for (o of orders(); track o.id) { … } @empty { … }` and drop the `CommonModule` import.
```

```
[minor] features/orders/pages/order-list.ts:25 — `formatTotal()` is called from the template.
Why it matters: it runs on every change-detection pass, for every row, constructing a new
`Intl.NumberFormat` each time.
Suggest: precompute the formatted total in a `computed()` view model, or use the `currency` pipe.
```

```
[question] features/orders/pages/order-list.ts:16 — there is no empty state and no error state.
What should the page show when the search returns nothing, and when the request fails? Both are
one-line template branches if we decide now.
```

```
[praise] features/orders/pages/order-list.ts:25 — formatting with `Intl.NumberFormat` and the order's
own currency code, rather than a hard-coded `£`. That is the right call and I'd like it copied into the
invoice view, which still hard-codes it.
```

## The summary

```
## Summary
Verdict: Request changes
Blockers: 2  Majors: 3  Minors: 2
Files reviewed: 1 of 1

Top 3 to address:
1. Remove the `[innerHTML]` binding — user-entered notes must not be rendered as HTML.
2. Make the row a real `<button>` or `<a>`; keyboard users currently cannot open an order.
3. Replace the two `subscribe()` calls with a debounced `httpResource`, which fixes the leak, the
   race and the request-per-keystroke problem together.

What's good: currency formatting is done properly with the order's own currency code — worth copying
into the invoice view.
```

## What this example demonstrates

- **Two blockers, and they are genuinely blocking**: an XSS-shaped sink and a primary flow that keyboard users cannot complete. Neither is a matter of taste.
- **Related problems merged into one fix.** The leak, the race and the request storm share a root cause, so the summary proposes one change instead of three arguments.
- **Each finding names the failure mode**, not a preference: "a slow first response overwrites a later search" is checkable; "this isn't idiomatic" is not.
- **One `[question]`** where the answer is a product decision, not a code defect.
- **One honest `[praise]`** that also spreads a good pattern to another file.
- **Nothing about formatting, import order or quote style** — a tool owns those, and spending review attention on them buys the author a worse review.
