Repository: WordPress/WordPress-Coding-Standards (php)

Issue:
Change WordPress.WP.EnqueuedResourceParameters.MissingVersion to warning
`EnqueuedResourceParameters` is [included](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/206b30cd1051f36199f139bb11664bb1b75026e4/WordPress-Extra/ruleset.xml#L145) in `WordPress-Extra`.

It was recently added via #1378.

While I agree that it's a best practice to add a script version (WP will use its own version anyway if not given), I think we should reconsider this being reported as an _error_. 

Example case, would be registering a script from a CDN e.g. `https://cdn.bootcss.com/backgrid.js/0.3.8/backgrid.min.js` - this already contains the version number, so having to add a version number as a separate argument doesn't make sense.

The arg is optional - if it was something that someone _must_ do (for which not doing would be an error), then it wouldn't be optional.

I realise this is for Extra, not Core, and that there are ways for individual projects to ignore, disable or change the type for this violation, but I'd like to see us re-consider changing it in WPCS.

Pull request description:
WP/EnqueuedResourceParameters: change `MissingVersion` to a warning
Fixes #1472

Includes updated unit tests.

Patch:
diff --git a/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php b/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php
index 3bed8105..e5b0dd1d 100644
--- a/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php
+++ b/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php
@@ -134,8 +134,8 @@ class EnqueuedResourceParametersSniff extends AbstractFunctionParameterSniff {
 				$type = 'style';
 			}
 
-			$this->phpcsFile->addError(
-				'Resource version not set in call to %s(). This means new versions of the %s will not always be loaded due to browser caching.',
+			$this->phpcsFile->addWarning(
+				'Resource version not set in call to %s(). This means new versions of the %s may not always be loaded due to browser caching.',
 				$stackPtr,
 				'MissingVersion',
 				array( $matched_content, $type )


Test patch:
diff --git a/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc b/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc
index 6e5cd7e3..098d40de 100644
--- a/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc
+++ b/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc
@@ -1,6 +1,6 @@
 <?php
 
-wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ) ); // Error - missing $ver, Warning - In Footer is set to a falsy (default) value.
+wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ) ); // Warning - missing $ver, Warning - In Footer is set to a falsy (default) value.
 
 wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), /* comment */ '1.1.1', true ); // OK.
 wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), /* comment */ '0' /* another comment */, true ); // Error - 0, false or NULL are not allowed.
@@ -36,13 +36,13 @@ wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array
 wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), '1.1.0', $in_footer ); // OK.
 
 wp_enqueue_script( 'script-name', 'https://example.com/someScript.js', false, '1.0.0', true ); // OK.
-wp_enqueue_script( 'script-name', 'https://example.com/someScript.js' ); // Error - missing $ver, Warning - missing $in_footer.
+wp_enqueue_script( 'script-name', 'https://example.com/someScript.js' ); // Warning - missing $ver, Warning - missing $in_footer.
 
 wp_register_style( 'script-name', 'https://example.com/someScript.js', false, '1.0.0' ); // OK.
-wp_register_style( 'script-name', 'https://example.com/someScript.js' ); // Error - missing $ver.
+wp_register_style( 'script-name', 'https://example.com/someScript.js' ); // Warning - missing $ver.
 
 wp_enqueue_style( 'script-name', 'https://example.com/someScript.js', false, '1.0.0'); // OK.
-wp_enqueue_style( 'script-name', 'https://example.com/someScript.js' ); // Error - missing $ver.
+wp_enqueue_style( 'script-name', 'https://example.com/someScript.js' ); // Warning - missing $ver.
 
 wp_register_script( 'someScript-js' ); // OK.
 wp_enqueue_script( 'someScript-js' ); // OK.
diff --git a/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php b/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php
index 5fa96cd2..b916b68b 100644
--- a/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php
+++ b/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php
@@ -27,18 +27,13 @@ class EnqueuedResourceParametersUnitTest extends AbstractSniffUnitTest {
 	 */
 	public function getErrorList() {
 		return array(
-			3  => 1,
 			6  => 1,
 			9  => 1,
 			10 => 1,
-			11 => 1,
 			12 => 1,
 			13 => 1,
 			14 => 1,
 			22 => 1,
-			39 => 1,
-			42 => 1,
-			45 => 1,
 			54 => 1,
 			57 => 1,
 		);
@@ -51,9 +46,12 @@ class EnqueuedResourceParametersUnitTest extends AbstractSniffUnitTest {
 	 */
 	public function getWarningList() {
 		return array(
-			3  => 1,
+			3  => 2,
+			11 => 1,
 			32 => 1,
-			39 => 1,
+			39 => 2,
+			42 => 1,
+			45 => 1,
 		);
 	}