57% add-region-by-country-for-woocommerce

Code Review | Add Region by Country for WooCommerce

WordPress plugin Add Region by Country for WooCommerce scored57%from 54 tests.

About plugin

  • Plugin page: add-region-by-cou...
  • Plugin version: 1.0.3
  • PHP version: 7.4.16
  • WordPress compatibility: 5.0-6.1.1
  • WordPress version: 6.3.1
  • First release: Feb 28, 2020
  • Latest release: Jul 6, 2023
  • Number of updates: 8
  • Update frequency: every 153.0 days
  • Top authors: rupeshjorkar (100%)

Code review

54 tests

User reviews

1 review

Install metrics

80+ active /1,082 total downloads

Benchmarks

Plugin footprint 48% from 16 tests

Installer Passed 1 test

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

Server metrics [RAM: ▼1.87MB] [CPU: ▼53.95ms] Passed 4 tests

Analyzing server-side resources used by Add Region by Country for WooCommerce
Normal server usage
PageMemory (MB)CPU Time (ms)
Home /2.12 ▼1.347.39 ▼33.36
Dashboard /wp-admin2.14 ▼1.167.20 ▼57.04
Posts /wp-admin/edit.php2.14 ▼1.217.20 ▼44.83
Add New Post /wp-admin/post-new.php2.14 ▼3.758.17 ▼80.58
Media Library /wp-admin/upload.php2.14 ▼1.087.84 ▼26.76
Add Region /wp-admin/admin.php?page=arbyw-region-by-country-page2.148.15

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

Filesystem and database footprint
There were no storage issued detected upon installing this plugin
Filesystem: 9 new files
Database: 1 new table, 8 new options
New tables
wp_woocommerce_custom_region_by_country
New WordPress options
widget_recent-posts
WC_CMETRIC_ARBYW_DB_VERSION
widget_theysaidso_widget
widget_recent-comments
theysaidso_admin_options
db_upgraded
can_compress_scripts
recovery_mode_email_last_sent

Browser metrics Passed 4 tests

A check of browser resources used by Add Region by Country for WooCommerce
There were no issues detected in relation to browser resource usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,828 ▲6714.74 ▲0.361.73 ▲0.0247.55 ▲5.33
Dashboard /wp-admin2,231 ▲285.81 ▲0.9596.41 ▼17.7539.33 ▲0.64
Posts /wp-admin/edit.php2,113 ▲132.04 ▼0.0137.03 ▼4.9436.86 ▼2.53
Add New Post /wp-admin/post-new.php1,539 ▲1317.67 ▲0.20680.80 ▲5.5950.68 ▲5.85
Media Library /wp-admin/upload.php1,416 ▲164.14 ▼0.09112.29 ▲13.1053.79 ▲6.27
Add Region /wp-admin/admin.php?page=arbyw-region-by-country-page7331.538.3232.67

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

🔸 Tests weight: 35 | It is important to correctly uninstall your plugin, without leaving any traces
You still need to fix the following
  • This plugin cannot be uninstalled
    • > Notice in wp-content/plugins/add-region-by-country-for-woocommerce/cmetric_arbyw_class.php+70
    Undefined index: activate
  • Zombie tables detected upon uninstall: 1 table
    • wp_woocommerce_custom_region_by_country
  • Zombie WordPress options were found after uninstall: 8 options
    • WC_CMETRIC_ARBYW_DB_VERSION
    • theysaidso_admin_options
    • recovery_mode_email_last_sent
    • db_upgraded
    • widget_recent-comments
    • widget_theysaidso_widget
    • can_compress_scripts
    • widget_recent-posts

Smoke tests 50% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | This is a shallow check for server-side errors
Almost there, just fix the following server-side errors
    • > GET request to /wp-admin/admin.php?page=arbyw-region-by-country-page
    • > Notice in wp-content/plugins/add-region-by-country-for-woocommerce/cmetric_arbyw_class.php+70
    Undefined index: activate
    • > GET request to /wp-admin/admin.php?page=arbyw-region-by-country-page
    • > Error in wp-content/plugins/add-region-by-country-for-woocommerce/includes/views/region_country_page.php+116
    Uncaught Error: Class 'WC_Countries' not found in wp-content/plugins/add-region-by-country-for-woocommerce/includes/views/region_country_page.php:116
    Stack trace:
    #0 wp-content/plugins/add-region-by-country-for-woocommerce/includes/views/region_country_page.php(55): region_build_form()
    #1 wp-content/plugins/add-region-by-country-for-woocommerce/includes/cmetric_arbyw_setting_functions.php(52): include('/var/www/wordpr...')
    #2 wp-includes/class-wp-hook.php(310): WP_Class_Cmetric_Arbyw_Setting->arbyw_region_by_country_page_callback()
    #3 wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters()
    #4 wp-includes/plugin.php(517): WP_Hook->do_action()
    #5 wp-admin/admin.php(259): do_action()
    #6 {main}
    thrown

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
Please take a closer look at the following
  • 7× PHP files trigger server-side errors or warnings when accessed directly:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_html() in wp-content/plugins/add-region-by-country-for-woocommerce/includes/views/region_country_page.php:2
    • > PHP Warning
      require_once(ABSPATHwp-admin/includes/class-wp-list-table.php): failed to open stream: No such file or directory in wp-content/plugins/add-region-by-country-for-woocommerce/includes/views/class-region-list-table.php on line 4
    • > PHP Warning
      require_once(ABSPATHwp-admin/includes/class-wp-list-table.php): failed to open stream: No such file or directory in wp-content/plugins/add-region-by-country-for-woocommerce/includes/views/class-region-list-table.php on line 4
    • > PHP Fatal error
      require_once(): Failed opening required 'ABSPATHwp-admin/includes/class-wp-list-table.php' (include_path='.:/usr/share/php') in wp-content/plugins/add-region-by-country-for-woocommerce/includes/views/class-region-list-table.php on line 4
    • > PHP Fatal error
      require_once(): Failed opening required 'ABSPATHwp-admin/includes/class-wp-list-table.php' (include_path='.:/usr/share/php') in wp-content/plugins/add-region-by-country-for-woocommerce/includes/views/class-region-list-table.php on line 4
    • > PHP Warning
      Use of undefined constant ABSPATH - assumed 'ABSPATH' (this will throw an Error in a future version of PHP) in wp-content/plugins/add-region-by-country-for-woocommerce/includes/views/class-region-list-table.php on line 4
    • > PHP Warning
      Use of undefined constant ABSPATH - assumed 'ABSPATH' (this will throw an Error in a future version of PHP) in wp-content/plugins/add-region-by-country-for-woocommerce/includes/views/class-region-list-table.php on line 4

User-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no browser errors were triggered
Everything seems fine, but this is not an exhaustive test

Optimizations

Plugin configuration 86% from 29 tests

readme.txt 81% from 16 tests

It's important to format your readme.txt file correctly as it is parsed for the public listing of your plugin
These attributes need to be fixed:
  • Tags: Please reduce the number of tags, currently 12 tag instead of maximum 10
  • License uri: Please fix this invalid url: ""
  • Donate link: Please fix this invalid url: ""
Please take inspiration from this readme.txt

add-region-by-country-for-woocommerce/add-region-by-country-for-woocommerce.php 92% from 13 tests

The main PHP file in "Add Region by Country for WooCommerce" ver. 1.0.3 adds more information about the plugin and also serves as the entry point for this plugin
It is important to fix the following:
  • Text Domain: Since WordPress version 4.6 the text domain is optional; if specified, it must be the same as the plugin slug

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
Everything looks great! No dangerous files found in this plugin466 lines of code in 7 files:
LanguageFilesBlank linesComment linesLines of code
PHP62254463
CSS1003

PHP code Passed 2 tests

An overview of cyclomatic complexity and code structure
There were no cyclomatic complexity issued detected
Cyclomatic complexity
Average complexity per logical line of code0.31
Average class complexity11.33
▷ Minimum class complexity3.00
▷ Maximum class complexity19.00
Average method complexity1.85
▷ Minimum method complexity1.00
▷ Maximum method complexity7.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes3
▷ Abstract classes00.00%
▷ Concrete classes3100.00%
▷ Final classes00.00%
Methods28
▷ Static methods310.71%
▷ Public methods2589.29%
▷ Protected methods00.00%
▷ Private methods310.71%
Functions1
▷ Named functions1100.00%
▷ Anonymous functions00.00%
Constants6
▷ Global constants583.33%
▷ Class constants116.67%
▷ Public constants1100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

PNG files should be compressed to save space and minimize bandwidth usage
No PNG images were found in this plugin