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

Code Review | 51Degrees - Optimize by Device & Location

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

About plugin

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

Code review

54 tests

User reviews

1 review

Install metrics

10+ active / 232 total downloads

Benchmarks

Plugin footprint Passed 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
Install script ran successfully

Server metrics [RAM: ▲1.77MB] [CPU: ▼285.35ms] Passed 4 tests

A check of server-side resources used by 51Degrees - Optimize by Device & Location
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /5.34 ▲1.8263.81 ▲12.62
Dashboard /wp-admin5.18 ▲1.7741.37 ▲7.13
Posts /wp-admin/edit.php5.41 ▲1.7647.02 ▲11.27
Add New Post /wp-admin/post-new.php8.71 ▲1.74106.65 ▼1,159.41
Media Library /wp-admin/upload.php5.12 ▲1.8132.86 ▼0.38
51Degrees /wp-admin/options-general.php?page=51Degrees5.0930.52

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

Input-output and database impact of this plugin
No storage issues were detected
Filesystem: 3,265 new files
Database: no new tables, 2 new options
New WordPress options
fiftyonedegrees_resource_key
fiftyonedegrees_resource_key_pipeline

Browser metrics Passed 4 tests

A check of browser resources used by 51Degrees - Optimize by Device & Location
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,779 ▲2516.23 ▲0.387.09 ▲1.062.43 ▲0.03
Dashboard /wp-admin2,901 ▲386.49 ▲0.12118.80 ▼17.72154.97 ▼6.89
Posts /wp-admin/edit.php2,701 ▲103.44 ▲0.0163.55 ▲1.61140.47 ▼7.27
Add New Post /wp-admin/post-new.php1,680 ▼3117.40 ▼3.98393.22 ▼64.01158.73 ▼6.02
Media Library /wp-admin/upload.php1,712 ▲175.76 ▲0.06135.69 ▼14.38196.80 ▼1.15
51Degrees /wp-admin/options-general.php?page=51Degrees1,0662.8255.17113.86

Uninstaller [IO: ▲0.00MB] [DB: ▲0.00MB] Passed 4 tests

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
This plugin's uninstaller ran successfully

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 everything seems fine, this is not 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
The following issues need your attention
  • 3× PHP files perform the task of outputting text when accessed with GET requests:
    • > /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 'PhpParser\ode\\Expr' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php:7
    • > PHP Fatal error
      Uncaught Error: Class 'PhpParser\ode\\Expr\\BinaryOp' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php:7
    • > PHP Fatal error
      Uncaught Error: Interface 'PHPUnit\\TextUI\\XmlConfiguration\\Migration' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/phpunit/phpunit/src/TextUI/XmlConfiguration/Migration/Migrations/MoveWhitelistExcludesToCoverage.php:19
    • > 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/PostInc.php:7
    • > PHP Fatal error
      Uncaught Error: Class 'Monolog\\Formatter\ormalizerFormatter' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php:24
    • > PHP Fatal error
      Uncaught Error: Class 'phpseclib3\\Crypt\\EC\\BaseCurves\\Binary' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect283k1.php:21
    • > PHP Fatal error
      Uncaught Error: Class 'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\Reductions\\Barrett' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php:27
    • > PHP Fatal error
      Uncaught Error: Interface 'Hamcrest\\SelfDescribing' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Internal/SelfDescribingValue.php:13
    • > PHP Fatal error
      Uncaught Error: Interface 'SebastianBergmann\\CodeCoverage\\Exception' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/phpunit/php-code-coverage/src/Exception/DeadCodeDetectionNotSupportedException.php:14
    • > PHP Fatal error
      Uncaught Error: Class 'phpseclib3\\Crypt\\Common\\Formats\\Keys\\PuTTY' not found in wp-content/plugins/51degrees-optimize-by-device-location/lib/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php:29

User-side errors Passed 1 test

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

Optimizations

Plugin configuration 90% 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 your attention:
  • Tags: You are using too many tags: 25 tag instead of maximum 10
You can take inspiration from this readme.txt

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

"51Degrees - Optimize by Device & Location" version 1.0.14's primary PHP file adds more information about the plugin and serves as the entry point for WordPress
You should first fix the following items:
  • Main file name: It is recommended to name the main PHP file as the plugin slug ("51degrees-optimize-by-device-location.php" instead of "fiftyonedegrees.php")
  • Text Domain: If you choose to specify the text domain, it must be the same as the plugin slug; optional since WordPress version 4.6

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
Everything looks great! No dangerous files found in this plugin267,078 lines of code in 3,077 files:
LanguageFilesBlank linesComment linesLines of code
PHP2,57635,229107,098177,095
JavaScript1614,0304,20837,998
JSON8917029,208
Markdown1326,282015,711
yacc3326122,013
reStructuredText381,0461,3241,245
YAML36258861,241
XSD300962
HTML120454
XML24122395
Mustache1500392
CSS6367153
Python292180114
TypeScript114183
make1409
Bourne Shell1203
SVG2002

PHP code 50% from 2 tests

Analyzing cyclomatic complexity and code structure
The following items need your attention
  • Please reduce cyclomatic complexity of methods to less than 100 (currently 145)
Cyclomatic complexity
Average complexity per logical line of code0.34
Average class complexity7.67
▷ Minimum class complexity1.00
▷ Maximum class complexity661.00
Average method complexity2.25
▷ Minimum method complexity1.00
▷ Maximum method complexity145.00
Code structure
Namespaces269
Interfaces168
Traits57
Classes2,414
▷ Abstract classes29712.30%
▷ Concrete classes2,11787.70%
▷ Final classes59728.20%
Methods13,844
▷ Static methods1,82413.18%
▷ Public methods11,48782.97%
▷ Protected methods1,1188.08%
▷ Private methods1,2398.95%
Functions2,069
▷ Named functions59428.71%
▷ Anonymous functions1,47571.29%
Constants1,346
▷ Global constants302.23%
▷ Class constants1,31697.77%
▷ Public constants1,22693.16%

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