Skip to content

Plugin: Fix unused parameter phpcs sniffs in tests #8653

Open

Description

Part of #8436.

Description

Remove the VariableAnalysis.CodeAnalysis.VariableAnalysis exclude from phpcs.xml.dist and fix the issues reported when running npm run lint:php in the following files:

  • tests/unit/core/server/request/test-trait-order-info.php
  • tests/unit/core/server/request/test-class-core-cancel-intention-request.php
  • tests/unit/core/server/request/test-class-core-capture-intention-request.php
  • tests/unit/helpers/class-wc-mock-wc-data-store.php
  • tests/unit/core/server/request/test-class-core-get-intention-request.php
  • tests/unit/core/server/request/test-class-core-get-setup-intention-request.php
  • tests/unit/woopay/services/test-checkout-service.php
  • tests/unit/core/server/request/test-class-core-update-intention-request.php
  • tests/unit/subscriptions/test-class-wc-payments-subscription-service.php
  • tests/unit/woopay/test-class-woopay-session.php
  • tests/unit/helpers/class-wc-helper-product-add-ons-helper.php
  • tests/unit/subscriptions/test-class-wc-payments-subscriptions-event-handler.php
  • tests/unit/subscriptions/test-class-wc-payments-subscriptions-migrator.php
  • tests/unit/helpers/class-wc-helper-product.php
  • tests/unit/helpers/class-wc-helper-subscription.php
  • tests/unit/helpers/class-wc-helper-subscriptions-product.php
  • tests/unit/helpers/class-wc-helper-subscriptions-synchroniser.php
  • tests/unit/test-class-database-cache.php
  • tests/unit/multi-currency/test-class-multi-currency.php
  • tests/unit/test-class-payment-information.php
  • tests/unit/multi-currency/compatibility/test-class-woocommerce-subscriptions.php
  • tests/unit/src/Internal/Service/MinimumAmountServiceTest.php
  • tests/unit/test-class-wc-payment-gateway-wcpay-payment-types.php
  • tests/unit/admin/test-class-wc-rest-payments-orders-controller.php
  • tests/unit/multi-currency/test-class-analytics.php
  • tests/unit/admin/test-class-wc-rest-payments-readers-controller.php
  • tests/unit/subscriptions/test-class-wc-payments-invoice-service.php
  • tests/unit/test-class-wc-payment-gateway-wcpay-process-payment.php
  • tests/unit/subscriptions/test-class-wc-payments-subscription-change-payment-method.php
  • tests/unit/test-class-wc-payments-payment-request-button-handler.php
  • tests/unit/test-class-wc-payment-gateway-wcpay-process-refund.php
  • tests/unit/payment-methods/test-class-upe-split-payment-gateway.php
  • tests/unit/reports/test-class-wc-rest-payments-reports-authorizations-controller.php
  • tests/unit/test-class-wc-payment-gateway-wcpay-subscriptions-payment-method-order-note.php
  • tests/unit/test-class-wc-payments-utils.php
  • tests/unit/test-class-wc-payment-gateway-wcpay-subscriptions-process-payment.php
  • tests/unit/test-class-wc-payment-gateway-wcpay-subscriptions.php
  • tests/unit/test-class-wc-payment-gateway-wcpay.php
  • tests/unit/test-class-wc-payments-account.php
  • tests/unit/test-class-compatibility-service.php

Suggested fixes:

Note

We should consider just adding an exclude for the tests directory, but it may be worth it to keep the rule.

  • When a variable is truly unused, such as in filter functions where a parameter isn’t needed, prepend $_unused_ to the variable name. For example $order$_unused_order.
  • If a variable is not necessary, remove it.
  • When a parent class/interface doesn’t use a parameter but child classes do, use an inline // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    focus: architectureProduct architecture and engineering best practicespriority: lowThe issue/PR is low priority—not many people are affected or there’s a workaround, etc.type: technical debtThis issue/PR represents/solves the technical debt of the project.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions