Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.

Commit b86aa57

Browse files
committed
Reconfigured code sniffer to use vendor libs for wpcs and phpcs, update PSR2 to make comment required
1 parent f3b2d16 commit b86aa57

File tree

597 files changed

+99
-77251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

597 files changed

+99
-77251
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.DS_Store
2-
.idea
2+
.idea
3+
/vendor
4+
/composer.lock

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
Installation instructions:
44

55
1. Clone repository on your drive
6+
2. Run `composer install`
67
2. Run: `chmod +x phpcsx phpmd`
78
3. Configure your PhpStorm to use both scripts

bin/phpcsx-init

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
$root = dirname(__FILE__) . '/..';
5+
6+
require_once $root . '/vendor/squizlabs/php_codesniffer/autoload.php';
7+
8+
$argv = [
9+
$_SERVER['argv'][0],
10+
'--config-set',
11+
'installed_paths',
12+
implode(',', array(
13+
$root . '/vendor/wp-coding-standards/wpcs/',
14+
$root . '/justcoded/',
15+
)),
16+
];
17+
$_SERVER['argv'] = $argv;
18+
$_SERVER['argc'] = count($argv);
19+
20+
$runner = new PHP_CodeSniffer\Runner();
21+
$exitCode = $runner->runPHPCS();
22+
exit($exitCode);

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@
2222
"php": ">=5.4.0",
2323
"ext-tokenizer": "*",
2424
"ext-xmlwriter": "*",
25-
"ext-simplexml": "*"
25+
"ext-simplexml": "*",
26+
"wp-coding-standards/wpcs": "~0.14.0"
27+
},
28+
"scripts": {
29+
"post-install-cmd": "phpcsx-init",
30+
"post-update-cmd": "phpcsx-init"
2631
},
2732
"bin": [
28-
"phpcsx"
33+
"bin/phpcsx-init"
2934
]
3035
}

phpcs/CodeSniffer/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php renamed to justcoded/JustcodedPSR2/Sniffs/Commenting/DocCommentSniff.php

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,15 @@
22
/**
33
* Ensures doc blocks follow basic formatting.
44
*
5-
* PHP version 5
6-
*
7-
* @category PHP
8-
* @package PHP_CodeSniffer
95
* @author Greg Sherwood <gsherwood@squiz.net>
10-
* @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
6+
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
117
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12-
* @link http://pear.php.net/package/PHP_CodeSniffer
138
*/
149

15-
/**
16-
* Ensures doc blocks follow basic formatting.
17-
*
18-
* @category PHP
19-
* @package PHP_CodeSniffer
20-
* @author Greg Sherwood <gsherwood@squiz.net>
21-
* @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
22-
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23-
* @version Release: @package_version@
24-
* @link http://pear.php.net/package/PHP_CodeSniffer
25-
*/
26-
class Generic_Sniffs_Commenting_DocCommentSniff implements PHP_CodeSniffer_Sniff
10+
use PHP_CodeSniffer\Sniffs\Sniff;
11+
use PHP_CodeSniffer\Files\File;
12+
13+
class JustcodedPSR2_Sniffs_Commenting_DocCommentSniff extends \PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\DocCommentSniff
2714
{
2815

2916
/**
@@ -50,15 +37,15 @@ public function register()
5037

5138

5239
/**
53-
* Processes this test, when one of its tokens is encountered.
5440
*
55-
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
56-
* @param int $stackPtr The position of the current token
57-
* in the stack passed in $tokens.
41+
*
42+
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
43+
* @param int $stackPtr The position of the current token
44+
* in the stack passed in $tokens.
5845
*
5946
* @return void
6047
*/
61-
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
48+
public function process(File $phpcsFile, $stackPtr)
6249
{
6350
$tokens = $phpcsFile->getTokens();
6451
$commentStart = $stackPtr;
@@ -119,8 +106,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
119106

120107
// Check for a comment description.
121108
if ($tokens[$short]['code'] !== T_DOC_COMMENT_STRING) {
122-
$error = 'Missing short description in doc comment';
123-
$phpcsFile->addError($error, $stackPtr, 'MissingShort');
109+
// @inheritdoc hotfix
110+
if (stripos($tokens[$short]['content'], '@inheritdoc') === false) {
111+
$error = 'Missing short description in doc comment';
112+
$phpcsFile->addError($error, $stackPtr, 'MissingShort');
113+
}
124114
return;
125115
}
126116

justcoded/JustcodedPSR2/ruleset.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,12 @@
1919
<!-- Covers rule: Use real tabs and not spaces. -->
2020
<arg name="tab-width" value="4"/>
2121
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
22-
22+
23+
<rule ref="WordPress-Docs">
24+
<exclude name="Squiz.Commenting.FileComment"/>
25+
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
26+
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType"/>
27+
<exclude name="Generic.Commenting.DocComment"/>
28+
</rule>
29+
<rule ref="JustcodedPSR2.Commenting.DocComment" />
2330
</ruleset>

justcoded/JustcodedWordpress/Sniffs/NamingConventions/ValidVariableNameSniff.php

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
* @license https://opensource.org/licenses/MIT MIT
88
*/
99

10-
if ( ! class_exists( 'WordPress_Sniffs_NamingConventions_ValidVariableNameSniff', true ) ) {
11-
throw new PHP_CodeSniffer_Exception( 'Class WordPress_Sniffs_NamingConventions_ValidVariableNameSniff not found' );
12-
}
13-
1410
/**
1511
* Checks the naming of variables and member variables.
1612
*
@@ -23,19 +19,27 @@
2319
* Last synced with base class July 2014 at commit ed257ca0e56ad86cd2a4d6fa38ce0b95141c824f.
2420
* @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php
2521
*/
26-
class JustcodedWordpress_Sniffs_NamingConventions_ValidVariableNameSniff extends WordPress_Sniffs_NamingConventions_ValidVariableNameSniff
22+
class JustcodedWordpress_Sniffs_NamingConventions_ValidVariableNameSniff extends \WordPress\Sniffs\NamingConventions\ValidVariableNameSniff
2723
{
2824

29-
/**
30-
* Custom list of variables which can have mixed case.
31-
*
32-
* @since 0.10.0
33-
*
34-
* @var string[]
35-
*/
36-
public $customPropertiesWhitelist = array(
37-
'SLUG',
38-
'TITLE',
39-
);
25+
/**
26+
* List of member variables that can have mixed case.
27+
*
28+
* @since 0.9.0
29+
* @since 0.11.0 Changed from public to protected.
30+
*
31+
* @var array
32+
*/
33+
protected $whitelisted_mixed_case_member_var_names = array(
34+
'ID' => true,
35+
'comment_ID' => true,
36+
'comment_post_ID' => true,
37+
'post_ID' => true,
38+
'comment_author_IP' => true,
39+
'cat_ID' => true,
40+
41+
'SLUG' => true,
42+
'TITLE' => true,
43+
);
4044

4145
}

justcoded/JustcodedWordpress/Sniffs/XSS/EscapeOutputSniff.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33
* WordPress Coding Standard, Justcoded edition.
44
*/
55

6-
if ( ! class_exists( 'WordPress_Sniffs_XSS_EscapeOutputSniff', true ) ) {
7-
throw new PHP_CodeSniffer_Exception( 'Class WordPress_Sniffs_XSS_EscapeOutputSniff not found' );
8-
}
9-
106
/**
117
* Verifies that all outputted strings are escaped.
128
*
139
* @link http://codex.wordpress.org/Data_Validation Data Validation on WordPress Codex
1410
*/
15-
class JustcodedWordpress_Sniffs_XSS_EscapeOutputSniff extends WordPress_Sniffs_XSS_EscapeOutputSniff {
11+
class JustcodedWordpress_Sniffs_XSS_EscapeOutputSniff extends \WordPress\Sniffs\XSS\EscapeOutputSniff {
1612

1713
/**
1814
* Custom list of functions which escape values for output.

phpcs/.gitattributes

Lines changed: 0 additions & 13 deletions
This file was deleted.

phpcs/.gitignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)