Changeset 1384

Show
Ignore:
Timestamp:
02/27/08 15:03:45 (8 months ago)
Author:
richi
Message:

defect #127: fixed issues with "// @codeCoverageIgnoreStart" (hopefully now ;D)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/org/stubbles/codeSniffer/Stubbles/Sniffs/Commenting/stubFunctionCommentSniff.php

    r1375 r1384  
    111111 
    112112        /* 
    113          * Stubbles (ignore code coverage comments
     113         * Stubbles (ignore code coverage comments - 1/2
    114114         */ 
    115         if (rtrim($content)  !== '// @codeCoverageIgnoreStart') { 
    116             if ($code === T_COMMENT) { 
    117                 $error = 'You must use "/**" style comments for a function comment'; 
    118                 $phpcsFile->addError($error, $stackPtr); 
    119                 return; 
    120             } else if ($code !== T_DOC_COMMENT) { 
    121                 $phpcsFile->addError('Missing function doc comment', $stackPtr); 
    122                 return; 
    123             } 
     115        if (rtrim($content)  === '// @codeCoverageIgnoreStart') { 
     116            // take real T_DOC_COMMENT instead of T_COMMENT 
     117            $commentEnd = $phpcsFile->findPrevious($find, ($commentEnd - 1)); 
     118            $code     = $tokens[$commentEnd]['code']; 
     119            $content  = $tokens[$commentEnd]['content']; 
     120        } 
     121 
     122        if ($code === T_COMMENT) { 
     123            $error = 'You must use "/**" style comments for a function comment'; 
     124            $phpcsFile->addError($error, $stackPtr); 
     125            return; 
     126        } else if ($code !== T_DOC_COMMENT) { 
     127            $phpcsFile->addError('Missing function doc comment', $stackPtr); 
     128            return; 
    124129        } 
    125130 
     
    131136        $ignore[]  = T_ABSTRACT; 
    132137        $ignore[]  = T_FINAL; 
     138 
     139        /* 
     140         * Stubbles (ignore code coverage comments - 2/2) 
     141         */ 
     142        $ignore[]  = T_COMMENT; 
     143 
    133144        $prevToken = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true); 
    134145        if ($prevToken !== $commentEnd) { 
     
    341352                } 
    342353            } 
    343  
    344         } 
     354    } 
    345355 
    346356    }