78% ni-woocommerce-cost-of-goods

Code Review | Ni WooCommerce Cost Of Goods

WordPress plugin Ni WooCommerce Cost Of Goods scored78%from 54 tests.

About plugin

  • Plugin page: ni-woocommerce-co...
  • Plugin version: 3.2.3
  • PHP compatiblity: 7.0+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.7-6.4.1
  • WordPress version: 6.3.1
  • First release: Feb 19, 2017
  • Latest release: Nov 23, 2023
  • Number of updates: 89
  • Update frequency: every 27.7 days
  • Top authors: anzia (100%)

Code review

54 tests

User reviews

4 reviews

Install metrics

700+ active /39,582 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

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

Server metrics [RAM: ▲0.18MB] [CPU: ▼2.54ms] Passed 4 tests

A check of server-side resources used by Ni WooCommerce Cost Of Goods
Server-side resource usage in normal parameters
PageMemory (MB)CPU Time (ms)
Home /3.65 ▲0.1843.39 ▼1.19
Dashboard /wp-admin3.50 ▲0.1547.21 ▼11.53
Posts /wp-admin/edit.php3.61 ▲0.2552.88 ▲6.64
Add New Post /wp-admin/post-new.php6.08 ▲0.1992.20 ▼0.54
Media Library /wp-admin/upload.php3.42 ▲0.1936.06 ▲3.11
Setting /wp-admin/admin.php?page=ni-cog-setting3.4232.11
Other plugin /wp-admin/admin.php?page=ni-cog-other-plugin3.4434.68
Category Stock Value /wp-admin/admin.php?page=ni-category-stock-value3.4232.43
Top Profit Product /wp-admin/admin.php?page=ni-cog-top-profit-product3.4231.41
Dashboard /wp-admin/admin.php?page=ni-cost-of-goods3.5534.42
Profit Report /wp-admin/admin.php?page=ni-cog-report3.5833.18
Profit Analytical /wp-admin/admin.php?page=ni-cog-analytical-report3.4333.54
Add Cost Price /wp-admin/admin.php?page=niwoocog-add-cost-price3.4744.17

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

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

Browser metrics Passed 4 tests

Ni WooCommerce Cost Of Goods: an overview of browser usage
This plugin renders optimally with no browser resource issues detected
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,837 ▲7514.34 ▼0.011.60 ▼0.2541.68 ▼1.68
Dashboard /wp-admin2,236 ▲565.47 ▼0.2095.59 ▼3.3440.65 ▲0.07
Posts /wp-admin/edit.php2,150 ▲472.03 ▲0.0839.11 ▲0.3536.80 ▲1.74
Add New Post /wp-admin/post-new.php1,573 ▲4718.47 ▼5.07622.71 ▼26.3966.68 ▲15.77
Media Library /wp-admin/upload.php1,450 ▲534.16 ▲0.0296.31 ▼2.7642.33 ▼0.02
Setting /wp-admin/admin.php?page=ni-cog-setting9781.9927.4343.35
Other plugin /wp-admin/admin.php?page=ni-cog-other-plugin1,1502.0022.8329.59
Category Stock Value /wp-admin/admin.php?page=ni-category-stock-value9371.6932.4630.08
Top Profit Product /wp-admin/admin.php?page=ni-cog-top-profit-product8951.9722.1434.78
Dashboard /wp-admin/admin.php?page=ni-cost-of-goods8781.636.5828.99
Profit Report /wp-admin/admin.php?page=ni-cog-report7391.526.5417.22
Profit Analytical /wp-admin/admin.php?page=ni-cog-analytical-report9671.7232.7024.04
Add Cost Price /wp-admin/admin.php?page=niwoocog-add-cost-price1,0421.6925.0626.70

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

🔸 Tests weight: 35 | The uninstall procedure must remove all plugin files and extra database tables
Please fix the following items
  • Zombie WordPress options were found after uninstall: 7 options
    • widget_theysaidso_widget
    • recovery_mode_email_last_sent
    • widget_recent-posts
    • theysaidso_admin_options
    • db_upgraded
    • widget_recent-comments
    • can_compress_scripts

Smoke tests 50% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the server (in the Apache logs)
Smoke test failed, please fix the following
    • > GET request to /wp-admin/admin.php?page=ni-cost-of-goods
    • > Error in wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-cog-dashboard.php+73
    Uncaught Error: Call to undefined function wc_price() in wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-cog-dashboard.php:73
    Stack trace:
    #0 wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-woocommerce-cost-of-goods-init.php(173): Ni_COG_Dashboard->page_init()
    #1 wp-includes/class-wp-hook.php(310): Ni_WooCommerce_Cost_Of_Goods_Init->add_page()
    #2 wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters()
    #3 wp-includes/plugin.php(517): WP_Hook->do_action()
    #4 wp-admin/admin.php(259): do_action()
    #5 {main}
    thrown
    • > GET request to /wp-admin/admin.php?page=ni-cog-report
    • > Error in wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-cog-sales-report.php+215
    Uncaught Error: Class 'WC_Countries' not found in wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-cog-sales-report.php:215
    Stack trace:
    #0 wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-cog-sales-report.php(206): Ni_COG_Sales_Report->get_countries()
    #1 wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-cog-sales-report.php(18): Ni_COG_Sales_Report->get_order_country()
    #2 wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-woocommerce-cost-of-goods-init.php(167): Ni_COG_Sales_Report->page_init()
    #3 wp-includes/class-wp-hook.php(310): Ni_WooCommerce_Cost_Of_Goods_Init->add_page()
    #4 wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters()
    #5 wp-includes/plugin.php(517): WP_Hook->do_action()
    #6 wp-admin/admin.php(259): do_action()
    #7 {main}
    thrown
    • > GET request to /wp-admin/admin.php?page=ni-cog-analytical-report
    • > Error in wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-cog-analytical-report.php+255
    Uncaught Error: Call to undefined function wc_price() in wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-cog-analytical-report.php:255
    Stack trace:
    #0 wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-cog-analytical-report.php(140): Ni_COG_Analytical_Report->get_tables()
    #1 wp-content/plugins/ni-woocommerce-cost-of-goods/include/ni-woocommerce-cost-of-goods-init.php(257): Ni_COG_Analytical_Report->page_ajax()
    #2 wp-includes/class-wp-hook.php(310): Ni_WooCommerce_Cost_Of_Goods_Init->ajax_ni_cog_action()
    #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-ajax.php(188): do_action()
    #6 {main}
    thrown

SRP Passed 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
Congratulations! This plugin passed the SRP test

User-side errors 0% from 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
Please fix the following user-side errors
    • > GET request to /wp-admin/admin.php?page=ni-cog-analytical-report
    • > Network (severe)
    wp-admin/admin-ajax.php?sub_action=ni_cog_analytical_report&action=ni_cog_action - Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 94% 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
These attributes need your attention:
  • Screenshots: These screenshots do not have images: #1 (Sales analysis count and value), #2 (Profit analysis count and value), #3 (Top 5 profit product), #4 (Top 5 profit customer), #5 (Profit report search and filter), #6 (Product profit grid or table), #7 (Product profit report), #8 (Today, yesterday and last 7 days profit product), #9 (Add cost price to product), #10 (Cost of goods setting), #11 (Product additional columns), #12 (Top 5 profit category), #13 (Current year vs previous year profit)
Please take inspiration from this readme.txt

ni-woocommerce-cost-of-goods/ni-woocommerce-cost-of-goods.php 85% from 13 tests

The principal PHP file in "Ni WooCommerce Cost Of Goods" v. 3.2.3 is loaded by WordPress automatically on each request
You should first fix the following items:
  • Text Domain: You no longer need to specify the text domain since WordPress 4.6; it must be the same as the plugin slug
  • Description: Please keep the plugin description shorter than 140 characters (currently 295 characters long)

Code Analysis Passed 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 detected8,982 lines of code in 24 files:
LanguageFilesBlank linesComment linesLines of code
PHP137031443,342
SVG1002,671
CSS553492,658
PO File199115220
JavaScript4271091

PHP code Passed 2 tests

This plugin's cyclomatic complexity and code structure detailed below
No cyclomatic complexity issues were detected for this plugin
Cyclomatic complexity
Average complexity per logical line of code0.31
Average class complexity27.21
▷ Minimum class complexity1.00
▷ Maximum class complexity106.00
Average method complexity4.34
▷ Minimum method complexity1.00
▷ Maximum method complexity40.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes14
▷ Abstract classes00.00%
▷ Concrete classes14100.00%
▷ Final classes00.00%
Methods110
▷ Static methods00.00%
▷ Public methods10999.09%
▷ Protected methods00.00%
▷ Private methods10.91%
Functions0
▷ Named functions00.00%
▷ Anonymous functions00.00%
Constants0
▷ Global constants00.00%
▷ Class constants00.00%
▷ Public constants00.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
13 PNG files occupy 0.46MB with 0.28MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
screenshot-12.png20.27KB7.48KB▼ 63.09%
screenshot-13.png23.42KB14.23KB▼ 39.24%
screenshot-11.png76.67KB24.52KB▼ 68.03%
screenshot-6.png34.14KB11.87KB▼ 65.23%
screenshot-5.png18.16KB6.31KB▼ 65.23%