mirror of
https://github.com/moodle/moodle.git
synced 2025-07-26 00:31:35 +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();
|
$tokens = $phpcsFile->getTokens();
|
||||||
|
|
||||||
$nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
//$nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
|
||||||
if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS) {
|
//if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS) {
|
||||||
$error = '"'.$tokens[$stackPtr]['content'].'"';
|
// $error = '"'.$tokens[$stackPtr]['content'].'"';
|
||||||
$error .= ' is a statement, not a function; ';
|
// $error .= ' is a statement, not a function; ';
|
||||||
$error .= 'no parentheses are required';
|
// $error .= 'no parentheses are required';
|
||||||
$phpcsFile->addError($error, $stackPtr);
|
// $phpcsFile->addError($error, $stackPtr);
|
||||||
}
|
//}
|
||||||
|
|
||||||
$inCondition = (count($tokens[$stackPtr]['conditions']) !== 0) ? true : false;
|
$inCondition = (count($tokens[$stackPtr]['conditions']) !== 0) ? true : false;
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ class Moodle_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
|
|||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $lineLimit = 80;
|
protected $lineLimit = 120;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The limit that the length of a line must not exceed.
|
* 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
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $absoluteLineLimit = 120;
|
protected $absoluteLineLimit = 200;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,25 +1,22 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHP_CodeSniffer tokenises PHP code and detects violations of a
|
* This script will run PHP CodeSniffer across given Moodle directories and
|
||||||
* defined set of coding standards.
|
* produce reports of coding standard violations.
|
||||||
*
|
*
|
||||||
* PHP version 5
|
* HOW TO USE:
|
||||||
|
* php lib/pear/PHP/runsniffer mod/forum
|
||||||
*
|
*
|
||||||
* @category PHP
|
|
||||||
* @package PHP_CodeSniffer
|
* @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)
|
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||||
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
|
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
|
||||||
* @version CVS: $Id$
|
|
||||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT);
|
error_reporting(E_ALL | E_STRICT);
|
||||||
|
|
||||||
if (is_file(dirname(__FILE__).'/../CodeSniffer/CLI.php') === true) {
|
if (is_file(dirname(__FILE__).'/CodeSniffer/CLI.php') === true) {
|
||||||
include_once dirname(__FILE__).'/../CodeSniffer/CLI.php';
|
include_once dirname(__FILE__).'/CodeSniffer/CLI.php';
|
||||||
} else {
|
} else {
|
||||||
include_once 'lib/pear/PHP/CodeSniffer/CLI.php';
|
include_once 'lib/pear/PHP/CodeSniffer/CLI.php';
|
||||||
}
|
}
|
@@ -1,3 +1,10 @@
|
|||||||
|
MOODLE-SPECIFIC PEAR MODIFICATIONS
|
||||||
|
==================================
|
||||||
|
|
||||||
|
|
||||||
|
Spreadsheet/Excel
|
||||||
|
=================
|
||||||
|
|
||||||
These functions:
|
These functions:
|
||||||
_calculateSharedStringsSizes()
|
_calculateSharedStringsSizes()
|
||||||
_storeSharedStringsTable()
|
_storeSharedStringsTable()
|
||||||
@@ -10,5 +17,14 @@ and documented for Moodle at:
|
|||||||
Such modifications should be carefuly each time the Excel PEAR package is updated
|
Such modifications should be carefuly each time the Excel PEAR package is updated
|
||||||
to a new release within Moodle.
|
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