From a89d8e070932060722a9018d821bdbdb6d1650f8 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Fri, 17 Jul 2009 05:56:49 +0000 Subject: [PATCH] todochecker script: skip third party code. --- lib/simpletest/todochecker.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/simpletest/todochecker.php b/lib/simpletest/todochecker.php index 093240a410c..37c564e5ef9 100644 --- a/lib/simpletest/todochecker.php +++ b/lib/simpletest/todochecker.php @@ -37,6 +37,7 @@ $PAGE->set_context($context); $PAGE->set_title('To-do checker'); $PAGE->set_heading('To-do checker'); +$thirdparty = load_third_party_lib_list(); $extensionstotest = array('php'); $extensionsregex = '/\.(?:' . implode('|', $extensionstotest) . ')$/'; $patterntofind = 'TO' . 'DO'; // Make it not match the regex. @@ -48,7 +49,7 @@ echo $OUTPUT->heading('To-do checker', 2); echo $OUTPUT->box_start(); echo 'Checking code ...'; flush(); -recurseFolders($CFG->dirroot, 'check_to_dos', $extensionsregex); +recurseFolders($CFG->dirroot, 'check_to_dos', $extensionsregex, false, array_keys($thirdparty)); echo ' done.'; echo $OUTPUT->box_end(); @@ -100,7 +101,10 @@ if (empty($found)) { echo $OUTPUT->footer(); function check_to_dos($filepath) { - global $CFG, $found; + global $CFG, $found, $thirdparty; + if (isset($thirdparty[$filepath])) { + return; // Skip this file. + } $lines = file($filepath); $matchesinfile = array(); foreach ($lines as $lineno => $line) { @@ -127,3 +131,13 @@ function issue_open($issueid) { $cache[$issueid] = $result; return $result; } + +function load_third_party_lib_list() { + global $CFG; + $libs = array(); + $xml = simplexml_load_file($CFG->libdir . '/thirdpartylibs.xml'); + foreach ($xml->library as $libobject) { + $libs[$CFG->libdir . '/' . $libobject->location] = 1; + } + return $libs; +} \ No newline at end of file