84% woocommerce-gift-coupon

Code Review | WooCommerce Gift Coupon

WordPress plugin WooCommerce Gift Coupon scored84%from 54 tests.

About plugin

  • Plugin page: woocommerce-gift-...
  • Plugin version: 3.3.0
  • PHP version: 7.4.16
  • WordPress compatibility: 3.4-5.0.2
  • WordPress version: 6.3.1
  • First release: May 12, 2015
  • Latest release: Dec 24, 2018
  • Number of updates: 98
  • Update frequency: every 13.5 days
  • Top authors: studiosweb (100%)

Code review

54 tests

User reviews

11 reviews

Install metrics

400+ active /18,466 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | It is important to correctly install your plugin, without throwing errors or notices
This plugin's installer ran successfully

Server metrics [RAM: ▲0.00MB] [CPU: ▼5.09ms] Passed 4 tests

Analyzing server-side resources used by WooCommerce Gift Coupon
Normal server usage
PageMemory (MB)CPU Time (ms)
Home /3.46 ▲0.0042.30 ▼4.95
Dashboard /wp-admin3.31 ▲0.0050.37 ▼3.42
Posts /wp-admin/edit.php3.36 ▲0.0050.13 ▼1.66
Add New Post /wp-admin/post-new.php5.89 ▲0.0092.43 ▼10.31
Media Library /wp-admin/upload.php3.23 ▲0.0036.17 ▼0.72

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

Input-output and database impact of this plugin
This plugin installed successfully
Filesystem: 253 new files
Database: no new tables, 6 new options
New WordPress options
widget_recent-posts
widget_theysaidso_widget
theysaidso_admin_options
can_compress_scripts
widget_recent-comments
db_upgraded

Browser metrics Passed 4 tests

This is an overview of browser requirements for WooCommerce Gift Coupon
This plugin renders optimally with no browser resource issues detected
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,789 ▲2814.21 ▼0.081.75 ▼0.0143.09 ▲0.06
Dashboard /wp-admin2,195 ▲185.51 ▼0.0986.32 ▼4.2739.19 ▼5.76
Posts /wp-admin/edit.php2,103 ▼02.02 ▲0.0238.15 ▼2.5737.78 ▼0.05
Add New Post /wp-admin/post-new.php1,526 ▼023.14 ▼0.44680.37 ▼21.3960.78 ▲4.57
Media Library /wp-admin/upload.php1,400 ▲34.18 ▼0.0195.88 ▼22.5544.50 ▼5.66

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

🔸 Tests weight: 35 | It is important to correctly uninstall your plugin, without leaving any traces
These items require your attention
  • Zombie WordPress options detected upon uninstall: 6 options
    • widget_recent-comments
    • widget_theysaidso_widget
    • can_compress_scripts
    • theysaidso_admin_options
    • db_upgraded
    • widget_recent-posts

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 everything seems fine, this is not an exhaustive test

SRP 50% from 2 tests

🔹 Tests weight: 20 | The single-responsibility principle: PHP files have to remain inert when accessed directly, throwing no errors and performing no actions
Almost there! Just fix the following items
  • 103× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'Svg\\Tag\\AbstractTag' not found in wp-content/plugins/woocommerce-gift-coupon/lib/dompdf/lib/php-svg-lib/src/Svg/Tag/StyleTag.php:13
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_max_upload_size() in wp-content/plugins/woocommerce-gift-coupon/admin/includes/gs-middle-options-page.php:11
    • > PHP Fatal error
      Uncaught Error: Class 'FontLib\\Table\\Table' not found in wp-content/plugins/woocommerce-gift-coupon/lib/dompdf/lib/php-font-lib/src/FontLib/Table/Type/hhea.php:17
    • > PHP Fatal error
      Uncaught Error: Class 'FontLib\\Table\\Table' not found in wp-content/plugins/woocommerce-gift-coupon/lib/dompdf/lib/php-font-lib/src/FontLib/Table/Type/cmap.php:17
    • > PHP Fatal error
      Uncaught Error: Class 'Dompdf\\FrameDecorator\\AbstractFrameDecorator' not found in wp-content/plugins/woocommerce-gift-coupon/lib/dompdf/src/FrameDecorator/Block.php:20
    • > PHP Fatal error
      Uncaught Error: Class 'FontLib\\Header' not found in wp-content/plugins/woocommerce-gift-coupon/lib/dompdf/lib/php-font-lib/src/FontLib/EOT/Header.php:21
    • > PHP Fatal error
      Uncaught Error: Interface 'Dompdf\\Canvas' not found in wp-content/plugins/woocommerce-gift-coupon/lib/dompdf/src/Adapter/GD.php:24
    • > PHP Fatal error
      Uncaught Error: Class 'Dompdf\\FrameDecorator\\AbstractFrameDecorator' not found in wp-content/plugins/woocommerce-gift-coupon/lib/dompdf/src/FrameDecorator/Inline.php:22
    • > PHP Fatal error
      Uncaught Error: Class 'Dompdf\\FrameReflower\\AbstractFrameReflower' not found in wp-content/plugins/woocommerce-gift-coupon/lib/dompdf/src/FrameReflower/Block.php:23
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/woocommerce-gift-coupon/lib/dompdf/lib/php-font-lib/tests/FontLib/FontTest.php:8

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a smoke test targeting browser errors/issues
Everything seems fine on the user side

Optimizations

Plugin configuration Passed 29 tests

readme.txt Passed 16 tests

The readme.txt file uses markdown syntax to describe your plugin to the world
6 plugin tags: discount coupon, cards, coupons, gift, pdf coupon...

woocommerce-gift-coupon/woocommerce-gift-coupon.php Passed 13 tests

"WooCommerce Gift Coupon" version 3.3.0's primary PHP file adds more information about the plugin and serves as the entry point for WordPress
130 characters long description:
Buy coupons as a product to give a friend. Generate coupon code PDF and send it by email or download manually on the user profile.

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 detected45,332 lines of code in 176 files:
LanguageFilesBlank linesComment linesLines of code
PHP1587,85715,06344,152
CSS211646552
Markdown4860233
XML332175
JSON400124
YAML211240
JavaScript10431
HTML10017
SVG1008

PHP code 50% from 2 tests

A short review of cyclomatic complexity and code structure
These items need your attention
  • Please reduce cyclomatic complexity of methods to less than 100 (currently 652)
Cyclomatic complexity
Average complexity per logical line of code0.43
Average class complexity41.43
▷ Minimum class complexity1.00
▷ Maximum class complexity765.00
Average method complexity4.78
▷ Minimum method complexity1.00
▷ Maximum method complexity652.00
Code structure
Namespaces25
Interfaces2
Traits0
Classes143
▷ Abstract classes64.20%
▷ Concrete classes13795.80%
▷ Final classes00.00%
Methods1,609
▷ Static methods804.97%
▷ Public methods1,36084.52%
▷ Protected methods18811.68%
▷ Private methods613.79%
Functions49
▷ Named functions3877.55%
▷ Anonymous functions1122.45%
Constants155
▷ Global constants74.52%
▷ Class constants14895.48%
▷ Public constants148100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
2 compressed PNG files occupy 0.00MB
Potential savings
Compression of 2 random PNG files using pngquant
FileSize - originalSize - compressedSavings
admin/images/woocommerce_gift_coupon-icon.png0.37KB0.48KB0.00%
lib/dompdf/lib/res/broken_image.png0.60KB0.47KB▼ 22.33%