Skip to content

Commit

Permalink
CodeSniffer MDL-19247 I updated the README, moved and renamed phpcs =…
Browse files Browse the repository at this point in the history
…> runsniffer script, and modifed some rules for line length and require statements
  • Loading branch information
moodler committed May 20, 2009
1 parent 8559ea1 commit e624cda
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -47,7 +47,7 @@ class Moodle_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
*
* @var int
*/
protected $absoluteLineLimit = 120;
protected $absoluteLineLimit = 200;


/**
Expand Down
15 changes: 6 additions & 9 deletions phpcs → lib/pear/PHP/runsniffer
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
* @author Marc McIntyre <[email protected]>
* @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';
}
Expand Down
20 changes: 18 additions & 2 deletions lib/pear/README_MOODLE.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
MOODLE-SPECIFIC PEAR MODIFICATIONS
==================================


Spreadsheet/Excel
=================

These functions:
_calculateSharedStringsSizes()
_storeSharedStringsTable()
Expand All @@ -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


0 comments on commit e624cda

Please sign in to comment.