diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2012-08-01 12:39:56 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2012-08-01 12:39:56 +0000 |
commit | 50d0e7f22900efb32851b7f624b57f7f353af014 (patch) | |
tree | eb885a4a4622d47ca20308ae4b044b3b48a0764c /tools/check-typo | |
parent | 4d44df1374c90ea84ba5500405c0e373fb6f6477 (diff) | |
download | ocaml-50d0e7f22900efb32851b7f624b57f7f353af014.tar.gz |
add detection of missing copyright headers
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12805 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'tools/check-typo')
-rwxr-xr-x | tools/check-typo | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/tools/check-typo b/tools/check-typo index 427873b5d5..3968ae7955 100755 --- a/tools/check-typo +++ b/tools/check-typo @@ -23,6 +23,7 @@ # - absence of white lines at end of file (white-at-eof) # - presence of a LF character at the end of the file (missing-lf) # - maximum line length of 80 characters (long-line) +# - presence of a copyright header (missing-header) # Exceptions are handled with a SVN property: "ocaml:typo". # Its value for a given file is a comma-separated list of rule names, @@ -34,6 +35,17 @@ # is automatically exempt from all the rules. # - Any file whose name begins with "Makefile" is automatically exempt # from the "tabs" rule. +# - Any file whose name matches one of the following patterns is +# automatically exempt from the "missing-header" rule. +# */.depend +# */.ignore +# *.mlpack +# *.mllib +# *.odocl +# *.clib +# */unmaintained/* +# */experimental/* +# *.reference # ASCII characters are bytes from 0 to 127. Any other byte is # flagged as a non-ASCII character. @@ -103,8 +115,14 @@ IGNORE_DIRS=' fi rules="$userrules" case "$f" in - Makefile*) rules="tab,$rules";; - */Makefile*) rules="tab,$rules";; + Makefile*|*/Makefile*) rules="tab,$rules";; + esac + h(){ rules="missing-header,$rules"; } + case "$f" in + */.depend|*/.ignore) h;; + *.mlpack|*.mllib|*.odocl|*.itarget|*.clib) h;; + */unmaintained/*|*/experimental/*) h;; + *.reference) h;; esac (cat "$f"; echo) \ @@ -141,10 +159,19 @@ IGNORE_DIRS=' length($0) > 80 { RSTART = 81; - RLENGTH = length($0) - 81; + RLENGTH = 0; err("long-line", "line is over 80 characters"); } + 3 <= NR && NR <= 8 \ + && (/ OCaml / || / ocamlbuild / || / OCamldoc /) { + header_ocaml = 1; + } + + 7 <= NR && NR <= 12 && / Copyright / && header_ocaml { + header_copyright = 1; + } + { prev_line = last_line; last_line = $0; @@ -162,12 +189,17 @@ IGNORE_DIRS=' if (!empty_file && match(prev_line, /^[ \t]*$/)){ err("white-at-eof", "white line(s) at EOF"); } + NR = 1; + RSTART = 1; + RLENGTH = 0; + if (!(header_ocaml && header_copyright)){ + err("missing-header", "missing copyright header"); + } split(svnrules, r, ","); for (i in r){ name = r[i]; if (name != "" && !counts[name]){ - printf ("%s, line 1, char 1: unused rule exception [%s]\n", - file, name); + err("unused-prop", sprintf("unused [%s] in ocaml:typo", name)); } } } |