CodeSniffer MDL-19247 I updated the README, moved and renamed phpcs => runsniffer script, and modifed some rules for line length and require statements

This commit is contained in:
moodler
2009-05-20 06:35:46 +00:00
parent 8559ea1080
commit e624cda83b
4 changed files with 33 additions and 20 deletions

View File

@@ -74,13 +74,13 @@ class Moodle_Sniffs_Files_IncludingFileSniff implements PHP_CodeSniffer_Sniff
{
$tokens = $phpcsFile->getTokens();
$nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS) {
$error = '"'.$tokens[$stackPtr]['content'].'"';
$error .= ' is a statement, not a function; ';
$error .= 'no parentheses are required';
$phpcsFile->addError($error, $stackPtr);
}
//$nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
//if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS) {
// $error = '"'.$tokens[$stackPtr]['content'].'"';
// $error .= ' is a statement, not a function; ';
// $error .= 'no parentheses are required';
// $phpcsFile->addError($error, $stackPtr);
//}
$inCondition = (count($tokens[$stackPtr]['conditions']) !== 0) ? true : false;

View File

@@ -38,7 +38,7 @@ class Moodle_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
*
* @var int
*/
protected $lineLimit = 80;
protected $lineLimit = 120;
/**
* The limit that the length of a line must not exceed.
@@ -47,7 +47,7 @@ class Moodle_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
*
* @var int
*/
protected $absoluteLineLimit = 120;
protected $absoluteLineLimit = 200;
/**

View File

@@ -1,25 +1,22 @@
#!/usr/bin/php
<?php
/**
* PHP_CodeSniffer tokenises PHP code and detects violations of a
* defined set of coding standards.
* This script will run PHP CodeSniffer across given Moodle directories and
* produce reports of coding standard violations.
*
* PHP version 5
* HOW TO USE:
* php lib/pear/PHP/runsniffer mod/forum
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood <gsherwood@squiz.net>
* @author Marc McIntyre <mmcintyre@squiz.net>
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
* @version CVS: $Id$
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
error_reporting(E_ALL | E_STRICT);
if (is_file(dirname(__FILE__).'/../CodeSniffer/CLI.php') === true) {
include_once dirname(__FILE__).'/../CodeSniffer/CLI.php';
if (is_file(dirname(__FILE__).'/CodeSniffer/CLI.php') === true) {
include_once dirname(__FILE__).'/CodeSniffer/CLI.php';
} else {
include_once 'lib/pear/PHP/CodeSniffer/CLI.php';
}

View File

@@ -1,3 +1,10 @@
MOODLE-SPECIFIC PEAR MODIFICATIONS
==================================
Spreadsheet/Excel
=================
These functions:
_calculateSharedStringsSizes()
_storeSharedStringsTable()
@@ -10,5 +17,14 @@ and documented for Moodle at:
Such modifications should be carefuly each time the Excel PEAR package is updated
to a new release within Moodle.
stronk7
$Id$
PHP/CodeSniffer
===============
A whole Moodle coding standards definition sits in lib/pear/PHP/CodeSniffer/Standards/Moodle
To run the codesniffer, you can call the runsniffer script using your command-line php binary:
Example: /usr/bin/php lib/pear/PHP/runsniffer mod/forum