77% sparrow

Code Review | Sparrow: Product Reviews and Ratings for WooCommerce

WordPress plugin Sparrow: Product Reviews and Ratings for WooCommerce scored 77% from 54 tests.

About plugin

  • Plugin page: sparrow
  • Plugin version: 2.0.2
  • PHP version: 7.4.16
  • WordPress compatibility: 4.0-5.6
  • WordPress version: 5.9.2
  • First release: May 31, 2019
  • Latest release: Jan 22, 2021
  • Number of updates: 56
  • Update frequency: every 10.9 days
  • Top authors: getsparrow (100%)

Code review

54 tests

User reviews

1 review

Install metrics

10+ active / 953 total downloads

Benchmarks

Plugin footprint 82% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
This plugin's installer ran successfully

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

A check of server-side resources used by Sparrow: Product Reviews and Ratings for WooCommerce
It is recommended to improve the following
  • CPU: Try to keep total CPU usage under 500.00ms (currently 1,622.50ms on /wp-admin/options-general.php?page=getsparrow)
PageMemory (MB)CPU Time (ms)
Home /8.62 ▲5.11107.18 ▲33.75
Dashboard /wp-admin8.64 ▲5.2385.51 ▲38.62
Posts /wp-admin/edit.php8.64 ▲5.0091.18 ▲28.87
Add New Post /wp-admin/post-new.php10.80 ▲3.83160.94 ▼1,147.53
Media Library /wp-admin/upload.php8.64 ▲5.3581.59 ▲33.75
Freemius Debug [v.2.4.1] /wp-admin/admin.php?page=freemius8.6466.38
Sparrow /wp-admin/options-general.php?page=getsparrow8.641,622.50

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

Filesystem and database footprint
This plugin installed successfully
Filesystem: 389 new files
Database: no new tables, 5 new options
New WordPress options
fs_active_plugins
fs_accounts
woocommerce_enable_reviews
fs_gdpr
fs_debug_mode

Browser metrics Passed 4 tests

Sparrow: Product Reviews and Ratings for WooCommerce: an overview of browser usage
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /4,015 ▲26116.95 ▲1.4649.70 ▲40.772.74 ▼0.94
Dashboard /wp-admin2,990 ▲1306.21 ▲0.10165.42 ▼4.77231.91 ▲7.44
Posts /wp-admin/edit.php2,783 ▲923.22 ▼0.0288.68 ▲10.15204.78 ▲15.26
Add New Post /wp-admin/post-new.php1,716 ▲4816.50 ▼2.28632.52 ▼124.33228.35 ▼26.73
Media Library /wp-admin/upload.php1,791 ▲965.57 ▲0.04210.05 ▼30.37283.82 ▼30.00
Freemius Debug [v.2.4.1] /wp-admin/admin.php?page=freemius1,4392.5376.43144.68
Sparrow /wp-admin/options-general.php?page=getsparrow1,2892.6164.50196.89

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

🔸 Tests weight: 35 | Checking the uninstaller removed all traces of the plugin
Please fix the following items
  • Zombie WordPress options were found after uninstall: 5 options
    • fs_active_plugins
    • fs_accounts
    • fs_debug_mode
    • fs_gdpr
    • woocommerce_enable_reviews

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the server (in the Apache logs)
Good news, no errors were detected

SRP 0% 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
  • 1× PHP files perform the action of outputting non-empty strings when accessed directly:
    • > /wp-content/plugins/sparrow/freemius/templates/ajax-loader.php
  • 108× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'Doctrine\\Common\\Cache\\CacheProvider' not found in wp-content/plugins/sparrow/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php:38
    • > PHP Fatal error
      Uncaught Error: Call to undefined function get_option() in wp-content/plugins/sparrow/public/partials/getsparrow-public-display.php:20
    • > PHP Notice
      Trying to access array offset on value of type null in wp-content/plugins/sparrow/freemius/templates/account/partials/addon.php on line 7
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/sparrow/vendor/kevinrob/guzzle-cache-middleware/tests/Strategy/GreedyCacheStrategyTest.php:15
    • > PHP Fatal error
      Uncaught Error: Interface 'GuzzleHttp\\Promise\\PromiseInterface' not found in wp-content/plugins/sparrow/vendor/guzzlehttp/promises/src/FulfilledPromise.php:10
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/sparrow/vendor/kevinrob/guzzle-cache-middleware/tests/ResponseAgeTest.php:13
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/sparrow/vendor/kevinrob/guzzle-cache-middleware/tests/InvalidateCacheTest.php:12
    • > PHP Fatal error
      Uncaught Error: Class 'Doctrine\\Common\\Cache\\FileCache' not found in wp-content/plugins/sparrow/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php:17
    • > PHP Fatal error
      Uncaught Error: Interface 'Kevinrob\\GuzzleCache\\Storage\\CacheStorageInterface' not found in wp-content/plugins/sparrow/vendor/kevinrob/guzzle-cache-middleware/src/Storage/Psr6CacheStorage.php:9
    • > PHP Fatal error
      Uncaught Error: Interface 'Kevinrob\\GuzzleCache\\Storage\\CacheStorageInterface' not found in wp-content/plugins/sparrow/vendor/kevinrob/guzzle-cache-middleware/src/Storage/CompressedDoctrineCacheStorage.php:8

User-side errors Passed 1 test

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

Optimizations

Plugin configuration 83% from 29 tests

readme.txt 81% 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
Attributes that need to be fixed:
  • Donate link: Invalid URI found ("")
  • Requires php: The plugin version is formatted incorrectly
  • Screenshots: Please add descriptions for these screenshots #2, #3, #4 in sparrow/assets to your readme.txt
You can take inspiration from this readme.txt

sparrow/getsparrow.php 85% from 13 tests

"Sparrow: Product Reviews and Ratings for WooCommerce" version 2.0.2's primary PHP file adds more information about the plugin and serves as the entry point for WordPress
Please make the necessary changes and fix the following:
  • Main file name: Even though not officially enforced, the main plugin file should be the same as the plugin slug ("sparrow.php" instead of "getsparrow.php")
  • Text Domain: The text domain must be the same as the plugin slug, although optional since WordPress version 4.6

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | Executable files are considered dangerous and should not be included with any WordPress plugin
No dangerous file extensions were detected48,186 lines of code in 330 files:
LanguageFilesBlank linesComment linesLines of code
PHP28110,19023,30143,362
Markdown141,13803,695
JSON1000794
JavaScript538113200
YAML314058
XML29044
CSS130814
Dockerfile18010
make1409

PHP code 50% from 2 tests

Analyzing cyclomatic complexity and code structure
The following items need your attention
  • Please reduce cyclomatic complexity of classes to less than 1000 (currently 2,895)
Cyclomatic complexity
Average complexity per logical line of code0.55
Average class complexity27.80
▷ Minimum class complexity1.00
▷ Maximum class complexity2,895.00
Average method complexity3.57
▷ Minimum method complexity1.00
▷ Maximum method complexity86.00
Code structure
Namespaces15
Interfaces25
Traits2
Classes174
▷ Abstract classes42.30%
▷ Concrete classes17097.70%
▷ Final classes116.47%
Methods2,214
▷ Static methods25111.34%
▷ Public methods1,55070.01%
▷ Protected methods1948.76%
▷ Private methods47021.23%
Functions267
▷ Named functions15457.68%
▷ Anonymous functions11342.32%
Constants216
▷ Global constants9945.83%
▷ Class constants11754.17%
▷ Public constants11396.58%

Plugin size Passed 2 tests

Image compression Passed 2 tests

All PNG images should be compressed to minimize bandwidth usage for end users
3 PNG files occupy 0.02MB with 0.01MB in potential savings
Potential savings
Compression of 3 random PNG files using pngquant
FileSize - originalSize - compressedSavings
freemius/assets/img/plugin-icon.png9.16KB5.26KB▼ 42.58%
freemius/assets/img/sparrow.png3.13KB1.83KB▼ 41.53%
freemius/assets/img/theme-icon.png10.97KB5.78KB▼ 47.37%