Receber por email
← Voltar para o catálogo

Delphi Code Review

Delphi code review checklist — quality, security, performance, SOLID, memory

42estrelas
Atualizado há 7 meses

Ver no GitHub ↗ Licença: MIT

Como adicionar

/plugin marketplace add delphicleancode/delphi-spec-kit

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Para o autor da skill

Cole no README do seu repo

Mostra que sua skill está catalogada na Skillteca, gera backlink e tráfego rastreável.

[![Skillteca](https://www.skillteca.com.br/api/badge/delphi-code-review-delphicleancode/svg)](https://www.skillteca.com.br/skills/delphi-code-review-delphicleancode)

Skills relacionadas

Ver todas de DevOps e Infra →

Alerta por categoria

Receba novas skills de DevOps e Infra toda segunda

1 email curto, só com as skills novas de DevOps e Infra. 4 minutos de leitura, sem spam, cancela com 1 clique.

Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.

Ler descrição completa

Delphi Code Review — Skill

Quick Checklist

Corretude

  • [ ] Code does what it's supposed to do
  • [ ] Edge cases handled (nil, empty list, zero value)
  • [ ] Error handling implemented with specific exceptions
  • [ ] No obvious bugs

Security

  • [ ] Parameterized SQL queries (without string concatenation)
  • [ ] Validated and sanitized input
  • [ ] No hardcoded credentials or passwords
  • [ ] No SQL injection via Format or concatenation in queries

Performance

  • [ ] No N+1 queries (avoid loop with query inside)
  • [ ] No unnecessary loops
  • [ ] Large objects released as early as possible
  • [ ] TObjectList with OwnsObjects configured correctly

Code Quality

  • [ ] Self-descriptive names following Pascal Guide
  • [ ] DRY — no duplicate code
  • [ ] SOLID — principles respected
  • [ ] Methods ≤ 20 lines
  • [ ] Guard clauses instead of deep nesting

Memory Management

  • [ ] try/finally with Free for temporary objects
  • [ ] Interfaces for automatic reference counting
  • [ ] Assigned() before accessing references that may be nil
  • [ ] Destructor Destroy with override freeing owned fields
  • [ ] No memory leaks in exception paths

Pascal Nomenclature

  • [ ] PascalCase for all identifiers
  • [ ] Prefix T in classes, I in interfaces, E in exceptions
  • [ ] Prefix F in private fields, A in parameters, L in local variables
  • [ ] Units: Projeto.Camada.Dominio.Funcionalidade.pas
  • [ ] Components: 3-letter prefix (btn, edt, lbl, etc.)

Tests

  • [ ] Unit tests for new code
  • [ ] Edge cases tested
  • [ ] Readable and maintainable tests

Documentation

  • [ ] XMLDoc for public methods and properties
  • [ ] Comments in Portuguese when necessary
  • [ ] Do not comment self-explanatory code

Anti-Patterns to Flag

// ❌ Números mágicos
if ACustomer.Age > 18 then

// ✅ Constantes nomeadas
const MINIMUM_AGE = 18;
if ACustomer.Age > MINIMUM_AGE then

// ❌ with statement
with AQuery do begin
  SQL.Text := '...';
  Open;
end;

// ✅ Referência explícita
AQuery.SQL.Text := '...';
AQuery.Open;

// ❌ Catch genérico
except
  on E: Exception do ShowMessage(E.Message);

// ✅ Exceptions específicas
except
  on E: EFDDBEngineException do
    raise EDatabaseException.Create('Falha: ' + E.Message);

// ❌ Logic em OnClick
procedure TfrmMain.btnSaveClick(Sender: TObject);
begin
  // 50 linhas de logic de negócio aqui
end;

// ✅ Delegar para Service
procedure TfrmMain.btnSaveClick(Sender: TObject);
begin
  FService.SaveCustomer(GetFormData);
end;

// ❌ Memory leak
function GetItems: TStringList;
begin
  Result := TStringList.Create;
  LoadItems(Result); // se LoadItems lançar exception, leak!
end;

// ✅ Seguro
function GetItems: TStringList;
begin
  Result := TStringList.Create;
  try
    LoadItems(Result);
  except
    Result.Free;
    raise;
  end;
end;

Review Comments Guide

🔴 BLOQUEANTE: Memory leak — objeto não liberado em caso de exception
🔴 BLOQUEANTE: SQL injection — query usando concatenação de string

🟡 SUGESTÃO: Extrair método — este bloco tem 35 linhas
🟡 SUGESTÃO: Usar interface em vez de classe concreta (DIP)

🟢 NIT: Renomear variável 'S' para nome descritivo
🟢 NIT: Preferir guard clause a nesting

❓ PERGUNTA: O que acontece se ACustomer for nil aqui?
❓ PERGUNTA: Este objeto é liberado por quem?

Specific SOLID Checklist

| Principle | Check | |-----------|-----------| | SRP | Does class have ONE responsibility? Service does not access data? | | OCP | Do new features add classes, not modify existing ones? | | LSP | Does either implementation of the interface work in place of the other? | | ISP | Doesn't interface have methods that implementers don't use? | | DIP | Constructor takes interfaces, not concrete classes? |

Compartilhar X LinkedIn