84% wc-m-pesa-payment-gateway

Code Review | Payment Gateway - Mpesa for WooCommerce

WordPress plugin Payment Gateway - Mpesa for WooCommerce scored84%from 54 tests.

About plugin

  • Plugin page: wc-m-pesa-payment...
  • Plugin version: 1.4.1
  • PHP compatiblity: 7.1+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.0.0-6.3
  • WordPress version: 6.3.1
  • First release: May 7, 2020
  • Latest release: Sep 26, 2023
  • Number of updates: 41
  • Update frequency: every 30.2 days
  • Top authors: karson9 (100%)

Code review

54 tests

User reviews

6 reviews

Install metrics

300+ active /6,569 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
This plugin's installer ran successfully

Server metrics [RAM: ▲0.24MB] [CPU: ▼0.49ms] Passed 4 tests

A check of server-side resources used by Payment Gateway - Mpesa for WooCommerce
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /3.69 ▲0.2239.94 ▼3.24
Dashboard /wp-admin3.59 ▲0.2852.91 ▼1.19
Posts /wp-admin/edit.php3.64 ▲0.2853.00 ▲1.83
Add New Post /wp-admin/post-new.php6.11 ▲0.22101.23 ▲0.63
Media Library /wp-admin/upload.php3.45 ▲0.2244.51 ▲6.82

Server storage [IO: ▲1.91MB] [DB: ▲0.00MB] Passed 3 tests

Filesystem and database footprint
This plugin was installed successfully
Filesystem: 179 new files
Database: no new tables, 7 new options
New WordPress options
wc_mpesa_version
widget_recent-comments
db_upgraded
can_compress_scripts
widget_theysaidso_widget
widget_recent-posts
theysaidso_admin_options

Browser metrics Passed 4 tests

Checking browser requirements for Payment Gateway - Mpesa for WooCommerce
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,789 ▲314.40 ▼0.231.71 ▼0.3057.42 ▲12.10
Dashboard /wp-admin2,195 ▲155.65 ▼0.0290.70 ▲2.6943.14 ▼4.78
Posts /wp-admin/edit.php2,100 ▼02.01 ▼0.0040.67 ▲1.3238.20 ▼1.29
Add New Post /wp-admin/post-new.php1,532 ▼1322.86 ▼0.15635.27 ▲21.0160.75 ▲4.12
Media Library /wp-admin/upload.php1,400 ▼04.23 ▲0.0197.39 ▼12.6944.80 ▲0.42

Uninstaller [IO: ▲0.00MB] [DB: ▲0.00MB] 75% from 4 tests

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
It is recommended to fix the following
  • The uninstall procedure has failed, leaving 7 options in the database
    • widget_recent-comments
    • can_compress_scripts
    • widget_theysaidso_widget
    • theysaidso_admin_options
    • wc_mpesa_version
    • db_upgraded
    • widget_recent-posts

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no server-side errors were triggered
Even though no errors were found, this is by no means an exhaustive test

SRP 50% from 2 tests

🔹 Tests weight: 20 | A shallow check of the single-responsibility principle; PHP files should perform no action - including output of placeholder text - and trigger no errors when accessed directly
The following issues need your attention
  • 51× PHP files trigger server errors when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'GuzzleHttp\\Exception\\BadResponseException' not found in wp-content/plugins/wc-m-pesa-payment-gateway/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php:8
    • > PHP Fatal error
      Uncaught Error: Interface 'Psr\\Http\\Message\\StreamInterface' not found in wp-content/plugins/wc-m-pesa-payment-gateway/vendor/guzzlehttp/psr7/src/DroppingStream.php:13
    • > PHP Fatal error
      Uncaught Error: Interface 'GuzzleHttp\\BodySummarizerInterface' not found in wp-content/plugins/wc-m-pesa-payment-gateway/vendor/guzzlehttp/guzzle/src/BodySummarizer.php:7
    • > PHP Fatal error
      Uncaught Error: Interface 'Psr\\Http\\Message\\ResponseInterface' not found in wp-content/plugins/wc-m-pesa-payment-gateway/vendor/guzzlehttp/psr7/src/Response.php:13
    • > PHP Fatal error
      Uncaught Error: Class 'GuzzleHttp\\Promise\\RejectionException' not found in wp-content/plugins/wc-m-pesa-payment-gateway/vendor/guzzlehttp/promises/src/CancellationException.php:8
    • > PHP Fatal error
      Uncaught Error: Interface 'GuzzleHttp\\ClientInterface' not found in wp-content/plugins/wc-m-pesa-payment-gateway/vendor/guzzlehttp/guzzle/src/Client.php:17
    • > PHP Fatal error
      Uncaught Error: Interface 'GuzzleHttp\\Promise\\PromisorInterface' not found in wp-content/plugins/wc-m-pesa-payment-gateway/vendor/guzzlehttp/promises/src/EachPromise.php:9
    • > PHP Fatal error
      Uncaught Error: Interface 'Psr\\Http\\Message\\UriInterface' not found in wp-content/plugins/wc-m-pesa-payment-gateway/vendor/guzzlehttp/psr7/src/Uri.php:17
    • > PHP Fatal error
      Uncaught Error: Interface 'Psr\\Http\\Message\\MessageInterface' not found in wp-content/plugins/wc-m-pesa-payment-gateway/vendor/psr/http-message/src/ResponseInterface.php:20
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/wc-m-pesa-payment-gateway/wc-mpesa-payment-gateway.php:21

User-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the browser (console and network errors and warnings)
No browser errors were detected

Optimizations

Plugin configuration 93% from 29 tests

readme.txt Passed 16 tests

The readme.txt file is important because it is parsed by WordPress.org for the public listing of your plugin
5 plugin tags: vodacom, woocommerce, mpesa api mozambique, payment gateway, mpesa

wc-m-pesa-payment-gateway/wc-mpesa-payment-gateway.php 85% from 13 tests

"Payment Gateway - Mpesa for WooCommerce" version 1.4.1's primary PHP file adds more information about the plugin and serves as the entry point for WordPress
Please make the necessary changes and fix the following:
  • Requires at least: Required version must be the same as the one declared in readme.txt ("5.0" instead of "4.0.0")
  • Main file name: The principal plugin file should be the same as the plugin slug ("wc-m-pesa-payment-gateway.php" instead of "wc-mpesa-payment-gateway.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | Executable files are not allowed as they can serve as attack vectors
Good job! No executable or dangerous file extensions detected16,180 lines of code in 162 files:
LanguageFilesBlank linesComment linesLines of code
PHP1242,1565,95710,855
Markdown201,33503,811
JSON10101,165
PO File3100103282
CSS113347
YAML21010
make1409
JavaScript1001

PHP code Passed 2 tests

Cyclomatic complexity and code structure are the fingerprint of this plugin
There were no cyclomatic complexity issued detected
Cyclomatic complexity
Average complexity per logical line of code0.45
Average class complexity13.43
▷ Minimum class complexity1.00
▷ Maximum class complexity88.00
Average method complexity2.81
▷ Minimum method complexity1.00
▷ Maximum method complexity34.00
Code structure
Namespaces13
Interfaces26
Traits3
Classes81
▷ Abstract classes00.00%
▷ Concrete classes81100.00%
▷ Final classes3543.21%
Methods776
▷ Static methods14518.69%
▷ Public methods65684.54%
▷ Protected methods40.52%
▷ Private methods11614.95%
Functions129
▷ Named functions3627.91%
▷ Anonymous functions9372.09%
Constants63
▷ Global constants00.00%
▷ Class constants63100.00%
▷ Public constants5282.54%

Plugin size Passed 2 tests

Image compression Passed 2 tests

All PNG images should be compressed to minimize bandwidth usage for end users
1 PNG file occupies 0.00MB with 0.00MB in potential savings
Potential savings
Compression of 1 random PNG file using pngquant
FileSize - originalSize - compressedSavings
assets/img/m-pesa-logo.png4.22KB2.77KB▼ 34.40%