File: F002.tcl

package info (click to toggle)
vera%2B%2B 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,184 kB
  • sloc: cpp: 10,361; tcl: 921; python: 32; makefile: 5
file content (56 lines) | stat: -rwxr-xr-x 1,753 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/tclsh
# File names should be well-formed

set maxDirectoryDepth [getParameter "max-directory-depth" 8]
set maxDirnameLength [getParameter "max-dirname-length" 31]
set maxFilenameLength [getParameter "max-filename-length" 31]
set maxPathLength [getParameter "max-path-length" 100]

foreach fileName [getSourceFileNames] {
    if {[string length $fileName] > $maxPathLength} {
        report $fileName 1 "path name too long"
    }

    set dirDepth 0
    foreach dir [file split [file dirname $fileName]] {
        if {$dir == "/" || $dir == "." || $dir == ".."} {
            continue
        }

        incr dirDepth

        if {[string length $dir] > $maxDirnameLength} {
            report $fileName 1 "directory name component too long"
            break
        }

        set first [string index $dir 0]
        if {[string is alpha $first] == 0 && $first != "_"} {
            report $fileName 1 "directory name should start with alphabetic character or underscore"
            break
        }

        if {[string first "." $dir] != -1} {
            report $fileName 1 "directory name should not contain a dot"
            break
        }
    }

    if {$dirDepth >= $maxDirectoryDepth} {
        report $fileName 1 "directory structure too deep"
    }

    set leafName [file tail $fileName]
    if {[string length $leafName] > $maxFilenameLength} {
        report $fileName 1 "file name too long"
    }

    set first [string index $leafName 0]
    if {[string is alpha $first] == 0 && $first != "_"} {
        report $fileName 1 "file name should start with alphabetic character or underscore"
    }

    if {[llength [split $leafName .]] > 2} {
        report $fileName 1 "file name should not contain more than one dot"
    }
}