Changelogger: Fix PHPCS violations (#33664)

This commit is contained in:
Paul Sealock 2022-07-07 08:54:48 +12:00 committed by GitHub
parent 0cebdf5277
commit 7229b65bc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 155 additions and 39 deletions

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -15,7 +15,7 @@
"extra": {
"changelogger": {
"formatter": {
"filename": "../../../tools/changelogger/PackageFormatter.php"
"filename": "../../../tools/changelogger/class-package-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -36,7 +36,7 @@
},
"changelogger": {
"formatter": {
"filename": "../../tools/changelogger/PluginFormatter.php"
"filename": "../../tools/changelogger/class-plugin-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS violation fixes

View File

@ -126,7 +126,7 @@
},
"changelogger": {
"formatter": {
"filename": "../../tools/changelogger/LegacyCoreFormatter.php"
"filename": "../../tools/changelogger/class-legacy-core-formatter.php"
},
"types": {
"fix": "Fixes an existing bug",

View File

@ -1,4 +1,9 @@
<?php
/**
* Formatter class
*
* @package WooCommerce
*/
namespace Automattic\WooCommerce\MonorepoTools\Changelogger;
@ -89,16 +94,16 @@ class Formatter extends KeepAChangelogParser {
$release_url = '';
if ( strpos( $path[1], 'packages/js/' ) !== false ) {
$package = substr( $path[1], 12 );
$release_url ='https://www.npmjs.com/package/@woocommerce/' . $package . '/v/';
} else if ( 'plugins/woocommerce' === $path[1] ) {
$package = substr( $path[1], 12 );
$release_url = 'https://www.npmjs.com/package/@woocommerce/' . $package . '/v/';
} elseif ( 'plugins/woocommerce' === $path[1] ) {
$release_url = 'https://github.com/woocommerce/woocommerce/releases/tag/';
} else if ( 'plugins/woocommerce-beta-tester' === $path[1] ) {
} elseif ( 'plugins/woocommerce-beta-tester' === $path[1] ) {
$release_url = 'https://github.com/woocommerce/woocommerce/releases/tag/';
} else {
throw new \InvalidArgumentException( 'Release URL not found.' );
}
return $release_url . $version;
}
@ -197,13 +202,13 @@ class Formatter extends KeepAChangelogParser {
$row = preg_replace( '/' . $this->bullet . '/', '', $row, 1 );
$row_segments = explode( ' - ', $row );
$significance = trim( strtolower( $row_segments[0] ) );
array_push(
$changes,
array(
'subheading' => $is_subentry ? '' : trim( $row_segments[0] ),
'content' => $is_subentry ? trim( $row ) : trim( isset($row_segments[1]) ? $row_segments[1] : '' ),
'significance' => in_array( $significance, array( 'patch', 'minor', 'major' ) ) ? $significance : null,
'content' => $is_subentry ? trim( $row ) : trim( isset( $row_segments[1] ) ? $row_segments[1] : '' ),
'significance' => in_array( $significance, array( 'patch', 'minor', 'major' ), true ) ? $significance : null,
)
);
}

View File

@ -1,4 +1,9 @@
<?php
/**
* Legacy_Core_Formatter class
*
* @package WooCommerce
*/
namespace Automattic\WooCommerce\MonorepoTools\Changelogger;
@ -9,14 +14,14 @@ use Automattic\Jetpack\Changelogger\FormatterPlugin;
* Jetpack Changelogger Formatter for WooCommerce plugins
*/
require_once 'Formatter.php';
require_once 'class-formatter.php';
/**
* Jetpack Changelogger Formatter for Legacy Core Changelog
*
* Class Formatter
*/
class LegacyCoreFormatter extends Formatter implements FormatterPlugin {
class Legacy_Core_Formatter extends Formatter implements FormatterPlugin {
/**
* Bullet for changes.
@ -35,13 +40,14 @@ class LegacyCoreFormatter extends Formatter implements FormatterPlugin {
/**
* Returns an mapping the subheading to the type key.
*
*
* @return array
*/
private function getSubheadingTypeMapping() {
$woocommerce_path = dirname( dirname( __DIR__ ) ) . '/plugins/woocommerce';
$composer_file = $woocommerce_path . '/composer.json';
$composer_config = json_decode( file_get_contents( $composer_file ), true );
// phpcs:disable WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$composer_config = json_decode( file_get_contents( $composer_file ), true );
return array_flip( $composer_config['extra']['changelogger']['types'] );
}
@ -59,8 +65,8 @@ class LegacyCoreFormatter extends Formatter implements FormatterPlugin {
foreach ( $changelog->getEntries() as $entry ) {
$version = $entry->getVersion();
if ( substr_count( $version, '.' ) == 1 ) {
$version .= '.0';
if ( substr_count( $version, '.' ) === 1 ) {
$version .= '.0';
}
$ret .= "= $version YYYY-mm-dd =\n\n";

View File

@ -1,4 +1,9 @@
<?php
/**
* Package_Formatter class
*
* @package WooCommerce
*/
namespace Automattic\WooCommerce\MonorepoTools\Changelogger;
@ -8,14 +13,14 @@ use Automattic\Jetpack\Changelogger\FormatterPlugin;
* Jetpack Changelogger Formatter for WooCommerce packages
*/
require_once 'Formatter.php';
require_once 'class-formatter.php';
/**
* Jetpack Changelogger Formatter for WooCommerce Packages
*
* Class Formatter
*/
class PackageFormatter extends Formatter implements FormatterPlugin {
class Package_Formatter extends Formatter implements FormatterPlugin {
/**
* Prologue text.
*
@ -27,8 +32,8 @@ class PackageFormatter extends Formatter implements FormatterPlugin {
* Return the epilogue string based on the package being released.
*/
public function getEpilogue() {
$cwd = getcwd();
$pos = stripos( $cwd, 'packages/js/' );
$cwd = getcwd();
$pos = stripos( $cwd, 'packages/js/' );
$package = substr( $cwd, $pos + 12 );
return '[See legacy changelogs for previous versions](https://github.com/woocommerce/woocommerce/blob/68581955106947918d2b17607a01bdfdf22288a9/packages/js/' . $package . '/CHANGELOG.md).';

View File

@ -1,4 +1,9 @@
<?php
/**
* Plugin_Formatter class
*
* @package WooCommerce
*/
namespace Automattic\WooCommerce\MonorepoTools\Changelogger;
@ -8,14 +13,14 @@ use Automattic\Jetpack\Changelogger\FormatterPlugin;
* Jetpack Changelogger Formatter for WooCommerce plugins
*/
require_once 'Formatter.php';
require_once 'class-formatter.php';
/**
* Jetpack Changelogger Formatter for WooCommerce Plugins
*
* Class Formatter
*/
class PluginFormatter extends Formatter implements FormatterPlugin {
class Plugin_Formatter extends Formatter implements FormatterPlugin {
/**
* Epilogue text.
*