-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update for WPCS 1.0 release #8
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="Prospress-WC"> | ||
<description>Prospress WooCommerce Coding Standards</description> | ||
|
||
<!-- Include the main Prospress standard --> | ||
<rule ref="Prospress"/> | ||
|
||
<!-- Modify the behavior of the checks for escaping functions --> | ||
<rule ref="WordPress.Security.EscapeOutput"> | ||
<!-- ignore wcs plain text email templates - strip_tags is run over the output amongst other things --> | ||
<exclude-pattern>*/templates/emails/plain/*</exclude-pattern> | ||
<properties> | ||
<!-- e.g. body_class, the_content, the_excerpt --> | ||
<property name="customAutoEscapedFunctions" type="array"> | ||
<element value="woocommerce_wp_select"/> | ||
<element value="wcs_help_tip"/> | ||
</property> | ||
<!-- e.g. esc_attr, esc_html, esc_url--> | ||
<property name="customEscapingFunctions" type="array"> | ||
<element value="wcs_json_encode"/> | ||
<element value="htmlspecialchars"/> | ||
<element value="wp_kses_allow_underscores"/> | ||
</property> | ||
</properties> | ||
</rule> | ||
</ruleset> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,105 +2,24 @@ | |
<ruleset name="Prospress"> | ||
<description>Prospress Coding Standards</description> | ||
|
||
<!-- http://make.wordpress.org/core/handbook/coding-standards/php/#brace-style --> | ||
<rule ref="Generic.ControlStructures.InlineControlStructure" /> | ||
<rule ref="Squiz.ControlStructures.ControlSignature" /> | ||
<rule ref="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"> | ||
<severity>0</severity> | ||
</rule> | ||
|
||
<!-- http://make.wordpress.org/core/handbook/coding-standards/php/#remove-trailing-spaces --> | ||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/> | ||
|
||
<!-- http://make.wordpress.org/core/handbook/coding-standards/php/#no-shorthand-php-tags --> | ||
<rule ref="Generic.PHP.DisallowShortOpenTag"/> | ||
|
||
<!-- important to prevent issues with content being sent before headers --> | ||
<rule ref="Generic.Files.ByteOrderMark"/> | ||
|
||
<!-- http://make.wordpress.org/core/handbook/coding-standards/php/#naming-conventions --> | ||
<rule ref="Generic.PHP.LowerCaseConstant"/> | ||
|
||
<!-- http://make.wordpress.org/core/handbook/coding-standards/php/#indentation --> | ||
<arg name="tab-width" value="4"/> | ||
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/> | ||
<rule ref="Generic.WhiteSpace.ScopeIndent"> | ||
<properties> | ||
<property name="indent" value="4"/> | ||
<property name="tabIndent" value="true"/> | ||
<property name="ignoreIndentationTokens" type="array" value="T_COMMENT"/> | ||
</properties> | ||
</rule> | ||
|
||
<!-- http://make.wordpress.org/core/handbook/coding-standards/php/#error-control-operator --> | ||
<rule ref="Generic.PHP.NoSilencedErrors" /> | ||
|
||
<rule ref="Squiz.Strings.DoubleQuoteUsage"/> | ||
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar"> | ||
<severity>0</severity> | ||
</rule> | ||
|
||
<rule ref="Generic.PHP.LowerCaseKeyword"/> | ||
|
||
<rule ref="Generic.Files.LineEndings"> | ||
<properties> | ||
<property name="eolChar" value="\n"/> | ||
</properties> | ||
</rule> | ||
|
||
<rule ref="Generic.Files.EndFileNewline"/> | ||
<!-- Import the main WordPress rules --> | ||
<rule ref="WordPress-Core"/> | ||
|
||
<!-- https://make.wordpress.org/core/handbook/coding-standards/php/#naming-conventions --> | ||
<rule ref="Generic.Files.LowercasedFilename"/> | ||
|
||
<!-- https://make.wordpress.org/core/handbook/coding-standards/php/#space-usage --> | ||
<rule ref="Generic.Formatting.SpaceAfterCast"/> | ||
|
||
<!-- https://make.wordpress.org/core/handbook/coding-standards/php/#brace-style --> | ||
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/> | ||
|
||
<rule ref="PEAR.Functions.FunctionCallSignature"> | ||
<properties> | ||
<property name="requiredSpacesAfterOpen" value="1" /> | ||
<property name="requiredSpacesBeforeClose" value="1" /> | ||
</properties> | ||
</rule> | ||
<rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"> | ||
<severity>0</severity> | ||
</rule> | ||
<rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine"> | ||
<severity>0</severity> | ||
</rule> | ||
<!-- Selectively import other WordPress rules --> | ||
<rule ref="WordPress.PHP.DiscouragedFunctions"/> | ||
<rule ref="WordPress.Security.NonceVerification"/> | ||
<rule ref="WordPress.WP.EnqueuedResources"/> | ||
<rule ref="WordPress.Variables.GlobalVariables"/> | ||
|
||
<rule ref="WordPress.Arrays.ArrayDeclaration"> | ||
<exclude name="WordPress.Arrays.ArrayDeclaration.SingleLineNotAllowed" /> | ||
<!-- Don't check the number of new lines after control structures --> | ||
<rule ref="Squiz.ControlStructures.ControlSignature"> | ||
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/> | ||
</rule> | ||
<rule ref="WordPress.Arrays.ArrayKeySpacingRestrictions"/> | ||
<rule ref="WordPress.Classes.ValidClassName"/> | ||
<rule ref="WordPress.Files.FileName"/> | ||
<rule ref="WordPress.Functions.FunctionDeclarationArgumentSpacing"/> | ||
<rule ref="WordPress.NamingConventions.ValidFunctionName"/> | ||
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing"/> | ||
<rule ref="WordPress.WhiteSpace.OperatorSpacing"/> | ||
<rule ref="WordPress.WhiteSpace.CastStructureSpacing"/> | ||
<rule ref="WordPress.PHP.YodaConditions"/> | ||
|
||
<rule ref="WordPress.XSS.EscapeOutput"> | ||
<!-- ignore wcs plain text email templates - strip_tags is run over the output amongst other things --> | ||
<exclude-pattern>*/templates/emails/plain/*</exclude-pattern> | ||
<!-- Don't require class files to start with "class-" --> | ||
<rule ref="WordPress.Files.FileName"> | ||
<properties> | ||
<!-- e.g. body_class, the_content, the_excerpt --> | ||
<property name="customAutoEscapedFunctions" type="array" value="0=>woocommerce_wp_select,1=>wcs_help_tip"/> | ||
<!-- e.g. esc_attr, esc_html, esc_url--> | ||
<property name="customEscapingFunctions" type="array" value="0=>wcs_json_encode,1=>htmlspecialchars,2=>wp_kses_allow_underscores"/> | ||
<!-- e.g. _deprecated_argument, printf, _e--> | ||
<property name="customPrintingFunctions" type="array" value=""/> | ||
<property name="strict_class_file_names" value="false"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ As far as I have observed in WCS code, I see class file names starting with "class-". Any reason why this has not been enforced strictly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not all of our libraries use the |
||
</properties> | ||
</rule> | ||
|
||
<rule ref="WordPress.CSRF.NonceVerification" /> | ||
<rule ref="WordPress.PHP.DiscouragedFunctions"/> | ||
<rule ref="WordPress.WP.EnqueuedResources"/> | ||
<rule ref="WordPress.Variables.GlobalVariables"/> | ||
|
||
</ruleset> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "prospress/prospress-coding-standards", | ||
"description": "Coding standards for Prospress plugins.", | ||
"type": "phpcodesniffer-standard", | ||
"require-dev": { | ||
"dealerdirect/phpcodesniffer-composer-installer": "^0.4", | ||
"wp-coding-standards/wpcs": "^1.0" | ||
}, | ||
"license": "MIT" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ Any particular reason why
Generic.Files.LowercasedFilename
is not imported?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all of our libraries (mainly Action Scheduler) use lowercase file names. Also, in my opinion, that's not one that we necessarily need to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you're also asking why I didn't keep it when it used to be part of the ruleset? The reason for that is that it appeared to be superseded by the
WordPress.Files.FileName
rule.