73% carbonbalance-for-woocommerce

Code Review | Carbon Balance: Carbon calculation and offsetting for WooCommerce

WordPress plugin Carbon Balance: Carbon calculation and offsetting for WooCommerce scored73%from 54 tests.

About plugin

  • Plugin page: carbonbalance-for...
  • Plugin version: 1.0.0.5
  • PHP compatiblity: 7.3+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.0-6.3.1
  • WordPress version: 6.3.1
  • First release: Jun 20, 2023
  • Latest release: Sep 6, 2023
  • Number of updates: 22
  • Update frequency: every 3.6 days
  • Top authors: carbonbalance (100%)

Code review

54 tests

User reviews

1 review

Install metrics

10+ active /368 total downloads

Benchmarks

Plugin footprint 65% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | The install procedure must perform silently
The plugin installed successfully, without throwing any errors or notices

Server metrics [RAM: ▼1.97MB] [CPU: ▲858.38ms] 75% from 4 tests

This is a short check of server-side resources used by Carbon Balance: Carbon calculation and offsetting for WooCommerce
Please have a look at the following items
  • Extra CPU: The extra CPU usage must be under 200.00ms (currently 858.38ms on /wp-admin/upload.php)
PageMemory (MB)CPU Time (ms)
Home /2.03 ▼1.43972.13 ▲931.21
Dashboard /wp-admin2.05 ▼1.30943.22 ▲886.27
Posts /wp-admin/edit.php2.05 ▼1.31936.51 ▲886.97
Add New Post /wp-admin/post-new.php2.05 ▼3.84903.51 ▲791.74
Media Library /wp-admin/upload.php2.05 ▼1.18905.34 ▲868.54

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

Filesystem and database footprint
No storage issues were detected
Filesystem: 67 new files
Database: no new tables, 8 new options
New WordPress options
widget_recent-posts
carbonbalance_checkout_placement
widget_recent-comments
widget_theysaidso_widget
db_upgraded
carbonbalance_widgetmark_footer
can_compress_scripts
theysaidso_admin_options

Browser metrics Passed 4 tests

Carbon Balance: Carbon calculation and offsetting for WooCommerce: an overview of browser usage
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,819 ▲7314.79 ▲0.401.91 ▲0.2536.68 ▼3.25
Dashboard /wp-admin2,210 ▲195.81 ▼0.0494.43 ▼9.6739.74 ▼2.47
Posts /wp-admin/edit.php2,092 ▲31.96 ▼0.0332.79 ▼6.3235.54 ▲0.48
Add New Post /wp-admin/post-new.php1,545 ▲3120.72 ▲3.10587.00 ▼50.3852.35 ▲1.16
Media Library /wp-admin/upload.php1,392 ▲44.18 ▼0.0089.53 ▼8.0642.78 ▲0.49

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

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
It is recommended to fix the following
  • The plugin did not uninstall gracefully
    • > Notice in wp-content/plugins/carbonbalance-for-woocommerce/carbonbalance-plugin.php+477
    Trying to get property 'message' of non-object
  • This plugin does not fully uninstall, leaving 8 options in the database
    • widget_recent-posts
    • widget_recent-comments
    • carbonbalance_checkout_placement
    • db_upgraded
    • can_compress_scripts
    • carbonbalance_widgetmark_footer
    • widget_theysaidso_widget
    • theysaidso_admin_options

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
Almost there! Just fix the following items
  • 10× PHP files trigger errors when accessed directly with GET requests:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugin_dir_path() in wp-content/plugins/carbonbalance-for-woocommerce/carbonbalance-autoloader.php:12
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found in wp-content/plugins/carbonbalance-for-woocommerce/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php:12
    • > PHP Fatal error
      Uncaught Error: Call to undefined function sanitize_url() in wp-content/plugins/carbonbalance-for-woocommerce/views/carbonbalance_widget_template_default.php:8
    • > PHP Fatal error
      Uncaught Error: Call to undefined function carbonbalance_plugin_woocommerce\\Components\\Admin\\add_action() in wp-content/plugins/carbonbalance-for-woocommerce/Components/Admin/Carbonbalance-AdminOverview.php:16
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found in wp-content/plugins/carbonbalance-for-woocommerce/vendor/cbschuld/logentries/tests/LogEntriesTest.php:8
    • > PHP Fatal error
      Uncaught Error: Class 'Psr\\Log\\AbstractLogger' not found in wp-content/plugins/carbonbalance-for-woocommerce/vendor/psr/log/Psr/Log/NullLogger.php:13
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/carbonbalance-for-woocommerce/Components/Admin/views/default.php:9
    • > PHP Fatal error
      Uncaught Error: Interface 'Psr\\Log\\LoggerInterface' not found in wp-content/plugins/carbonbalance-for-woocommerce/vendor/psr/log/Psr/Log/AbstractLogger.php:12
    • > PHP Fatal error
      Uncaught Error: Class 'cbschuld\\LogEntriesWriter' not found in wp-content/plugins/carbonbalance-for-woocommerce/vendor/cbschuld/logentries/tests/WriterTest.php:7
    • > PHP Fatal error
      Uncaught Error: Class 'Psr\\Log\\AbstractLogger' not found in wp-content/plugins/carbonbalance-for-woocommerce/vendor/cbschuld/logentries/src/LogEntries.php:8

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
No browser errors were detected

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 88% from 16 tests

The readme.txt file uses markdown syntax to describe your plugin to the world
These attributes need your attention: The official readme.txt is a good inspiration

carbonbalance-for-woocommerce/carbonbalance-plugin.php 92% from 13 tests

The principal PHP file in "Carbon Balance: Carbon calculation and offsetting for WooCommerce" v. 1.0.0.5 is loaded by WordPress automatically on each request
The following require your attention:
  • Main file name: It is recommended to name the main PHP file as the plugin slug ("carbonbalance-for-woocommerce.php" instead of "carbonbalance-plugin.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | An overview of files in this plugin; executable files are not allowed
Success! There were no dangerous files found in this plugin15,284 lines of code in 53 files:
LanguageFilesBlank linesComment linesLines of code
JavaScript3265346,986
JSON6004,125
PHP296419402,355
CSS27023888
Sass2593541
Markdown2610146
Bourne Shell121799
SVG21082
XML33043
INI20010
YAML1309

PHP code Passed 2 tests

A brief analysis of cyclomatic complexity and code structure for this plugin
No cyclomatic complexity issues were detected for this plugin
Cyclomatic complexity
Average complexity per logical line of code0.30
Average class complexity11.70
▷ Minimum class complexity1.00
▷ Maximum class complexity112.00
Average method complexity2.47
▷ Minimum method complexity1.00
▷ Maximum method complexity18.00
Code structure
Namespaces8
Interfaces2
Traits2
Classes19
▷ Abstract classes315.79%
▷ Concrete classes1684.21%
▷ Final classes00.00%
Methods160
▷ Static methods138.12%
▷ Public methods14892.50%
▷ Protected methods00.00%
▷ Private methods127.50%
Functions6
▷ Named functions233.33%
▷ Anonymous functions466.67%
Constants14
▷ Global constants00.00%
▷ Class constants14100.00%
▷ Public constants14100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

It is recommended to compress PNG files in your plugin to minimize bandwidth usage
2 PNG files occupy 0.04MB with 0.02MB in potential savings
Potential savings
Compression of 2 random PNG files using pngquant
FileSize - originalSize - compressedSavings
images/carbonbalance_logo.png43.51KB16.37KB▼ 62.38%
images/check_carbonbalance.png0.75KB0.39KB▼ 47.26%