Skip to content

Commit

Permalink
Merge pull request #12 from ernilambar/quality
Browse files Browse the repository at this point in the history
Code quality
  • Loading branch information
ernilambar authored Jan 13, 2024
2 parents 258957e + 60d7cbb commit aec71e0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Code Quality Checks

on:
pull_request:
push:
branches:
- main
- master

jobs:
code-quality:
uses: wp-cli/.github/.github/workflows/reusable-code-quality.yml@main
15 changes: 15 additions & 0 deletions .github/workflows/regenerate-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Regenerate README file

on:
workflow_dispatch:
push:
branches:
- main
- master
paths-ignore:
- "features/**"
- "README.md"

jobs:
regenerate-readme:
uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main
2 changes: 1 addition & 1 deletion features/database-command-basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: Basic tests
Then STDERR should contain:
"""
Error: Parameter errors:
missing --author parameter (Administrator user you want to keep after reset)
missing --author parameter (Administrator user you want to keep after reset.)
"""

Scenario: Test author parameter is passed but non-existent user
Expand Down
9 changes: 9 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@
<!-- Rules: Include the base ruleset for WP-CLI projects. -->
<rule ref="WP_CLI_CS"/>

<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="Nilambar\WP_CLI_Database"/><!-- Namespaces. -->
<element value="wpcli_database_command"/><!-- Global variables and such. -->
</property>
</properties>
</rule>

</ruleset>
10 changes: 5 additions & 5 deletions src/DatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class DatabaseCommand extends WP_CLI_Command {
* ## OPTIONS
*
* --author=<username>
* : Administrator user you want to keep after reset
* : Administrator user you want to keep after reset.
*
* ## EXAMPLES
*
* # Reset database and keep `admin` user
* # Reset database and keep `admin` user.
* $ wp database reset --author=admin
*
* @when after_wp_load
Expand Down Expand Up @@ -62,7 +62,7 @@ public function reset( $args, $assoc_args ) {
private function reset_callback( $user ) {
WP_CLI::log( 'Resetting...' );

// We dont want email notification.
// We don't want email notification.
if ( ! function_exists( 'wp_new_blog_notification' ) ) {
function wp_new_blog_notification() {
// Silence is golden.
Expand All @@ -79,10 +79,10 @@ function wp_new_blog_notification() {

$prefix = str_replace( '_', '\_', $wpdb->prefix );

$tables = $wpdb->get_col( "SHOW TABLES LIKE '{$prefix}%'" );
$tables = $wpdb->get_col( "SHOW TABLES LIKE '{$prefix}%'" ); // phpcs:ignore WordPress.DB.PreparedSQL

foreach ( $tables as $table ) {
$wpdb->query( "DROP TABLE $table" );
$wpdb->query( "DROP TABLE $table" ); // phpcs:ignore WordPress.DB.PreparedSQL
}

// Set site URL.
Expand Down

0 comments on commit aec71e0

Please sign in to comment.