##Nagelfar Plugin : Check of Eskil's sources

proc statementWords {words info} {
    set caller [dict get $info caller]
    set callee [lindex $words 0]
    set res {}

    # Rule: Space around initial "!" in expr.
    # Reason: I find it more readable
    if {$callee eq "if"} {
        set e [lindex $words 1]
        if {[regexp {\{(\s*)!(\s*)[\[$]} $e -> pre post]} {
            if {$pre ne " " || $post ne " "} {
                lappend res warning
                lappend res "Not (!) should be surrounded by one space"
            }
        }
    }
    # Rule: Do not allow single letter variables as arguments.
    # Reason: A lot of old unreadable code had them.
    # Exception: Upper-case "W","x" and "y".
    if {$callee eq "proc"} {
        set argList [lindex $words 2]
        foreach arg [lindex $argList 0] {
            set arg [lindex $arg 0]

            set lcArg [string tolower $arg]
            if {[string length $arg] == 1 && $lcArg eq $arg} {
                if {$arg ni {x y}} {
                    lappend res warning
                    lappend res "Single letter argument '$arg' is not allowed '$argList'"
                }
            }
        }
    }

    
    return $res
}
