The following list of items focuses on points of potential weakness and improvement to consider during a code review of a SQL script.
- Do the header notes identify the script's purpose, author, and revision history?
- Is the code formatted for readability?
- Do comments accurately describe the purpose of functional blocks within the script?
- Are nullable columns used in joins without accounting for the possibility of nulls?
- Are nullable columns used in WHERE clause conditions without accounting for the possibility of nulls?
- Are all appropriate columns used in each join expression?
- Do any inner joins result in the erroneous exclusion of rows because one table has non-matching rows?
- Do any joins result in unintended expansion of rows (e.g., because there is a many-to-many relationship between the tables when the relationship should be one-to-one or one-to-many)?
- Are values in imported data sets tested for completeness, consistency, and uniqueness, as appropriate?
- Are there undocumented or implicit assumptions about data or relationships in the code?
- Are any hard-coded values correct for the database in use (e.g., codes originally to be used with a different database carried over to the current database; capitalization correct)?
- Is the logic of AND and OR clauses in WHERE clauses correct?
- Is the logic of non-equi-join conditions correct?
- Is the logic or algebra of calculations correct?
- Are function arguments correct?
- Are there any equality comparisons between floating-point numbers when they are not drawn unmodified from the same table column?
- Are constant values defined as substitution variables in a configuration section at the head of the script or in a configuration file?
- Are table names used in execsql IMPORT metacommands in the appropriate case for the DBMS (e.g., lowercase for Postgres)?
- Are library scripts used where appropriate?
- Are transactions used where appropriate, and can committing of transactions be easily enabled or disabled?
- Is code repetition minimized through appropriate use of temporary queries or tables, subqueries, CTEs, functions, or execsql INCLUDE or SCRIPT metacommands?
- Does the code provide information about progress and status as it runs?
- Are any important actions missing?
No comments:
Post a Comment