72% woocommerce-shipping-gateway-per-product

Code Review | WooCommerce Shipping gateway per Product

WordPress plugin WooCommerce Shipping gateway per Product scored72%from 54 tests.

About plugin

  • Plugin page: woocommerce-shipp...
  • Plugin version: 2.3.5
  • PHP compatiblity: 7.4+
  • PHP version: 7.4.16
  • WordPress compatibility: 6.0-6.3
  • WordPress version: 6.3.1
  • First release: Sep 11, 2013
  • Latest release: Oct 3, 2023
  • Number of updates: 73
  • Update frequency: every 50.4 days
  • Top authors: dreamfox (100%)

Code review

54 tests

User reviews

10 reviews

Install metrics

200+ active /52,689 total downloads

Benchmarks

Plugin footprint 65% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | All plugins must install correctly, without throwing any errors, warnings, or notices
This plugin's installer ran successfully

Server metrics [RAM: ▲5.05MB] [CPU: ▲23.65ms] 75% from 4 tests

This is a short check of server-side resources used by WooCommerce Shipping gateway per Product
The following require your attention
  • Extra RAM: The extra memory usage must be under 5MB (currently 5.05MB on /wp-admin/admin.php?page=freemius)
PageMemory (MB)CPU Time (ms)
Home /8.94 ▲5.4864.98 ▲20.27
Dashboard /wp-admin8.96 ▲5.6676.46 ▲25.86
Posts /wp-admin/edit.php8.96 ▲5.6174.71 ▲30.24
Add New Post /wp-admin/post-new.php9.34 ▲3.46111.42 ▲18.23
Media Library /wp-admin/upload.php8.96 ▲5.7469.06 ▲33.99
Freemius Debug [v.2.5.12] /wp-admin/admin.php?page=freemius8.9671.55

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

A short overview of filesystem and database impact
No storage issues were detected
Filesystem: 191 new files
Database: no new tables, 9 new options
New WordPress options
fs_debug_mode
can_compress_scripts
db_upgraded
theysaidso_admin_options
fs_accounts
widget_theysaidso_widget
widget_recent-posts
widget_recent-comments
fs_active_plugins

Browser metrics Passed 4 tests

Checking browser requirements for WooCommerce Shipping gateway per Product
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,818 ▲7213.65 ▼0.721.71 ▼0.1833.14 ▼11.28
Dashboard /wp-admin2,218 ▲265.80 ▲0.82138.75 ▲18.5648.32 ▲3.39
Posts /wp-admin/edit.php2,109 ▲202.03 ▲0.0441.53 ▲2.4539.15 ▲6.48
Add New Post /wp-admin/post-new.php1,518 ▼123.14 ▼0.25650.74 ▼35.8749.80 ▼3.43
Media Library /wp-admin/upload.php1,406 ▲154.25 ▲0.1096.41 ▲2.0043.53 ▲0.36
Freemius Debug [v.2.5.12] /wp-admin/admin.php?page=freemius1,0682.0526.9028.58

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

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
It is recommended to fix the following
  • The plugin did not uninstall gracefully
    • > Notice in wp-content/plugins/woocommerce-shipping-gateway-per-product/freemius/includes/class-freemius.php+8515
    Undefined property: stdClass::$plugins
  • Zombie WordPress options detected upon uninstall: 9 options
    • fs_active_plugins
    • can_compress_scripts
    • widget_recent-posts
    • db_upgraded
    • widget_recent-comments
    • widget_theysaidso_widget
    • theysaidso_admin_options
    • fs_debug_mode
    • fs_accounts

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | This is a short smoke test looking for server-side errors
Even though no errors were found, this is by no means an exhaustive test

SRP 50% from 2 tests

🔹 Tests weight: 20 | SRP (Single-Responsibility Principle) - PHP files must act as libraries and never output text or perform any action when accessed directly in a browser
The following issues need your attention
  • 1× PHP files trigger server-side errors or warnings when accessed directly:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/woocommerce-shipping-gateway-per-product/inc/quick_bulk_edit_patch.php:5

User-side errors Passed 1 test

🔹 Test weight: 20 | This is just a short smoke test looking for browser issues
No browser issues were found

Optimizations

Plugin configuration 83% from 29 tests

readme.txt 88% from 16 tests

Don't ignore readme.txt as it is the file that instructs WordPress.org on how to present your plugin to the world
Attributes that need to be fixed:
  • Screenshots: These screenshots require images: #2 (screenshot2.png), #3 (screenshot3.png)
  • Tags: There are too many tags (14 tag instead of maximum 10)
You can take inspiration from this readme.txt

woocommerce-shipping-gateway-per-product/woocommerce-product-shippings.php 77% from 13 tests

Analyzing the main PHP file in "WooCommerce Shipping gateway per Product" version 2.3.5
Please make the necessary changes and fix the following:
  • Domain Path: The domain path folder does not exist ("/languages")
  • Main file name: Even though not officially enforced, the main plugin file should be the same as the plugin slug ("woocommerce-shipping-gateway-per-product.php" instead of "woocommerce-product-shippings.php")
  • Text Domain: The text domain must be the same as the plugin slug, although optional since WordPress version 4.6

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short check of programming languages and file extensions; no executable files are allowed
No dangerous file extensions were detected34,186 lines of code in 140 files:
LanguageFilesBlank linesComment linesLines of code
PHP1198,04817,31733,816
JavaScript54560240
CSS15241114
XML13016

PHP code 50% from 2 tests

A short review of cyclomatic complexity and code structure
It is recommended to fix the following
  • Class cyclomatic complexity has to be reduced to less than 1000 (currently 3,088)
Cyclomatic complexity
Average complexity per logical line of code0.63
Average class complexity93.38
▷ Minimum class complexity1.00
▷ Maximum class complexity3,088.00
Average method complexity4.60
▷ Minimum method complexity1.00
▷ Maximum method complexity94.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes48
▷ Abstract classes24.17%
▷ Concrete classes4695.83%
▷ Final classes00.00%
Methods1,259
▷ Static methods19815.73%
▷ Public methods86969.02%
▷ Protected methods171.35%
▷ Private methods37329.63%
Functions122
▷ Named functions12098.36%
▷ Anonymous functions21.64%
Constants147
▷ Global constants10068.03%
▷ Class constants4731.97%
▷ Public constants47100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
7 PNG files occupy 0.05MB with 0.01MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
img/close-icon.png1.09KB1.00KB▼ 7.55%
img/cross-flat.png2.93KB3.18KB0.00%
img/attention.png21.31KB8.70KB▼ 59.18%
img/help.png0.30KB0.32KB0.00%
freemius/assets/img/theme-icon.png10.97KB5.78KB▼ 47.37%