Eskil

Diff
Login

Differences From Artifact [a9cec29ad6]:

To Artifact [f3080718aa]:


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
##Nagelfar Plugin : Check of Eskil's sources

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

    # Experiment with coding standard

    if {$callee eq "if"} {
        set e [lindex $words 1]
        if {[regexp {\{(\s*)!(\s*)\[} $e -> pre post]} {
            # Trying two possible rules for whitespace
            if 1 {
                if {$pre ne "" || $post ne ""} {
                    lappend res warning
                    lappend res "Not (!) should not be surrounded by space"
                }









            } else {


                if {$pre ne " " || $post ne " "} {
                    lappend res warning
                    lappend res "Not (!) should be surrounded by one space"
                }
            }
        }
    }


    return $res
}







|
>


|
<
<
|
|
|
|
>
>
>
>
>
>
>
>
>
|
>
>
|

|




>
>


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
##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
}