mirror of
https://github.com/moodle/moodle.git
synced 2025-07-25 08:11:39 +02:00
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:
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
||||
/**
|
||||
|
34
lib/pear/PHP/runsniffer
Executable file
34
lib/pear/PHP/runsniffer
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
/**
|
||||
* This script will run PHP CodeSniffer across given Moodle directories and
|
||||
* produce reports of coding standard violations.
|
||||
*
|
||||
* HOW TO USE:
|
||||
* php lib/pear/PHP/runsniffer mod/forum
|
||||
*
|
||||
* @package PHP_CodeSniffer
|
||||
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
|
||||
* @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';
|
||||
} else {
|
||||
include_once 'lib/pear/PHP/CodeSniffer/CLI.php';
|
||||
}
|
||||
|
||||
$phpcs = new PHP_CodeSniffer_CLI();
|
||||
$phpcs->checkRequirements();
|
||||
|
||||
$numErrors = $phpcs->process();
|
||||
if ($numErrors === 0) {
|
||||
exit(0);
|
||||
} else {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
?>
|
@@ -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
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user