78% stats4wp

Code Review | stats4wp

WordPress plugin stats4wp scored 78% from 54 tests.

About plugin

  • Plugin page: stats4wp
  • Plugin version: 1.3.3
  • PHP compatiblity: 7.4+
  • PHP version: 7.4.16
  • WordPress compatibility: 5.2-5.9
  • WordPress version: 5.9.2
  • First release: Oct 28, 2021
  • Latest release: Apr 3, 2022
  • Number of updates: 17
  • Update frequency: every 9.4 days
  • Top authors: vanhoucke (100%)

Code review

54 tests

User reviews

1 review

Install metrics

10+ active / 592 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | All plugins must install correctly, without throwing any errors, warnings, or notices
Install script ran successfully

Server metrics [RAM: ▲3.67MB] [CPU: ▼272.13ms] Passed 4 tests

Server-side resources used by stats4wp
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /7.22 ▲3.70127.55 ▲66.84
Dashboard /wp-admin7.07 ▲3.6681.04 ▲41.66
Posts /wp-admin/edit.php7.35 ▲3.7166.92 ▲25.87
Add New Post /wp-admin/post-new.php10.59 ▲3.62127.64 ▼1,172.13
Media Library /wp-admin/upload.php7.01 ▲3.7262.91 ▲16.08
Pages /wp-admin/admin.php?page=stats4wp_pages7.0861.74
Dashboard /wp-admin/admin.php?page=stats4wp_plugin7.1069.50
Settings /wp-admin/admin.php?page=stats4wp_settings7.0351.03
CSV Export /wp-admin/admin.php?page=stats4wp_cvsexport7.0050.40
Visitors /wp-admin/admin.php?page=stats4wp_visitors7.1161.47

Server storage [IO: ▲11.26MB] [DB: ▲0.01MB] Passed 3 tests

A short overview of filesystem and database impact
No storage issues were detected
Filesystem: 295 new files
Database: 3 new tables, 2 new options
New tables
wp_stats4wp_useronline
wp_stats4wp_visitor
wp_stats4wp_pages
New WordPress options
widget_stats4wp_cpt_visitors_widget
stats4wp_plugin

Browser metrics Passed 4 tests

An overview of browser requirements for stats4wp
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /4,029 ▲30716.33 ▲0.818.38 ▲1.033.47 ▲0.70
Dashboard /wp-admin3,118 ▲2417.51 ▲1.15159.52 ▼8.20199.22 ▲10.82
Posts /wp-admin/edit.php2,766 ▲753.42 ▼0.0079.07 ▲6.12163.25 ▼3.63
Add New Post /wp-admin/post-new.php1,799 ▲15922.94 ▲2.57529.87 ▼41.98182.28 ▼17.96
Media Library /wp-admin/upload.php1,777 ▲856.23 ▲0.51161.58 ▼34.29231.28 ▼53.84
Pages /wp-admin/admin.php?page=stats4wp_pages1,4823.4866.97174.44
Dashboard /wp-admin/admin.php?page=stats4wp_plugin2,3745.64211.40295.57
Settings /wp-admin/admin.php?page=stats4wp_settings2,0393.5164.87175.29
CSV Export /wp-admin/admin.php?page=stats4wp_cvsexport1,2653.3569.46142.99
Visitors /wp-admin/admin.php?page=stats4wp_visitors1,9165.73302.95176.49

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
The following items require your attention
  • The uninstall procedure has failed, leaving 1 option in the database
    • widget_stats4wp_cpt_visitors_widget

Smoke tests 50% 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 0% 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
Almost there! Just fix the following items
  • 5× PHP files perform the task of outputting text when accessed with GET requests:
    • > /wp-content/plugins/stats4wp/templates-part/footer.php
    • > /wp-content/plugins/stats4wp/vendor/whichbrowser/parser/bin/update-profiles.php
    • > /wp-content/plugins/stats4wp/vendor/whichbrowser/parser/bin/update-browser-ids.php
    • > /wp-content/plugins/stats4wp/vendor/whichbrowser/parser/bin/update-chrome.php
    • > /wp-content/plugins/stats4wp/stats4wp.php
  • 122× PHP files trigger server errors when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'WhichBrowser\\Data\\BuildIds' not found in wp-content/plugins/stats4wp/vendor/whichbrowser/parser/data/build-android.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'WhichBrowser\\Data\\DeviceModels' not found in wp-content/plugins/stats4wp/vendor/whichbrowser/parser/data/indices/models-bada.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'WhichBrowser\\Model\\Primitive\\Base' not found in wp-content/plugins/stats4wp/vendor/whichbrowser/parser/src/Model/Version.php:7
    • > PHP Fatal error
      Trait 'WhichBrowser\\Analyser\\Header\\Useragent\\Os' not found in wp-content/plugins/stats4wp/vendor/whichbrowser/parser/src/Analyser/Header/Useragent.php on line 5
    • > PHP Fatal error
      Uncaught Error: Class 'WhichBrowser\\Constants\\DeviceType' not found in wp-content/plugins/stats4wp/vendor/whichbrowser/parser/data/models-ios.php:10
    • > PHP Fatal error
      Uncaught Error: Class 'WhichBrowser\\Data\\DeviceModels' not found in wp-content/plugins/stats4wp/vendor/whichbrowser/parser/data/indices/models-wm.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'WhichBrowser\\Data\\DeviceModels' not found in wp-content/plugins/stats4wp/vendor/whichbrowser/parser/data/models-brew.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'STATS4WP\\Core\\BaseController' not found in wp-content/plugins/stats4wp/inc/Ui/Pages.php:16
    • > PHP Fatal error
      Uncaught Error: Class 'WhichBrowser\\Data\\DeviceModels' not found in wp-content/plugins/stats4wp/vendor/whichbrowser/parser/data/models-s40.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'STATS4WP\\Core\\DB' not found in wp-content/plugins/stats4wp/templates-part/visitor/location.php:16

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)
No browser issues were found

Optimizations

Plugin configuration 97% 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:
  • Tags: You are using too many tags: 29 tag instead of maximum 10
The official readme.txt is a good inspiration

stats4wp/stats4wp.php Passed 13 tests

The primary PHP file in "stats4wp" version 1.3.3 is used by WordPress to initiate all plugin functionality
24 characters long description:
Statistics For WorPress.

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short review of files and their extensions; it is not recommended to include executable files
No dangerous file extensions were detected76,322 lines of code in 237 files:
LanguageFilesBlank linesComment linesLines of code
PHP2134,9782,42559,859
JavaScript4834213,257
PO File2406496889
Markdown63460740
C111825668
CSS413654525
JSON470285
XML14059
m418032
C/C++ Header14128

PHP code 50% from 2 tests

Cyclomatic complexity and code structure are the fingerprint of this plugin
The following items need your attention
  • Please reduce cyclomatic complexity of methods to less than 100 (currently 107)
Cyclomatic complexity
Average complexity per logical line of code0.46
Average class complexity25.58
▷ Minimum class complexity1.00
▷ Maximum class complexity484.00
Average method complexity6.72
▷ Minimum method complexity1.00
▷ Maximum method complexity107.00
Code structure
Namespaces20
Interfaces4
Traits25
Classes79
▷ Abstract classes00.00%
▷ Concrete classes79100.00%
▷ Final classes11.27%
Methods472
▷ Static methods8918.86%
▷ Public methods26155.30%
▷ Protected methods00.00%
▷ Private methods21144.70%
Functions28
▷ Named functions1346.43%
▷ Anonymous functions1553.57%
Constants103
▷ Global constants65.83%
▷ Class constants9794.17%
▷ Public constants8183.51%

Plugin size 50% from 2 tests

Image compression 50% from 2 tests

It is recommended to compress PNG files in your plugin to minimize bandwidth usage
46 PNG files occupy 0.82MB with 0.22MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/images/screenshot-6.png11.07KB6.50KB▼ 41.30%
assets/images/logo-menu.png11.84KB0.81KB▼ 93.14%
assets/images/search-engine/clearch.png0.29KB0.29KB0.00%
assets/images/browser/Firefox%20Mobile.png0.80KB0.88KB0.00%
assets/images/browser/UC%20Browser.png0.80KB0.93KB0.00%