84% klarna-payments-for-woocommerce

Code Review | Klarna Payments for WooCommerce

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

About plugin

  • Plugin page: klarna-payments-f...
  • Plugin version: 3.2.3
  • PHP compatiblity: 7.4+
  • PHP version: 7.4.16
  • WordPress compatibility: 5.6.0-6.3.2
  • WordPress version: 6.3.1
  • First release: Dec 12, 2017
  • Latest release: Nov 7, 2023
  • Number of updates: 151
  • Update frequency: every 14.4 days
  • Top authors: klarna (67.55%)michaelbengtsson (33.11%)

Code review

54 tests

User reviews

14 reviews

Install metrics

30,000+ active /936,278 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | It is important to correctly install your plugin, without throwing errors or notices
The plugin installed gracefully, with no errors

Server metrics [RAM: ▲0.11MB] [CPU: ▼1.81ms] Passed 4 tests

This is a short check of server-side resources used by Klarna Payments for WooCommerce
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /3.57 ▲0.1136.77 ▼4.39
Dashboard /wp-admin3.41 ▲0.1146.27 ▼6.41
Posts /wp-admin/edit.php3.52 ▲0.1750.62 ▲6.16
Add New Post /wp-admin/post-new.php5.99 ▲0.1095.27 ▲1.67
Media Library /wp-admin/upload.php3.33 ▲0.1035.93 ▲1.88

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

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

Browser metrics Passed 4 tests

An overview of browser requirements for Klarna Payments for WooCommerce
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,796 ▲3414.29 ▼0.051.62 ▲0.0240.07 ▼5.23
Dashboard /wp-admin2,198 ▲215.51 ▼0.1489.12 ▼12.4139.61 ▼5.73
Posts /wp-admin/edit.php2,107 ▲71.96 ▲0.0239.97 ▲2.2437.07 ▲3.12
Add New Post /wp-admin/post-new.php1,532 ▲623.17 ▼0.00678.88 ▲41.9654.18 ▲4.02
Media Library /wp-admin/upload.php1,409 ▲64.17 ▼0.01100.24 ▲4.6943.50 ▲2.64

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

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
It is recommended to fix the following
  • Zombie WordPress options were found after uninstall: 6 options
    • theysaidso_admin_options
    • can_compress_scripts
    • db_upgraded
    • widget_theysaidso_widget
    • widget_recent-posts
    • 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
The smoke test was a success, however most plugin functionality was not tested

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
The following issues need your attention
  • 22× PHP files trigger errors when accessed directly with GET requests (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/klarna-payments-for-woocommerce/classes/class-kp-settings-saved.php:33
    • > PHP Fatal error
      Uncaught Error: Class 'Krokedil\\WooCommerce\\Base' not found in wp-content/plugins/klarna-payments-for-woocommerce/vendor/krokedil/woocommerce/src/OrderData.php:15
    • > PHP Fatal error
      Uncaught Error: Class 'Krokedil\\WooCommerce\\OrderLineData' not found in wp-content/plugins/klarna-payments-for-woocommerce/vendor/krokedil/woocommerce/src/Cart/CartLineItem.php:13
    • > PHP Fatal error
      Uncaught Error: Class 'Krokedil\\WooCommerce\\OrderLineData' not found in wp-content/plugins/klarna-payments-for-woocommerce/vendor/krokedil/woocommerce/src/Order/OrderLine.php:13
    • > PHP Fatal error
      Uncaught Error: Class 'Krokedil\\WooCommerce\\Order\\OrderLine' not found in wp-content/plugins/klarna-payments-for-woocommerce/vendor/krokedil/woocommerce/src/Order/OrderLineShipping.php:11
    • > PHP Fatal error
      Uncaught Error: Call to undefined function kp_is_order_pay_page() in wp-content/plugins/klarna-payments-for-woocommerce/templates/klarna-payments-categories.php:7
    • > PHP Fatal error
      Uncaught Error: Class 'Krokedil\\WooCommerce\\OrderData' not found in wp-content/plugins/klarna-payments-for-woocommerce/vendor/krokedil/woocommerce/src/Order/Order.php:15
    • > PHP Fatal error
      Uncaught Error: Class 'Krokedil\\WooCommerce\\CustomerData' not found in wp-content/plugins/klarna-payments-for-woocommerce/vendor/krokedil/woocommerce/src/StoreApi/StoreApiCustomer.php:15
    • > PHP Fatal error
      Uncaught Error: Class 'Krokedil\\WooCommerce\\Order\\OrderLine' not found in wp-content/plugins/klarna-payments-for-woocommerce/vendor/krokedil/woocommerce/src/Order/OrderLineFee.php:11
    • > PHP Fatal error
      Uncaught Error: Class 'Krokedil\\WooCommerce\\CustomerData' not found in wp-content/plugins/klarna-payments-for-woocommerce/vendor/krokedil/woocommerce/src/Order/OrderCustomer.php:15

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)
Everything seems fine, but this is not an exhaustive test

Optimizations

Plugin configuration 93% from 29 tests

readme.txt 94% from 16 tests

The readme.txt file uses markdown syntax to describe your plugin to the world
Attributes that require attention: You can take inspiration from this readme.txt

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

The primary PHP file in "Klarna Payments for WooCommerce" version 3.2.3 is used by WordPress to initiate all plugin functionality
Please make the necessary changes and fix the following:
  • Requires at least: Required version must match the one declared in readme.txt ("5.0" instead of "5.6.0")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | This is an overview of file extensions present in this plugin and a short test that no dangerous files are bundled with this plugin
Good job! No executable or dangerous file extensions detected9,894 lines of code in 121 files:
LanguageFilesBlank linesComment linesLines of code
PHP711,5514,8636,200
PO File105601,3301,525
SVG26560857
JavaScript697126585
CSS410438576
JSON10094
Markdown237053
Sass1004

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.25
Average class complexity10.26
▷ Minimum class complexity1.00
▷ Maximum class complexity58.00
Average method complexity1.94
▷ Minimum method complexity1.00
▷ Maximum method complexity21.00
Code structure
Namespaces8
Interfaces0
Traits0
Classes61
▷ Abstract classes813.11%
▷ Concrete classes5386.89%
▷ Final classes00.00%
Methods653
▷ Static methods7110.87%
▷ Public methods60192.04%
▷ Protected methods192.91%
▷ Private methods335.05%
Functions24
▷ Named functions1770.83%
▷ Anonymous functions729.17%
Constants10
▷ Global constants660.00%
▷ Class constants440.00%
▷ Public constants4100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
7 PNG files occupy 0.24MB with 0.15MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/img/klarna_logo_black.png86.90KB22.92KB▼ 73.63%
assets/img/icon_slice_it.png6.58KB3.06KB▼ 53.52%
assets/img/icon_pay_now.png5.95KB3.23KB▼ 45.66%
assets/img/klarna_logo_white.png90.49KB22.92KB▼ 74.68%
assets/img/klarna_icons.png35.59KB10.30KB▼ 71.05%