# Code support

I read the code the team wrote and list findings by severity; we reproduce the bug in production and find its root cause; we deliver the fix together with a test that breaks when the fix is reverted.

With code inherited from someone else, I start with the path that touches the most money and data.

- **P0 now**: **Security, money, data loss.** Must not stay live; this comes first.
- **P1 before release**: **Wrong result.** Shows the user a wrong figure or a wrong status.
- **P2 planned**: **Fragile spot.** Works today, fails at the first unexpected case.
- **P3 improvement**: **Readability and repetition.** The code works, but makes the next change harder.

## 06.1 The work in three parts

A green test alone is not proof. A test that does not break when the fix is reverted is not catching the bug.

### **a** What we do

- **Code review**: I read the changes and write findings in P0-P3 order, with line numbers.
- **Debugging**: We reproduce the production bug first, then find its root cause.
- **Testing**: Tests for critical flows that really catch the bug.
- **Takeover**: A map of undocumented code: what is where, which part touches what.

### **b** What we deliver

- **List of findings**: Each finding: location, problem, suggested fix, test.
- **Fix branch**: On a separate branch, with small, explained commits; the merge decision is yours.
- **Tests**: Shown to break when the fix is reverted.
- **Code map**: A one-page structure note for an inherited project.

### **c** How we measure

- **Escaped bugs**: Number of bugs found after reaching production, month by month.
- **Time to fix**: Time from a bug being reported to the fix going live.
- **Repeats**: How often the same kind of bug shows up again.
- **Coverage**: Share of paths in critical flows (payment, login, data writes) that have a test.

## 06.2 What a review looks like

Four findings in a made-up order function. Click the number on a line or a finding on the right.

Code review

A made-up example, 19 lines

Sample code

order.js 4 findings

1. `export async function orderTotal(cart, coupon) {`
2. ` let total = 0;`
3. ` for (const item of cart.items) {`
4. ` total += item.price * item.quantity;`3
5. ` }`
6. ` if (coupon) {`
7. ` total = total - total * coupon.rate;`2
8. ` }`
9. ` const shipping = await shippingFee(cart.address);`4
10. ` return Math.round(total + shipping);`
11. `}`
13. `app.post('/api/order', async (req, res) => {`
14. ` const { id, coupon } = req.body;`
15. ` const cart = await db.query(`1
16. ` `SELECT * FROM cart WHERE id = ${id}`);`
17. ` const total = await orderTotal(cart, coupon);`
18. ` res.json({ total });`
19. `});`

- 1 User input is added to the query P0
  ### User input is added to the query
  P0 lines 15-16
  - **Problem**: The cart id is written straight into the SQL text; a value from outside can read or delete the whole table.
  - **Fix**: A parameterized query; the id is converted to a number and validated.
  - **Test**: A request that sends an SQL fragment instead of an id should return 400; the test should break when the fix is reverted.
- 2 The discount rate comes from the client P0
  ### The discount rate comes from the client
  P0 lines 7, 14
  - **Problem**: The coupon object is taken from the request as it is; send a rate of 1 and the order is free.
  - **Fix**: Only the coupon code is taken from the client; the rate, expiry and usage limit are checked on the server.
  - **Test**: An expired or fake coupon should not change the order total.
- 3 Money is calculated with floating-point numbers P1
  ### Money is calculated with floating-point numbers
  P1 lines 4, 10
  - **Problem**: Prices are added as floating-point numbers and then rounded to whole units; cents get lost.
  - **Fix**: All amounts are kept as whole numbers of cents; rounding happens in one place, with a written rule.
  - **Test**: With amounts like 0.10 + 0.20, the total is correct to the cent.
- 4 The order fails if the shipping service errors P2
  ### The order fails if the shipping service errors
  P2 line 9
  - **Problem**: If the shipping fee service does not respond, the request ends in a 500 and the user does not see why.
  - **Fix**: A timeout and a clear error message; an event log.
  - **Test**: When a mocked service returns an error, does the user get the right message.

Order

### Money and data first

In a review, the order matters more than the number of findings. A change with a P0 finding does not go live, however many P3s have been fixed.

Checked in every review

1. Where input from outside goes security
2. How money and amounts are calculated money
3. Whether deletes and overwrites can be undone data
4. Whether secrets and keys are in the code secrets
5. What the user sees when something fails errors

The sample code is not taken from any project; it was written to show how a review looks.

## 06.3 Related packages

The three packages that most often go with code support.

Start

### Starting audit and score

A scan of the codebase in P0-P3 order and a score for critical flows.

- Payment, login, data write paths
- Critical paths without tests

Security

### Compliance and risk review

A review of secrets, personal data and third-party dependencies.

- Secret scan in code and logs
- Old dependencies with known vulnerabilities

Speed

### AI agents built for the project

Code agents: a setup that writes on its own branch, is reviewed by a separate agent, and leaves the decision to the team.

## 06.4 What determines the price?

The price is set in a written quote, based on the state of the code. No figures here; these things decide the quote.

1. **Size of the codebase**: How many files and services must be read.
2. **Language and technology**: Which language, framework and database; how common or old they are.
3. **State of the tests**: With tests, changes can be made safely; without them a short safety net is built first.
4. **Type of work**: Debugging, code review, a security scan or a new feature.
5. **Urgency**: A bug live in production and a planned improvement take different amounts of time.
6. **Continuity**: A one-off job or regular support.

[Describe the bug or job briefly, ask for a quote](https://ruesandora.com/services/code-support#iletisim)

## Write where the code lives and what is broken.

Repository access can be discussed later; a short description of the bug and how long it has been happening is enough to start.

[Email info@ruesandora.com](mailto:info@ruesandora.com) [Telegram ruesandora](https://t.me/ruesandora) [X @ruesandora0](https://x.com/ruesandora0) [Instagram @ruesandora0](https://www.instagram.com/ruesandora0) [YouTube @ruesandora0](https://www.youtube.com/@ruesandora0)

Page: https://ruesandora.com/services/code-support
