📄 isip_check_code.pl
字号:
($return =~ /double .*result/))) { } elsif (($return_type =~ /SysString\&/) && ($return =~ /a static SysString\& containing the class name.*/)) { } else { print "$file:$ret_line: questionable return comment\n"; } } else { print "$file:$ret_line: invalid return comment\n"; } } # make sure the classname matches the class directory # if ((($def_class =~ /$classdir/i) == 0) && ($header_file == 0)) { #print "$def_class, $classdir\n"; print "$file:$line: invalid class directory comment ($classdir != $def_class)\n"; } # make sure the method name matches the comment # if (($def_method =~ /$method/) == 0) { if ((($method =~ /structor/) == 0) && (($method =~ /operator\(\)/))) { print "$def_method, $method\n"; print "$file:$line: invalid method comment ($method != $def_method)\n"; } } if ($debug) { print "def = ", join(',',@def_args), "\n"; print "args = ", join(',',@args), "\n"; } # make sure the argument lists match # if ($header_file == 1) { $state = 7; break; } elsif ($#def_args != $#args) {# print "def = ", join(';',@def_args), "\n";# print "args = ", join(';',@args), "\n"; $all_def = join(';',@def_args); if ($all_def =~ /\(.*\*.*\)/) { print "$file:$line: different number of arguments to method $method (might be function pointers)\n"; } else { if ($debug) { print "\ndef = ", join(';',@def_args), "\n"; print "args = ", join(';',@args), "\n"; } print "$file:$line: different number of arguments to method $method\n"; } } else { if ($#args >= 0) { $i = 0; $n = $#args; for ($i = 0; $i <= $n; $i++) { $arg = join("_",shift(@args),"a"); $def_arg = shift(@def_args); if ($arg ne $def_arg) { print "$arg, $def_arg\n"; print "$file:$line: argument list doesn't match ($arg != $def_arg in method $method)\n"; } } } } if ($multi_method > 0) { $multi_method =0; } $state = 7; } } # look for either a new method comment (for multiple # methods/file), or for error calls, or for spacing, or for # logical overdeclaration. # elsif ($state == 7) { # we only allow multiple methods to be in the same file if # the first are trivial variations (overloads) of the # second, so we start a new state machine looking for # tell-tale signs. # if (($multi_method == 0) && (/call the master function/)) { $multi_method = 1; } elsif (($multi_method == 1) && (/return $method\(/)) { $multi_method = 2; } if ((($method =~ /^diagnose/) == 0) && (/Error\:\:handle\(name\(\), L\"(\w+)\"/) && ($1 ne $method)) { print "$file:$line: sending invalid methodname $1 to Error in method $method\n"; } elsif ((($method =~ /^diagnose/) == 0) && (/Error\:\:handle\(name\(\), L\"\w+\", Error::TEST/)) { print "$file:$line: Error::TEST should ONLY be used in diagnose methods\n"; } elsif (/^\s*\/\/ method: ([\w ]+)/) { if ($multi_method >= 0) { if ($multi_method != 2) { print "$file:$line: inclusion of a second method in a file which starts with a non-trivial method\n"; } if ($method ne $1) { print "$file:$line: inclusion of a second dissimilar method in one file\n"; } $multi_method = 0; } $method = $1; $method =~ s/\s*$//; if ($header_file == 1) { $state = 6; } else { $state = 4; } } # make sure we aren't too explicit with Integral::TRUE and FALSE # if (/[!=]=\s*(true|false)/) { print "$file:$line: you are too explicit with boolean's\n"; } if (/(>|>=|<|<=|-|\+)\s*(true|false)/) { print "$file:$line: you can't do this with a boolean\n"; } # possibly check spacing of operators # if (length($_) < 72) { # nix comments # if (/\/\//) { s/^(.*?)\/\/.*$/$1/; } # nix strings and literals # if (/[^\\]\".*[^\\]\"/) { while (s/^(.*?[^\\])\".*?[^\\]\"(.*)$/$1$2/) {} } # parse away template operands, too messy # if (/<.*?>/) { if ((/<.*?<[a-zA-Z_]+> >/) && ((/< .*?<[a-zA-Z_]+> >/) == 0)) { print "$file:$line: nested-template spacing error\n"; } s/<[a-zA-Z_]+>//; } if (/[^\\]\'.*[^\\]\'/) { while (s/^(.*?[^\\])\'.*?[^\\]\'(.*)$/$1$2/) {} } elsif (/const_cast/) { # do nothing for now # } # test assignment spacing # elsif (((/\b(.*?[^ \!\=\+\-\*\/\%\^\&\|\>\<]=.*?)\b/) && (("$1" =~ /\=\=/) == 0)) || ((/\b(.*?[^\!\=\+\-\*\/\%\^\&\|]=[^ ].*?)\b/) && (("$1" =~ /\=\=/) == 0))) { print "$file:$line: spacing error about =\n"; } # test logical spacing # elsif ((/[^ \t]==/) || (/==[^ ]/)) { print "$file:$line: spacing error about ==\n"; } elsif ((/[^ \t]!=/) || (/!=[^ ]/)) { print "$file:$line: spacing error about !=\n"; } elsif ((/[^ >]>=/) || (/>=[^ ]/)) { print "$file:$line: spacing error about >=\n"; } elsif ((/[^ <]<=/) || (/<=[^ ]/)) { print "$file:$line: spacing error about <=\n"; } elsif ((/[^ ]>>=/) || (/>>=[^ ]/)) { print "$file:$line: spacing error about >>=\n"; } elsif ((/[^ ]<<=/) || (/<<=[^ ]/)) { print "$file:$line: spacing error about <<=\n"; } elsif (((/[^ ->]>/) || (/[^\-]>[^ >\=]/)) && (/<[\w\ \,]+>/ == 0)) { print "$file:$line: spacing error about >\n"; print; } elsif (((/[^ <]</) || (/<[^ \=<]/)) && (/<[\w\ \,]+>/ == 0) && ((/template<>/) == 0)) { print "$file:$line: spacing error about <\n"; } # test arithmetic spacing. + and - are the worst, since we # have to allow ++ and -- # elsif (((/\b(.*?[^ \+]\+.*?)\b/) && (("$1" =~ /\+\+/) == 0) && (("$1" =~ /[eE]\+/) == 0)) || ((/\b(.*?[^\+]\+[^ \=].*?)\b/) && (("$1" =~ /\+\+/) == 0) && (("$1" =~ /[eE]\+/) == 0))) { print "$file:$line: spacing error about +\n"; } elsif ((/\b(.*?[^ \-\(\)]\-.*?)\b/) && (("$1" =~ /\-[\-\>]/) == 0) && (("$1" =~ /[eE]\-/) == 0)) { print "$file:$line: spacing error about -\n"; } # * is nearly impossible because of pointers, skip it... # # of course / is part of comment // # elsif ((/[^ ]\//) || (/\/[^ \=]/)) { print "$file:$line: spacing error about /\n"; } # I take some liberty here since you never divide on # the same line as there is a string. # elsif (((/[^ ]\\/) || (/\\[^ \=]/)) && ((/\".*\"/) == 0) && ((/\'.*\'/) == 0)) { print "$file:$line: spacing error about \\\n"; } # test accumulative arithmetic operators # elsif ((/[^ ]\+\=/) || (/\+\=[^ ]/)) { print "$file:$line: spacing error about +=\n"; } elsif ((/[^ ]\-\=/) || (/\-\=[^ ]/)) { print "$file:$line: spacing error about -=\n"; } elsif ((/[^ ]\*=/) || (/\*\=[^ ]/)) { print "$file:$line: spacing error about *=\n"; } elsif ((/[^ ]\\\=/) || (/\\\=[^ ]/)) { print "$file:$line: spacing error about \\=\n"; } elsif ((/[^ ]\/\=/) || (/\/\=[^ ]/)) { print "$file:$line: spacing error about /=\n"; } # test accumulative bitwise operators # elsif ((/[^ ]\^=/) || (/\^\=[^ ]/)) { print "$file:$line: spacing error about \^=\n"; } elsif ((/[^ ]&=/) || (/&\=[^ ]/)) { print "$file:$line: spacing error about &=\n"; } elsif ((/[^ ]\|=/) || (/\|\=[^ ]/)) { print "$file:$line: spacing error about |=\n"; } # test commas and semicolons # elsif (/\,[^ \n]/) { print "$file:$line: spacing error about ,\n"; } elsif (/\;[^ \n\t]/) { print "$file:$line: spacing error about ;\n"; } # test increment and decrement (both pre and post) # elsif ((/\ \+\+[\]\;\)]/) || (/\ \+\+\ /)) { print "$file:$line: spacing error about ++\n"; } elsif ((/\ \-\-[\]\;\)]/) || (/\ \-\-\ /)) { print "$file:$line: spacing error about --\n"; } # test a few reserve words # elsif (/if\(/) { print "$file:$line: spacing error about if\n"; } elsif (/for\(/) { print "$file:$line: spacing error about for\n"; } elsif (/while\(/) { print "$file:$line: spacing error about while\n"; } # else statements always start the line # elsif ((/else/) && ((/^\s*else/) == 0) && ((/^\s*#else/)==0)) { print "$file:$line: spacing error about else\n"; } # bracket-end should be the ONLY thing on the line, unless # it is part of a do while loop or has a semicolon after it. # elsif ((/\}/) && ((/^\s*\}\s*$/) == 0) && ((/^\s*\} while/) == 0) && ((/\};\s*$/) == 0) && ((/\{\}\s*$/) == 0)) { print "$file:$line: } should be on it's own line\n"; } # bracket-start should be last on line, space preceding # elsif (/[^ ]\{/) { print "$file:$line: spacing error about {\n"; } elsif ((/\{/) && (((/\{\s*$/) == 0) && ((/\{\}\s*$/) == 0) && ((/enum.*\{/) == 0))) { print "$file:$line: { should be end of line\n"; } } } } # if we didn't end in a final state (7), inform the user # if ($state == 6) { print "$file:$line: ($state) function '$method' never defined\n"; } elsif ($state == 5) { print "$file:$line: ($state) return value never commented\n"; } elsif ($state == 4) { print "$file:$line: ($state) arguments never commented\n"; } elsif ($state == 3) { if ($header_file == 0) { print "$file:$line: ($state) methodname never commented\n"; } } elsif ($state == 2) { print "$file:4: ($state) no \"isip include files\" listed\n"; } elsif ($state == 1) { print "$file:2: ($state) version never commented\n"; } elsif ($state == 0) { print "$file:1: ($state) filename never commented\n"; }}## end of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -