74% woocommerce-braintree-payment-gateway

Code Review | WooCommerce Braintree Payment Gateway

WordPress plugin WooCommerce Braintree Payment Gateway scored74%from 54 tests.

About plugin

  • Plugin page: woocommerce-brain...
  • Plugin version: 1.9.5
  • PHP version: 7.4.16
  • WordPress compatibility: 5.0-6.3
  • WordPress version: 6.3.1
  • First release: Sep 22, 2014
  • Latest release: Jul 27, 2023
  • Number of updates: 57
  • Update frequency: every 56.7 days
  • Top authors: wp.insider (70.18%)Leljak (31.58%)

Code review

54 tests

User reviews

12 reviews

Install metrics

500+ active /23,692 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
The plugin installed gracefully, with no errors

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

Server-side resources used by WooCommerce Braintree Payment Gateway
Normal server usage
PageMemory (MB)CPU Time (ms)
Home /3.47 ▲0.0136.22 ▼3.22
Dashboard /wp-admin3.31 ▲0.0147.40 ▼0.00
Posts /wp-admin/edit.php3.36 ▲0.0149.58 ▲0.59
Add New Post /wp-admin/post-new.php5.89 ▲0.0190.48 ▼7.18
Media Library /wp-admin/upload.php3.23 ▲0.0032.61 ▼1.33

Server storage [IO: ▲0.57MB] [DB: ▲0.07MB] Passed 3 tests

Filesystem and database footprint
This plugin was installed successfully
Filesystem: 192 new files
Database: no new tables, 6 new options
New WordPress options
can_compress_scripts
theysaidso_admin_options
db_upgraded
widget_theysaidso_widget
widget_recent-posts
widget_recent-comments

Browser metrics Passed 4 tests

WooCommerce Braintree Payment Gateway: an overview of browser usage
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,825 ▲6813.29 ▼1.404.79 ▲2.5240.57 ▼0.24
Dashboard /wp-admin2,209 ▲215.86 ▲0.97108.72 ▼5.5842.61 ▲3.06
Posts /wp-admin/edit.php2,089 ▼01.98 ▼0.0239.70 ▼0.9236.39 ▼2.18
Add New Post /wp-admin/post-new.php1,546 ▲2723.44 ▲0.57605.46 ▼5.1248.82 ▼6.25
Media Library /wp-admin/upload.php1,385 ▼34.26 ▲0.05100.98 ▲5.5442.59 ▼1.01

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

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
You still need to fix the following
  • Zombie WordPress options were found after uninstall: 6 options
    • db_upgraded
    • widget_theysaidso_widget
    • theysaidso_admin_options
    • widget_recent-comments
    • widget_recent-posts
    • can_compress_scripts

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no server-side errors were triggered
Even though no errors were found, this is by no means an exhaustive test

SRP 50% from 2 tests

🔹 Tests weight: 20 | SRP (Single-Responsibility Principle) - PHP files must act as libraries and never output text or perform any action when accessed directly in a browser
The following issues need your attention
  • 107× PHP files trigger errors when accessed directly with GET requests (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Exception' not found in wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/Braintree/Exception/ForgedQueryString.php:16
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Base' not found in wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/Braintree/ThreeDSecureInfo.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\PartialMatchNode' not found in wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/Braintree/TextNode.php:4
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Exception' not found in wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/Braintree/Exception/Timeout.php:12
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Instance' not found in wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/Braintree/Transaction/StatusDetails.php:18
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Base' not found in wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/Braintree/Transaction.php:214
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Collection' not found in wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/Braintree/Error/ValidationErrorCollection.php:19
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Base' not found in wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/Braintree/Merchant.php:4
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Base' not found in wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/Braintree/Result/Error.php:36
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Exception' not found in wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/Braintree/Exception/TooManyRequests.php:12

User-side errors Passed 1 test

🔹 Test weight: 20 | This is just a short smoke test looking for browser issues
Everything seems fine on the user side

Optimizations

Plugin configuration 96% from 29 tests

readme.txt Passed 16 tests

The readme.txt file is undoubtedly the most important file in your plugin, preparing it for public listing on WordPress.org
7 plugin tags: payments, payment gateway, woocommerce, credit card, braintreepayments...

woocommerce-braintree-payment-gateway/woocommerce-braintree-payment-gateway.php 92% from 13 tests

"WooCommerce Braintree Payment Gateway" version 1.9.5's main PHP file describes plugin functionality and also serves as the entry point to any WordPress functionality
Please take the time to fix the following:
  • Description: Keep the plugin description shorter than 140 characters (currently 173 characters long)

Code Analysis 5% from 3 tests

File types 0% from 1 test

🔸 Test weight: 35 | A short check of programming languages and file extensions; no executable files are allowed
It is important to fix the following items
  • Do not include executable or dangerous files in your plugin
    • .crt - Security Certificate in Firefox, IE, Chrome, Safari
      • wp-content/plugins/woocommerce-braintree-payment-gateway/includes/lib/ssl/api_braintreegateway_com.ca.crt
11,065 lines of code in 186 files:
LanguageFilesBlank linesComment linesLines of code
PHP1841,7775,17310,679
CSS14510247
JavaScript1113139

PHP code Passed 2 tests

A brief analysis of cyclomatic complexity and code structure for this plugin
Everything seems fine, there were no complexity issues found
Cyclomatic complexity
Average complexity per logical line of code0.18
Average class complexity4.78
▷ Minimum class complexity1.00
▷ Maximum class complexity62.00
Average method complexity1.66
▷ Minimum method complexity1.00
▷ Maximum method complexity33.00
Code structure
Namespaces10
Interfaces0
Traits0
Classes182
▷ Abstract classes21.10%
▷ Concrete classes18098.90%
▷ Final classes00.00%
Methods1,031
▷ Static methods44342.97%
▷ Public methods85983.32%
▷ Protected methods555.33%
▷ Private methods11711.35%
Functions8
▷ Named functions337.50%
▷ Anonymous functions562.50%
Constants808
▷ Global constants00.00%
▷ Class constants808100.00%
▷ Public constants808100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

All PNG images should be compressed to minimize bandwidth usage for end users
1 PNG file occupies 0.01MB with 0.00MB in potential savings
Potential savings
Compression of 1 random PNG file using pngquant
FileSize - originalSize - compressedSavings
public/images/cards.png5.35KB1.83KB▼ 65.70%