-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
288 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<buildpath> | ||
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/> | ||
<buildpathentry kind="src" path="vendor/composer"> | ||
<attributes> | ||
<attribute name="composer" value="vendor"/> | ||
</attributes> | ||
</buildpathentry> | ||
</buildpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# IDE relatives | ||
/.idea/ | ||
|
||
# Composer | ||
/vendor/ | ||
composer.lock | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,8 @@ | |
} | ||
}, | ||
"name" : "kamelot/code-sniffer", | ||
"description" : "Ruleset for phpcodesniffer\n\nC'est mon premier package composer.\nC'est mon premier gitflow.\nC'est mon premier Ruleset.\n\nTout feedback est bien venu", | ||
"license": "LGPL-3.0", | ||
|
||
"description" : "Ruleset for phpcodesniffer. C'est mon premier package composer. C'est mon premier gitflow. C'est mon premier Ruleset. Tout feedback est bien venu", | ||
"license" : "LGPL-3.0", | ||
"require" : { | ||
"squizlabs/php_codesniffer" : "3.1.0", | ||
"php" : ">=7.0" | ||
|
@@ -24,5 +23,8 @@ | |
"email" : "[email protected]", | ||
"role" : "Developper" | ||
} | ||
] | ||
], | ||
"require-dev": { | ||
"phpunit/phpunit": "^6.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd" | ||
bootstrap="tests/autoload.php" | ||
forceCoversAnnotation="true" | ||
beStrictAboutCoversAnnotation="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
verbose="true"> | ||
|
||
<testsuite name="Full tests"> | ||
<directory suffix="Test.php">tests</directory> | ||
</testsuite> | ||
|
||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<?php | ||
/** | ||
* Generic_Sniffs_Commenting_TodoSniff. | ||
* | ||
* PHP version 5 | ||
* | ||
* @category PHP | ||
* @package PHP_CodeSniffer | ||
* @author Greg Sherwood <[email protected]> | ||
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) | ||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | ||
* @link http://pear.php.net/package/PHP_CodeSniffer | ||
*/ | ||
|
||
namespace Standards\Sniffs\Comments; | ||
|
||
use PHP_CodeSniffer\Files\File; | ||
use PHP_CodeSniffer\Sniffs\Sniff; | ||
use PHP_CodeSniffer\Util\Tokens; | ||
|
||
/** | ||
* Based on Generic_Sniffs_Commenting_TodoSniff. | ||
* | ||
* Warns about TO DO comments. | ||
* | ||
* @category PHP | ||
* @package PHP_CodeSniffer | ||
* @author Greg Sherwood <[email protected]> | ||
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) | ||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | ||
* @version Release: @package_version@ | ||
* @link http://pear.php.net/package/PHP_CodeSniffer | ||
*/ | ||
|
||
class TodoSniff implements Sniff | ||
{ | ||
|
||
/** | ||
* A list of tokenizers this sniff supports. | ||
* | ||
* @var array | ||
*/ | ||
public $supportedTokenizers = array( | ||
'PHP', | ||
'JS', | ||
); | ||
|
||
|
||
/** | ||
* Returns an array of tokens this test wants to listen for. | ||
* | ||
* @return array | ||
*/ | ||
public function register() | ||
{ | ||
return Tokens::$commentTokens; | ||
|
||
}//end register() | ||
|
||
|
||
/** | ||
* Processes this sniff, when one of its tokens is encountered. | ||
* | ||
* @param File $phpcsFile The file being scanned. | ||
* @param int $stackPtr The position of the current token in the stack passed in $tokens. | ||
* | ||
* @return int | ||
*/ | ||
public function process(File $phpcsFile, $stackPtr) | ||
{ | ||
$tokens = $phpcsFile->getTokens(); | ||
|
||
$foundComments = []; | ||
$stackEnable = false; | ||
$blockCommentStack = []; | ||
foreach($tokens as $token) { | ||
$code = $token['code']; | ||
$line = $token['line']; | ||
$content = $token['content']; | ||
|
||
//search inline comment | ||
if ($code === T_COMMENT && !$stackEnable) { | ||
$foundComments[$line] = $content; | ||
} | ||
|
||
|
||
//search block comments | ||
if ($code === T_DOC_COMMENT_OPEN_TAG) { | ||
$stackEnable = true; | ||
continue; | ||
} | ||
|
||
if ($code === T_DOC_COMMENT_CLOSE_TAG) { | ||
$foundComments[$line] = join('', $blockCommentStack); | ||
$blockCommentStack = []; | ||
$stackEnable = false; | ||
} | ||
|
||
if ($stackEnable) { | ||
$blockCommentStack[] = $content; | ||
} | ||
} | ||
|
||
foreach ($foundComments as $lineNumber => $foundComment) { | ||
$this->handleComment($phpcsFile, $lineNumber - 1, $foundComment); | ||
} | ||
|
||
return count($tokens) + 1; | ||
} | ||
|
||
private function handleComment(File $phpcsFile, $lineNumber, $foundComment) | ||
{ | ||
if (preg_match('/(?:\A|[^\p{L}]+)todo([^\p{L}]+(.*)|\Z)/ui', $foundComment, $matches)) { | ||
if (! preg_match('/WWW([a-z])*-([0-9])*/ui', $matches[1], $jiramatches)) { | ||
// Clear whitespace and some common characters not required at | ||
// the end of a to-do message to make the warning more informative. | ||
|
||
$type = 'CommentFound'; | ||
$todoMessage = trim($matches[1]); | ||
$todoMessage = trim($todoMessage, '-:[](). '); | ||
$error = "Ajoutez l'id du ticket jira lié à ce TODO "; | ||
$data = array($todoMessage); | ||
if ($todoMessage !== '') { | ||
$type = 'TaskFound'; | ||
$error .= ' "%s"'; | ||
} | ||
|
||
$phpcsFile->addWarning($error, $lineNumber, $type, $data); | ||
} | ||
} | ||
|
||
} | ||
}//end class |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.