Skip to content
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

Run PHPCS in CI #102

Open
wants to merge 5 commits into
base: 22-07/lower-version-requirement
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: PHPCS check
on:
push

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
phpcs:
name: PHPCS check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
ini-values: "memory_limit=1G"
coverage: none
tools: cs2pr

- name: Install Composer dependencies
uses: "ramsey/composer-install@v2"

- name: Run PHPCS checks
continue-on-error: true
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml

- name: Show PHPCS results in PR
run: cs2pr ./phpcs-report.xml
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![PHPCS](https://github.com/woocommerce/wc-smooth-generator/actions/workflows/phpcs.yml/badge.svg)](https://github.com/woocommerce/wc-smooth-generator/actions/workflows/phpcs.yml)

# WooCommerce Smooth Generator
A smooth products, customer and order generator using WP-CLI. Future versions will include scheduled auto generation functionality.

1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

2022-06-30 - version 1.0.5
* Fix - Lower version requirement from PHP 8.0.2 to PHP 7.1.
* Dev - Run PHPCS checks in CI.

2021-12-15 - version 1.0.4
* Add - coupon generator and a new option for orders to allow for coupon generation.
4 changes: 2 additions & 2 deletions includes/Admin/Settings.php
Original file line number Diff line number Diff line change
@@ -70,12 +70,12 @@ public static function process_page_submit() {
$num_to_generate = absint( $_POST['num_products_to_generate'] );
wc_smooth_generate_schedule( 'product', $num_to_generate );
add_action( 'admin_notices', array( __CLASS__, 'product_generating_notice' ) );
} else if ( ! empty( $_POST['generate_orders'] ) && ! empty( $_POST['num_orders_to_generate'] ) ) {
} elseif ( ! empty( $_POST['generate_orders'] ) && ! empty( $_POST['num_orders_to_generate'] ) ) {
check_admin_referer( 'generate', 'smoothgenerator_nonce' );
$num_to_generate = absint( $_POST['num_orders_to_generate'] );
wc_smooth_generate_schedule( 'order', $num_to_generate );
add_action( 'admin_notices', array( __CLASS__, 'order_generating_notice' ) );
} else if ( ! empty( $_POST['cancel_all_generations'] ) ) {
} elseif ( ! empty( $_POST['cancel_all_generations'] ) ) {
check_admin_referer( 'generate', 'smoothgenerator_nonce' );
wc_smooth_generate_cancel_all();
}
4 changes: 2 additions & 2 deletions includes/Generator/Product.php
Original file line number Diff line number Diff line change
@@ -126,8 +126,8 @@ protected static function create_global_attribute( $raw_name ) {
$taxonomy_name = wc_attribute_taxonomy_name( $slug );
register_taxonomy(
$taxonomy_name,
apply_filters( 'woocommerce_taxonomy_objects_' . $taxonomy_name, array( 'product' ) ),
apply_filters( 'woocommerce_taxonomy_args_' . $taxonomy_name, array(
apply_filters( 'woocommerce_taxonomy_objects_' . $taxonomy_name, array( 'product' ) ), // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
apply_filters( 'woocommerce_taxonomy_args_' . $taxonomy_name, array( // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
'labels' => array(
'name' => $raw_name,
),
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
<!-- Exclude paths -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>Gruntfile\.js</exclude-pattern>

<!-- Show progress, show the error codes for each message (source). -->
<arg value="ps"/>