84% klarna-checkout-for-woocommerce

Code Review | Klarna Checkout for WooCommerce

WordPress plugin Klarna Checkout for WooCommerce scored84%from 54 tests.

About plugin

  • Plugin page: klarna-checkout-f...
  • Plugin version: 2.11.5
  • PHP compatiblity: 7.0+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.0.0-6.3
  • WordPress version: 6.3.1
  • First release: Dec 12, 2017
  • Latest release: Oct 9, 2023
  • Number of updates: 228
  • Update frequency: every 9.3 days
  • Top authors: klarna (78.95%)michaelbengtsson (21.49%)

Code review

54 tests

User reviews

9 reviews

Install metrics

20,000+ active /1,016,325 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | The install procedure must perform silently
This plugin's installer ran successfully

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

Analyzing server-side resources used by Klarna Checkout for WooCommerce
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /3.48 ▲0.0237.33 ▲0.62
Dashboard /wp-admin3.31 ▼0.0344.69 ▼11.50
Posts /wp-admin/edit.php3.36 ▲0.0144.48 ▲1.01
Add New Post /wp-admin/post-new.php5.90 ▲0.0177.70 ▼11.51
Media Library /wp-admin/upload.php3.24 ▲0.0133.25 ▼1.97

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

How much does this plugin use your filesystem and database?
There were no storage issued detected upon installing this plugin
Filesystem: 88 new files
Database: no new tables, 6 new options
New WordPress options
widget_recent-posts
can_compress_scripts
widget_theysaidso_widget
widget_recent-comments
theysaidso_admin_options
db_upgraded

Browser metrics Passed 4 tests

An overview of browser requirements for Klarna Checkout for WooCommerce
This plugin renders optimally with no browser resource issues detected
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,789 ▲2814.35 ▲0.001.60 ▼0.3838.23 ▼0.19
Dashboard /wp-admin2,198 ▲205.61 ▼0.2286.77 ▼13.0040.15 ▲0.07
Posts /wp-admin/edit.php2,097 ▼31.97 ▼0.0240.46 ▲5.6536.83 ▲1.55
Add New Post /wp-admin/post-new.php1,537 ▲118.17 ▼4.92614.82 ▼70.8577.49 ▲17.74
Media Library /wp-admin/upload.php1,403 ▲34.20 ▲0.0795.18 ▼14.2644.46 ▼2.11

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
The following items require your attention
  • This plugin does not fully uninstall, leaving 6 options in the database
    • can_compress_scripts
    • db_upgraded
    • widget_recent-posts
    • theysaidso_admin_options
    • widget_theysaidso_widget
    • widget_recent-comments

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 | The single-responsibility principle applies for WordPress plugins as well - please make sure your PHP files perform no actions when accessed directly
Please take a closer look at the following
  • 3× GET requests to PHP files have triggered server-side errors or warnings:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function do_action() in wp-content/plugins/klarna-checkout-for-woocommerce/templates/klarna-checkout.php:11
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/klarna-checkout-for-woocommerce/classes/class-kco-settings-saved.php:35
    • > PHP Fatal error
      Uncaught Error: Call to undefined function WC() in wp-content/plugins/klarna-checkout-for-woocommerce/templates/klarna-checkout-order-received.php:10

User-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the browser (console and network errors and warnings)
There were no browser issues found

Optimizations

Plugin configuration 93% 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 to be fixed: The official readme.txt might help

klarna-checkout-for-woocommerce/klarna-checkout-for-woocommerce.php 92% from 13 tests

Analyzing the main PHP file in "Klarna Checkout for WooCommerce" version 2.11.5
You should first fix the following items:
  • Requires at least: Required version must match the one declared in readme.txt ("4.0" instead of "4.0.0")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | There should be no dangerous file extensions present in any WordPress plugin
Everything looks great! No dangerous files found in this plugin10,173 lines of code in 65 files:
LanguageFilesBlank linesComment linesLines of code
PHP439842,5735,446
PO File101,3101,5103,415
CSS412650661
JavaScript58693600
SVG20046
JSON1005

PHP code Passed 2 tests

A short review of cyclomatic complexity and code structure
No cyclomatic complexity issues were detected for this plugin
Cyclomatic complexity
Average complexity per logical line of code0.44
Average class complexity19.41
▷ Minimum class complexity1.00
▷ Maximum class complexity89.00
Average method complexity3.58
▷ Minimum method complexity1.00
▷ Maximum method complexity21.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes39
▷ Abstract classes00.00%
▷ Concrete classes39100.00%
▷ Final classes00.00%
Methods279
▷ Static methods3913.98%
▷ Public methods24186.38%
▷ Protected methods165.73%
▷ Private methods227.89%
Functions25
▷ Named functions2496.00%
▷ Anonymous functions14.00%
Constants10
▷ Global constants660.00%
▷ Class constants440.00%
▷ Public constants4100.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
7 PNG files occupy 0.24MB with 0.14MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/img/icon_slice_it.png6.58KB3.06KB▼ 53.52%
assets/img/klarna_logo_white.png90.49KB22.92KB▼ 74.68%
assets/img/klarna_icons.png35.59KB10.30KB▼ 71.05%
assets/img/icon_pay_now.png5.95KB3.23KB▼ 45.66%
assets/img/icon_pay_later.png5.96KB3.30KB▼ 44.60%