62% woo-coupon-usage

Code Review | WooCommerce Affiliate Plugin - Coupon Affiliates

WordPress plugin WooCommerce Affiliate Plugin - Coupon Affiliates scored62%from 54 tests.

About plugin

  • Plugin page: woo-coupon-usage
  • Plugin version: 5.11.2
  • PHP version: 7.4.16
  • WordPress compatibility: 3.7-6.4.1
  • WordPress version: 6.3.1
  • First release: Aug 18, 2015
  • Latest release: Nov 28, 2023
  • Number of updates: 480
  • Update frequency: every 6.3 days
  • Top authors: Elliotvs (100%)

Code review

54 tests

User reviews

63 reviews

Install metrics

4,000+ active /154,332 total downloads

Benchmarks

Plugin footprint 46% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
The plugin installed gracefully, with no errors

Server metrics [RAM: ▲6.99MB] [CPU: ▲37.90ms] 25% from 4 tests

Analyzing server-side resources used by WooCommerce Affiliate Plugin - Coupon Affiliates
Please take the time to fix the following items
  • RAM: Try to keep total memory usage under 10MB (currently 10.53MB on /wp-admin/admin.php?page=wcusage_setup)
  • CPU: Total CPU usage should be kept under 500.00ms (currently 2,808.58ms on /wp-admin/admin.php?page=wcusage_help)
  • Extra RAM: Extra memory usage should kept under 5MB (currently 6.99MB on /wp-admin/admin.php?page=wcusage_setup)
PageMemory (MB)CPU Time (ms)
Home /10.10 ▲6.6367.68 ▲20.58
Dashboard /wp-admin10.68 ▲7.3895.32 ▲46.13
Posts /wp-admin/edit.php10.74 ▲7.38107.38 ▲62.52
Add New Post /wp-admin/post-new.php12.52 ▲6.63111.31 ▲22.35
Media Library /wp-admin/upload.php10.54 ▲7.3196.08 ▲63.33
Freemius Debug [v.2.6.0] /wp-admin/admin.php?page=freemius10.7881.38
Info & Help /wp-admin/admin.php?page=wcusage_help10.582,808.58
Setup Wizard /wp-admin/admin.php?page=wcusage_setup10.5379.67

Server storage [IO: ▲11.90MB] [DB: ▲0.01MB] Passed 3 tests

A short overview of filesystem and database impact
There were no storage issued detected upon installing this plugin
Filesystem: 302 new files
Database: 3 new tables, 17 new options
New tables
wp_wcusage_activity
wp_wcusage_register
wp_wcusage_clicks
New WordPress options
wcusage_options
fs_active_plugins
wcusage_register_db_version
wcusage_update_notice_dismissed_version
can_compress_scripts
fs_accounts
widget_recent-comments
theysaidso_admin_options
wcusage_activity_db_version
wcusage_update_notice_dismissed
...

Browser metrics Passed 4 tests

A check of browser resources used by WooCommerce Affiliate Plugin - Coupon Affiliates
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,478 ▼26914.20 ▼0.040.43 ▼1.156.42 ▼37.39
Dashboard /wp-admin2,213 ▲385.56 ▼0.1496.60 ▼1.6772.87 ▲36.20
Posts /wp-admin/edit.php2,131 ▲311.96 ▼0.0234.34 ▼4.7831.77 ▼3.49
Add New Post /wp-admin/post-new.php45 ▼1,4810.41 ▼22.910.08 ▼613.479.33 ▼49.78
Media Library /wp-admin/upload.php1,433 ▲304.21 ▲0.03112.70 ▲13.0479.85 ▲36.17
Freemius Debug [v.2.6.0] /wp-admin/admin.php?page=freemius1,0981.6625.1830.18
Info & Help /wp-admin/admin.php?page=wcusage_help1,4822.1325.9280.17
Setup Wizard /wp-admin/admin.php?page=wcusage_setup1,0272.0228.4236.40

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

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
You still need to fix the following
  • This plugin did not uninstall without warnings or errors
    • > Notice in wp-content/plugins/woo-coupon-usage/freemius/includes/class-freemius.php+8546
    Undefined property: stdClass::$plugins
  • The uninstall procedure failed, leaving 3 tables in the database
    • wp_wcusage_register
    • wp_wcusage_activity
    • wp_wcusage_clicks
  • The uninstall procedure has failed, leaving 17 options in the database
    • wcusage_activity_db_version
    • widget_recent-comments
    • wcusage_custom_roles_version
    • wcusage_register_db_version
    • wcusage_options
    • db_upgraded
    • can_compress_scripts
    • fs_active_plugins
    • recovery_mode_email_last_sent
    • wcusage_update_notice_dismissed_version
    • ...

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
Even though everything seems fine, this is not an exhaustive test

SRP 50% from 2 tests

🔹 Tests weight: 20 | It is important to ensure that your PHP files perform no action when accessed directly, respecting the single-responsibility principle
Please fix the following
  • 4× GET requests to PHP files trigger server-side errors or Error 500 responses:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/woo-coupon-usage/inc/api/coupon-info.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wcu_fs() in wp-content/plugins/woo-coupon-usage/inc/api/request-payout.php:2
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/woo-coupon-usage/inc/api/users-coupons.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/woo-coupon-usage/inc/admin-reports/ajax-admin-reports.php:40

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 issues were found

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: affiliates woocommerce, woocommerce affiliate, affiliate program, affiliates, affiliate

woo-coupon-usage/woo-coupon-usage.php 85% from 13 tests

The entry point to "WooCommerce Affiliate Plugin - Coupon Affiliates" version 5.11.2 is a PHP file that has certain tags in its header comment area
You should first fix the following items:
  • Description: If Twitter did it, so should we! Keep the description under 140 characters (currently 147 characters long)
  • Requires at least: Required version does not match the one declared in readme.txt ("4.7" instead of "3.7")

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short glimpse at programming languages used with this plugin and a check that no dangerous files are present
Good job! No executable or dangerous file extensions detected133,726 lines of code in 233 files:
LanguageFilesBlank linesComment linesLines of code
PO File815,67222,57565,438
PHP20013,87319,80559,133
CSS173,1571118,646
JavaScript87898509

PHP code 50% from 2 tests

This is a short overview of cyclomatic complexity and code structure for this plugin
These items need your attention
  • Class cyclomatic complexity should be reduced to less than 1000 (currently 3,096)
Cyclomatic complexity
Average complexity per logical line of code0.52
Average class complexity80.97
▷ Minimum class complexity1.00
▷ Maximum class complexity3,096.00
Average method complexity4.63
▷ Minimum method complexity1.00
▷ Maximum method complexity94.00
Code structure
Namespaces0
Interfaces1
Traits0
Classes58
▷ Abstract classes23.45%
▷ Concrete classes5696.55%
▷ Final classes00.00%
Methods1,328
▷ Static methods20015.06%
▷ Public methods92869.88%
▷ Protected methods171.28%
▷ Private methods38328.84%
Functions462
▷ Named functions45097.40%
▷ Anonymous functions122.60%
Constants149
▷ Global constants10167.79%
▷ Class constants4832.21%
▷ Public constants48100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
10 PNG files occupy 0.22MB with 0.05MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
images/icon.png0.50KB0.81KB0.00%
images/coupon-affiliates-logo.png82.24KB15.48KB▼ 81.18%
images/us.png0.31KB0.31KB0.00%
freemius/assets/img/plugin-icon.png9.16KB5.26KB▼ 42.58%
images/gb.png0.31KB0.31KB▼ 1.26%