78% woo-discount-rules

Code Review | Discount Rules for WooCommerce - Create Smart WooCommerce Coupons & Discounts

WordPress plugin Discount Rules for WooCommerce - Create Smart WooCommerce Coupons & Discounts scored78%from 54 tests.

About plugin

  • Plugin page: woo-discount-rules
  • Plugin version: 2.6.2
  • PHP version: 7.4.16
  • WordPress compatibility: 4.6.1-6.3
  • WordPress version: 6.3.1
  • First release: Dec 13, 2016
  • Latest release: Sep 27, 2023
  • Number of updates: 360
  • Update frequency: every 6.9 days
  • Top authors: flycart (99.17%)flycartdev (1.11%)

Code review

54 tests

User reviews

744 reviews

Install metrics

100,000+ active /1,756,553 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
Installer ran successfully

Server metrics [RAM: ▼0.01MB] [CPU: ▼8.78ms] Passed 4 tests

Analyzing server-side resources used by Discount Rules for WooCommerce - Create Smart WooCommerce Coupons & Discounts
Server-side resource usage in normal parameters
PageMemory (MB)CPU Time (ms)
Home /3.46 ▲0.0039.55 ▼2.85
Dashboard /wp-admin3.31 ▼0.0448.80 ▼10.70
Posts /wp-admin/edit.php3.36 ▲0.0049.67 ▼3.26
Add New Post /wp-admin/post-new.php5.89 ▲0.0094.80 ▼16.44
Media Library /wp-admin/upload.php3.23 ▲0.0037.06 ▼4.70

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

How much does this plugin use your filesystem and database?
This plugin was installed successfully
Filesystem: 180 new files
Database: no new tables, 7 new options
New WordPress options
db_upgraded
theysaidso_admin_options
can_compress_scripts
widget_theysaidso_widget
widget_recent-posts
advanced_woo_discount_rules_load_version
widget_recent-comments

Browser metrics Passed 4 tests

A check of browser resources used by Discount Rules for WooCommerce - Create Smart WooCommerce Coupons & Discounts
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,789 ▲2814.37 ▼0.211.71 ▲0.0144.44 ▲2.50
Dashboard /wp-admin2,192 ▲185.67 ▲0.1092.08 ▲4.8943.64 ▲2.48
Posts /wp-admin/edit.php2,103 ▲31.99 ▼0.0139.37 ▼1.2537.74 ▼9.86
Add New Post /wp-admin/post-new.php1,549 ▼023.20 ▲0.08616.73 ▼196.6254.35 ▼85.40
Media Library /wp-admin/upload.php1,397 ▼34.22 ▲0.03101.35 ▼30.8644.53 ▼9.77

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
These items require your attention
  • Zombie WordPress options detected upon uninstall: 7 options
    • can_compress_scripts
    • widget_recent-posts
    • theysaidso_admin_options
    • widget_recent-comments
    • db_upgraded
    • advanced_woo_discount_rules_load_version
    • widget_theysaidso_widget

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
Good news, no errors were detected

SRP 0% from 2 tests

🔹 Tests weight: 20 | The single-responsibility principle applies for WordPress plugins as well - please make sure your PHP files perform no actions when accessed directly
Almost there! Just fix the following items
  • 2× PHP files output text when accessed directly:
    • > /wp-content/plugins/woo-discount-rules/v2/App/Views/Admin/Tabs/compatible.php
    • > /wp-content/plugins/woo-discount-rules/v2/App/Views/Admin/Tabs/settings.php
  • 5× 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/woo-discount-rules/v2/App/Snippets/overrideCustomPrice.php:6
    • > PHP Fatal error
      Uncaught Error: Class 'Wdr\\App\\Controllers\\ManageDiscount' not found in wp-content/plugins/woo-discount-rules/v2/App/Controllers/Admin/Messages.php:8
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/woo-discount-rules/v2/App/Views/Admin/review-notice.php:6
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_filter() in wp-content/plugins/woo-discount-rules/v2/App/Snippets/disableRecalculateTotal.php:6
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_filter() in wp-content/plugins/woo-discount-rules/v2/App/Snippets/recalculateTotalBeforeApplyCoupon.php:6

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a smoke test targeting browser errors/issues
No browser issues were found

Optimizations

Plugin configuration 93% from 29 tests

readme.txt 94% from 16 tests

The readme.txt file uses markdown syntax to describe your plugin to the world
Please fix the following attributes:
  • Tags: Too many tags (12 tag instead of maximum 10); only the first 5 tags are used in your directory listing
You can take inspiration from this readme.txt

woo-discount-rules/woo-discount-rules.php 92% from 13 tests

"Discount Rules for WooCommerce - Create Smart WooCommerce Coupons & Discounts" version 2.6.2's main PHP file describes plugin functionality and also serves as the entry point to any WordPress functionality
You should first fix the following items:
  • Requires at least: Required version must match the one declared in readme.txt ("4.4.1" instead of "4.6.1")

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
Everything looks great! No dangerous files found in this plugin27,029 lines of code in 170 files:
LanguageFilesBlank linesComment linesLines of code
PHP1411,8074,71621,883
JavaScript182554423,534
CSS891591,487
JSON20099
XML10026

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
  • Please reduce cyclomatic complexity of methods to less than 100 (currently 109)
Cyclomatic complexity
Average complexity per logical line of code0.60
Average class complexity60.03
▷ Minimum class complexity1.00
▷ Maximum class complexity681.00
Average method complexity5.39
▷ Minimum method complexity1.00
▷ Maximum method complexity109.00
Code structure
Namespaces12
Interfaces0
Traits0
Classes61
▷ Abstract classes46.56%
▷ Concrete classes5793.44%
▷ Final classes00.00%
Methods826
▷ Static methods25831.23%
▷ Public methods66980.99%
▷ Protected methods14317.31%
▷ Private methods141.69%
Functions66
▷ Named functions1015.15%
▷ Anonymous functions5684.85%
Constants18
▷ Global constants1372.22%
▷ Class constants527.78%
▷ Public constants5100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

PNG files should be compressed to save space and minimize bandwidth usage
6 PNG files occupy 0.04MB with 0.01MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
v2/Assets/Js/Jquery-ui/images/ui-icons_555555_256x240.png6.96KB4.18KB▼ 39.91%
v2/Assets/Js/Jquery-ui/images/ui-icons_777620_256x240.png4.56KB4.18KB▼ 8.31%
v2/Assets/Js/Jquery-ui/images/ui-icons_777777_256x240.png7.00KB4.18KB▼ 40.22%
v2/Assets/Js/Jquery-ui/images/ui-icons_cc0000_256x240.png4.56KB4.18KB▼ 8.31%
v2/Assets/Js/Jquery-ui/images/ui-icons_ffffff_256x240.png6.39KB4.18KB▼ 34.52%