77% 51degrees-optimize-by-device-location

Code Review | 51Degrees - Optimize by Device & Location

WordPress plugin 51Degrees - Optimize by Device & Location scored77%from 54 tests.

About plugin

  • Plugin page: 51degrees-optimiz...
  • Plugin version: 4.4.1
  • PHP compatiblity: 5.6+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.7-5.9
  • WordPress version: 6.3.1
  • First release: Dec 15, 2021
  • Latest release: Apr 27, 2022
  • Number of updates: 41
  • Update frequency: every 3.5 days
  • Top authors: 51Degrees (100%)

Code review

54 tests

User reviews

1 review

Install metrics

10+ active /614 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | The install procedure must perform silently
The plugin installed gracefully, with no errors

Server metrics [RAM: ▲1.79MB] [CPU: ▼0.30ms] Passed 4 tests

Analyzing server-side resources used by 51Degrees - Optimize by Device & Location
Server-side resource usage in normal parameters
PageMemory (MB)CPU Time (ms)
Home /5.28 ▲1.8258.29 ▲16.52
Dashboard /wp-admin5.12 ▲1.8262.48 ▲0.14
Posts /wp-admin/edit.php5.17 ▲1.8258.36 ▼2.00
Add New Post /wp-admin/post-new.php7.67 ▲1.7893.28 ▼11.99
Media Library /wp-admin/upload.php4.98 ▲1.7648.56 ▲12.65
51Degrees /wp-admin/options-general.php?page=51Degrees4.9643.57

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

Filesystem and database footprint
The plugin installed successfully
Filesystem: 3,269 new files
Database: no new tables, 8 new options
New WordPress options
widget_recent-posts
db_upgraded
fiftyonedegrees_resource_key_pipeline
theysaidso_admin_options
can_compress_scripts
widget_recent-comments
fiftyonedegrees_resource_key
widget_theysaidso_widget

Browser metrics Passed 4 tests

Checking browser requirements for 51Degrees - Optimize by Device & Location
There were no issues detected in relation to browser resource usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,814 ▲4313.33 ▼1.021.69 ▼0.3342.39 ▼2.80
Dashboard /wp-admin2,218 ▲394.86 ▼0.95107.26 ▼18.9946.94 ▼1.52
Posts /wp-admin/edit.php2,098 ▲62.05 ▲0.0435.41 ▼9.4934.58 ▼1.41
Add New Post /wp-admin/post-new.php6,363 ▲4,83527.75 ▲9.39873.38 ▲249.2338.00 ▼16.87
Media Library /wp-admin/upload.php1,400 ▲154.21 ▲0.0196.59 ▼3.8042.78 ▼0.04
51Degrees /wp-admin/options-general.php?page=51Degrees8402.0924.8425.43

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

🔸 Tests weight: 35 | Checking the uninstaller removed all traces of the plugin
These items require your attention
  • This plugin does not fully uninstall, leaving 6 options in the database
    • theysaidso_admin_options
    • can_compress_scripts
    • db_upgraded
    • widget_theysaidso_widget
    • widget_recent-comments
    • widget_recent-posts

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)
Even though no errors were found, this is by no means an exhaustive test

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 fix the following items
  • 3× GET requests to PHP files return non-empty strings:
    • > /wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/nikic/php-parser/grammar/rebuildParsers.php
    • > /wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/antecedent/patchwork/src/Console.php
    • > /wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/mustache/mustache/bin/build_bootstrap.php
  • 1741× GET requests to PHP files trigger server-side errors or Error 500 responses (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\Constraint\\Constraint' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/phpunit/phpunit/src/Framework/Constraint/Boolean/IsFalse.php:15
    • > PHP Fatal error
      Uncaught Error: Class 'Hamcrest\\BaseMatcher' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/ShortcutCombination.php:12
    • > PHP Fatal error
      Uncaught Error: Interface 'Google\\Auth\\FetchAuthTokenInterface' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/google/auth/src/SignBlobInterface.php:23
    • > PHP Fatal error
      Uncaught Error: Interface 'PhpParser\\Builder' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'PhpParser\ode\\Expr\\Cast' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php:7
    • > PHP Fatal error
      Uncaught Error: Class 'Google\\Model' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/google/apiclient-services/src/GoogleAnalyticsAdmin/GoogleAnalyticsAdminV1alphaAcknowledgeUserDataCollectionRequest.php:20
    • > PHP Fatal error
      Uncaught Error: Class 'PhpParser\ode\\Expr\\Cast' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php:7
    • > PHP Fatal error
      Uncaught Error: Class 'PhpParser\ode\\Expr' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php:7
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\MockObject\\Rule\\InvocationOrder' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/phpunit/phpunit/src/Framework/MockObject/Rule/InvokedCount.php:19
    • > PHP Fatal error
      Uncaught Error: Class 'Monolog\\Handler\\Handler' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/monolog/monolog/src/Monolog/Handler/NoopHandler.php:23

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
Everything seems fine, but this is not an exhaustive test

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 94% from 16 tests

Often overlooked, readme.txt is one of the most important files in your plugin
These attributes need to be fixed:
  • Tags: There are too many tags (25 tag instead of maximum 10)
You can look at the official readme.txt

51degrees-optimize-by-device-location/fiftyonedegrees.php 85% from 13 tests

Analyzing the main PHP file in "51Degrees - Optimize by Device & Location" version 4.4.1
You should first fix the following items:
  • Main file name: Please rename the main PHP file in this plugin to the plugin slug ("51degrees-optimize-by-device-location.php" instead of "fiftyonedegrees.php")
  • Text Domain: You no longer need to specify the text domain since WordPress 4.6; it must be the same as the plugin slug

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | Executable files are not allowed as they can serve as attack vectors
Success! There were no dangerous files found in this plugin267,974 lines of code in 3,079 files:
LanguageFilesBlank linesComment linesLines of code
PHP2,57735,276107,363177,541
JavaScript1614,0404,21538,299
JSON8917029,212
Markdown1326,311015,771
yacc3326122,013
YAML37260871,326
reStructuredText381,0461,3241,245
XSD300962
HTML120454
XML24122395
Mustache1500392
CSS6367153
Python292180114
TypeScript114183
make1409
Bourne Shell1203
SVG2002

PHP code 50% from 2 tests

This is a very shot review of cyclomatic complexity and code structure
Please fix the following
  • Cyclomatic complexity of methods has to be reduced to less than 100 (currently 145)
Cyclomatic complexity
Average complexity per logical line of code0.34
Average class complexity7.69
▷ Minimum class complexity1.00
▷ Maximum class complexity662.00
Average method complexity2.26
▷ Minimum method complexity1.00
▷ Maximum method complexity145.00
Code structure
Namespaces269
Interfaces168
Traits57
Classes2,415
▷ Abstract classes29712.30%
▷ Concrete classes2,11887.70%
▷ Final classes59828.23%
Methods13,859
▷ Static methods1,82513.17%
▷ Public methods11,49982.97%
▷ Protected methods1,1198.07%
▷ Private methods1,2418.95%
Functions2,069
▷ Named functions59428.71%
▷ Anonymous functions1,47571.29%
Constants1,352
▷ Global constants302.22%
▷ Class constants1,32297.78%
▷ Public constants1,22592.66%

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.38MB with 0.24MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/images/screenshot-1.png65.88KB20.30KB▼ 69.18%
assets/images/screenshot-5.png53.62KB16.68KB▼ 68.90%
assets/images/icon-256x256.png33.75KB12.55KB▼ 62.80%
assets/images/screenshot-2.png85.84KB29.74KB▼ 65.36%
assets/images/logo.png8.80KB4.02KB▼ 54.29%