8000 Add phpcs and codeclimate configuration · notion/forkdaemon-php@720fca6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 720fca6

Browse files
committed
Add phpcs and codeclimate configuration
1 parent acd554b commit 720fca6

12 files changed

+2197
-0
lines changed

.codeclimate.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
exclude_paths:
2+
- ".phpcs/**/*"
3+
- "examples/**/*"
4+
engines:
5+
phpmd:
6+
enabled: false
7+
config:
8+
file_extensions: "php"
9+
rulesets: "unusedcode"
10+
phpcodesniffer:
11+
enabled: true
12+
config:
13+
file_extensions: "php"
14+
standard: "/code/.phpcs/Barracuda/ruleset.xml"
15+
ignore_warnings: true
16+
fixme:
17+
enabled: true
18+
ratings:
19+
paths:
20+
- "**/*.php"
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* This sniff prohibits the use of single line multi line comments
4+
*
5+
* PHP version 5
6+
*
7+
* @category PHP
8+
* @package PHP_CodeSniffer
9+
* @author Ryan Matthews <rmatthews@barracuda.com>
10+
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
11+
* @version 1.0.00
12+
* @link http://pear.php.net/package/PHP_CodeSniffer
13+
*/
14+
15+
/**
16+
* This sniff prohibits the use of Perl style hash comments.
17+
*
18+
* An example of a hash comment is:
19+
*
20+
* <code>
21+
* /* This is a single line multi line comment, which is prohibited. */
22+
/* $hello = 'hello';
23+
* </code>
24+
*
25+
* @category PHP
26+
* @package PHP_CodeSniffer
27+
* @author Ryan Matthews <rmatthews@barracuda.com>
28+
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
29+
* @version Release: 1.0.00
30+
* @link http://pear.php.net/package/PHP_CodeSniffer
31+
*/
32+
class Barracuda_Sniffs_Commenting_DisallowSingleLineMultiCommentsSniff implements PHP_CodeSniffer_Sniff
33+
{
34+
35+
36+
/**
37+
* Returns the token types that this sniff is interested in.
38+
*
39+
* @return array(int)
40+
*/
41+
public function register()
42+
{
43+
return array(T_COMMENT);
44+
45+
}// end register()
46+
47+
48+
/**
49+
* Processes the tokens that this sniff is interested in.
50+
*
51+
* @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
52+
* @param int $stackPtr The position in the stack where
53+
* the token was found.
54+
*
55+
* @return void
56+
*/
57+
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
58+
{
59+
$tokens = $phpcsFile->getTokens();
60+
if (preg_match('/\/\*[^\n]*\*\//', $tokens[$stackPtr]['content']))
61+
{
62+
$error = 'Multi line comments are prohibited on single lines; found %s';
63+
$data = array(trim($tokens[$stackPtr]['content']));
64+
$phpcsFile->addError($error, $stackPtr, 'Found', $data);
65+
}
66+
67+
}// end process()
68+
}
69+
// end class
70+

0 commit comments

Comments
 (0)
0