Eric Radman : a Journal

Basic Checks

These are few tools that are of immense value in raising the level of consistency and quality of each commit.

Spelling and Typos

Static Analysis

Whitespace Check

#!/usr/bin/awk -f

function warn(msg) {
  print FILENAME ":" NR, msg
  ret=1;
}

# single line checks
/ $/ { warn("trailing space"); }
/\t$/ { warn("trailing tab"); }
/ \t/ { warn("tab after space"); }
/\x0D$/ { warn("line ending with \\r\\n"); exit 1; }

# multi-line checks
/^\t/ { if (prev ~ /^ /) warn("mixed tabs and spaces"); }
/^ / { if (prev ~ /^\t/) warn("mixed tabs and spaces"); }

# keep state
{ prev=$0; }

END {
  if ($0 ~ /^$/) warn("empty line at end of file")
  exit ret
}