Major function scanning bugfix, as well as some parser improvements. Fault list now supports page up / down keys. Mantis: 2691
git-svn-id: file:///srv/svn/scanner/trunk@11 a0501263-5b7a-4423-a8ba-1edf086583e7
This commit is contained in:
parent
227d59c733
commit
ea365a09dd
3 changed files with 29 additions and 8 deletions
|
@ -8,7 +8,7 @@ function FunctionsModule_callback_global( $object ) {
|
|||
global $FunctionsModule_functions, $FunctionsModule_file;
|
||||
$FunctionsModule_functions[$object['name']] = array(
|
||||
'used' => 0,
|
||||
'file' => $FunctionsModule_file
|
||||
'file' => $object['file']
|
||||
);
|
||||
}
|
||||
function FunctionsModule_callback_local( $object ) {
|
||||
|
@ -97,7 +97,7 @@ class FunctionsModule extends ScannerModule {
|
|||
!in_array( $object['name'], $this->internal_functions )
|
||||
&& !in_array( $object['name'], array_keys( $FunctionsModule_local_functions[filename( $object['file'] )] ) )
|
||||
) {
|
||||
$this->fault( $object, FAULT_MAJOR, "Undefined function '{$object['name']}'" );
|
||||
$this->fault( $object, FAULT_MAJOR, "Undefined function '{$object['name']}'", true );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -119,9 +119,9 @@ class FunctionsModule extends ScannerModule {
|
|||
$open_blocks = is_array( $object['open_blocks'] ) ? implode( ',', $object['open_blocks'] ) : '';
|
||||
$info = "called[l={$object['line']};b={$object['block']};d={$object['depth']}]" . ( !$bad ? ", required[l={$inc['line']};b={$inc['block']};d={$inc['depth']}] open[{$open_blocks}]" : '' );
|
||||
if( $bad === true ) {
|
||||
$this->fault( $object, FAULT_MAJOR, "Undefined function '{$object['name']}' $info" );
|
||||
$this->fault( $object, FAULT_MAJOR, "Undefined function '{$object['name']}' $info", true );
|
||||
} elseif( $warning === true ) {
|
||||
$this->fault( $object, FAULT_MEDIUM, "Potentially undefined function '{$object['name']}' $info" );
|
||||
$this->fault( $object, FAULT_MEDIUM, "Potentially undefined function '{$object['name']}' $info", true );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
16
parser.php
16
parser.php
|
@ -137,6 +137,7 @@ class PHPParser {
|
|||
&& !empty( $string )
|
||||
&& $last_token != T_FUNCTION
|
||||
&& $last_token != T_OBJECT_OPERATOR
|
||||
&& $last_token != T_DOUBLE_COLON
|
||||
&& $last_token != T_NEW
|
||||
//&& ( (bool)($this->fetch_mode & PHPPARSER_FETCH_INTERNAL) && !in_array( $string, $this->internal_functions ) )
|
||||
) {
|
||||
|
@ -332,6 +333,21 @@ class PHPParser {
|
|||
T_ECHO,
|
||||
T_PRINT
|
||||
) ) ) ? $text : ' ';
|
||||
if( (bool)($this->fetch_mode & PHPPARSER_FETCH_EXPRESSIONS) && in_array( $id, array( T_CLOSE_TAG ) ) && strlen( trim( $expression ) ) > 0 ) {
|
||||
$this->foundObject( array(
|
||||
'type' => PHPPARSER_EXPRESSION,
|
||||
'name' => trim( $expression ),
|
||||
'file' => $this->file_name,
|
||||
'context' => $lines[$line - 1],
|
||||
'line' => $line,
|
||||
'block' => $block,
|
||||
'depth' => $depth,
|
||||
'in_class' => $classname,
|
||||
'in_function' => $functionname,
|
||||
'open_blocks' => $open_blocks
|
||||
) );
|
||||
$expression = '';
|
||||
}
|
||||
$count = preg_match_all( '/\r?(\n|\r)/', $text, $m );
|
||||
$line += $count;
|
||||
}
|
||||
|
|
13
scanner.php
13
scanner.php
|
@ -62,9 +62,9 @@ class ScannerModule {
|
|||
$this->blame = array();
|
||||
err( "Initializing " . get_class( $this ) . "...\n" );
|
||||
}
|
||||
function fault( $object, $level, $reason = '' ) {
|
||||
function fault( $object, $level, $reason = '', $force = false ) {
|
||||
global $config, $revisions, $faults;
|
||||
if( $this->file['revision'] > 0 && $this->blame[$object['line']]['revision'] != $this->file['revision'] ) {
|
||||
if( !$force && $this->file['revision'] > 0 && $this->blame[$object['line']]['revision'] != $this->file['revision'] ) {
|
||||
/* If files have been added using SVN revisions, filter out any faulty
|
||||
changes that aren't a part of the requested changeset(s).
|
||||
*/
|
||||
|
@ -74,7 +74,7 @@ class ScannerModule {
|
|||
$faults[] = $this->faults[] = array(
|
||||
'module' => get_class( $this ),
|
||||
'object' => $object,
|
||||
'file' => $this->file,
|
||||
'file' => $object['file'],
|
||||
'line' => $object['line'],
|
||||
'level' => $level,
|
||||
'reason' => $reason,
|
||||
|
@ -346,7 +346,6 @@ err( "\n" );
|
|||
|
||||
if( $curses ) {
|
||||
$nc_faults->load( $faults );
|
||||
$nc_faults->update( count( $faults ) );
|
||||
$done = false;
|
||||
while( !$done ) {
|
||||
$key = $nc_main->get_char();
|
||||
|
@ -357,6 +356,12 @@ if( $curses ) {
|
|||
case NCURSES_KEY_DOWN:
|
||||
$nc_faults->update( $nc_faults->selected + 1 );
|
||||
break;
|
||||
case NCURSES_KEY_PPAGE:
|
||||
$nc_faults->update( $nc_faults->selected - $nc_faults->height - 1 );
|
||||
break;
|
||||
case NCURSES_KEY_NPAGE:
|
||||
$nc_faults->update( $nc_faults->selected + $nc_faults->height - 1 );
|
||||
break;
|
||||
case 10:
|
||||
case 13:
|
||||
$nc_fault_info = new NcWindow( $nc_main, -10, -10, 5, 5 );
|
||||
|
|
Loading…
Reference in a new issue