68% randomad

Code Review | RandomAd

WordPress plugin RandomAd scored68%from 54 tests.

About plugin

  • Plugin page: randomad
  • Plugin version: 1.0.0
  • PHP version: 7.4.16
  • WordPress version: 6.3.1
  • First release: Feb 9, 2018
  • Latest release: Feb 9, 2018
  • Number of updates: 3
  • Update frequency: N/A
  • Top authors: tokuhausu (100%)

Code review

54 tests

User reviews

1 review

Install metrics

10+ active /534 total downloads

Benchmarks

Plugin footprint 65% 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: ▲0.08MB] [CPU: ▼5.70ms] Passed 4 tests

Analyzing server-side resources used by RandomAd
This plugin has minimal impact on server resources
PageMemory (MB)CPU Time (ms)
Home /3.52 ▲0.0637.82 ▼2.58
Dashboard /wp-admin3.41 ▲0.0644.47 ▼16.70
Posts /wp-admin/edit.php3.52 ▲0.1649.44 ▲4.46
Add New Post /wp-admin/post-new.php5.99 ▲0.1086.07 ▼6.27
Media Library /wp-admin/upload.php3.33 ▲0.1036.79 ▲2.76
RandomAds /wp-admin/admin.php?page=randomads3.3032.13
広告一覧 /wp-admin/admin.php?page=randomads-ads3.3033.69
カテゴリー /wp-admin/admin.php?page=randomads-category3.2726.55
RandomAdsプラグインの管理画面 /wp-admin/options-general.php?page=randomads-config3.3030.85
広告を追加 /wp-admin/admin.php?page=randomads-add-newad3.3029.36

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

Analyzing filesystem and database footprints of this plugin
This plugin installed successfully
Filesystem: 14 new files
Database: 2 new tables, 7 new options
New tables
wp_randomad_ad
wp_randomad_cat
New WordPress options
can_compress_scripts
widget_theysaidso_widget
theysaidso_admin_options
widget_recent-comments
widget_widget-template
widget_recent-posts
db_upgraded

Browser metrics Passed 4 tests

An overview of browser requirements for RandomAd
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,835 ▲8913.61 ▼0.821.75 ▼0.0441.85 ▲2.06
Dashboard /wp-admin2,238 ▲535.84 ▼0.0398.09 ▼4.4643.81 ▲2.38
Posts /wp-admin/edit.php2,121 ▲322.05 ▼0.0136.29 ▲1.9938.96 ▲5.70
Add New Post /wp-admin/post-new.php1,564 ▲5023.16 ▲5.67616.91 ▼63.2359.02 ▲2.09
Media Library /wp-admin/upload.php1,423 ▲414.26 ▼0.1295.44 ▼3.0246.13 ▲3.71
RandomAds /wp-admin/admin.php?page=randomads7822.0323.2927.65
広告一覧 /wp-admin/admin.php?page=randomads-ads8522.0324.4755.97
カテゴリー /wp-admin/admin.php?page=randomads-category9082.0523.0760.38
RandomAdsプラグインの管理画面 /wp-admin/options-general.php?page=randomads-config7882.0323.5644.64
広告を追加 /wp-admin/admin.php?page=randomads-add-newad8692.0222.8247.85

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

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
Please fix the following items
  • The uninstall procedure failed, leaving 2 tables in the database
    • wp_randomad_ad
    • wp_randomad_cat
  • This plugin does not fully uninstall, leaving 7 options in the database
    • widget_theysaidso_widget
    • can_compress_scripts
    • theysaidso_admin_options
    • db_upgraded
    • widget_recent-comments
    • widget_recent-posts
    • widget_widget-template

Smoke tests 50% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | A shallow check that no server-side errors were triggered
Almost there, just fix the following server-side errors
    • > GET request to /wp-admin/admin.php?page=randomads-category
    • > Warning in wp-content/plugins/randomad/page.php+190
    Use of undefined constant cat_id - assumed 'cat_id' (this will throw an Error in a future version of PHP)
    • > GET request to /wp-admin/admin.php?page=randomads-category
    • > Notice in wp-content/plugins/randomad/page.php+190
    Undefined index: cat_id

SRP 50% from 2 tests

🔹 Tests weight: 20 | It is important to ensure that your PHP files perform no action when accessed directly, respecting the single-responsibility principle
Please take a closer look at the following
  • 3× PHP files trigger server-side errors or warnings when accessed directly:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugin_dir_path() in wp-content/plugins/randomad/TO_RandomAd.php:29
    • > PHP Fatal error
      Uncaught Error: Class 'WP_Widget' not found in wp-content/plugins/randomad/widget.php:3
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_shortcode() in wp-content/plugins/randomad/ShortCoad.php:39

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a smoke test targeting browser errors/issues
No browser errors were detected

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 88% from 16 tests

Often overlooked, readme.txt is one of the most important files in your plugin
These attributes need your attention:
  • Requires at least: Invalid version format
  • Screenshots: Please add images for these screenshots: #1 (Ad List on menu.), #2 (Widget of this plugin.), #3 (Widget), #4 (Plugin menu.)
The official readme.txt might help

randomad/TO_RandomAd.php 92% from 13 tests

The primary PHP file in "RandomAd" version 1.0.0 is used by WordPress to initiate all plugin functionality
It is important to fix the following:
  • Main file name: The principal plugin file should be the same as the plugin slug ("randomad.php" instead of "TO_RandomAd.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short check of programming languages and file extensions; no executable files are allowed
Good job! No executable or dangerous file extensions detected788 lines of code in 9 files:
LanguageFilesBlank linesComment linesLines of code
PHP77170686
CSS200102

PHP code Passed 2 tests

An short overview of logical lines of code, cyclomatic complexity, and other code metrics
Although this was not an exhaustive test, there were no cyclomatic complexity issues detected
Cyclomatic complexity
Average complexity per logical line of code0.14
Average class complexity5.50
▷ Minimum class complexity4.00
▷ Maximum class complexity7.00
Average method complexity2.12
▷ Minimum method complexity1.00
▷ Maximum method complexity6.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes2
▷ Abstract classes00.00%
▷ Concrete classes2100.00%
▷ Final classes00.00%
Methods8
▷ Static methods00.00%
▷ Public methods8100.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions34
▷ Named functions3397.06%
▷ Anonymous functions12.94%
Constants0
▷ Global constants00.00%
▷ Class constants00.00%
▷ Public constants00.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

PNG files should be compressed to save space and minimize bandwidth usage
4 PNG files occupy 0.06MB with 0.02MB in potential savings
Potential savings
Compression of 4 random PNG files using pngquant
FileSize - originalSize - compressedSavings
screenshot-4.png2.66KB1.90KB▼ 28.60%
screenshot-1.png41.59KB21.08KB▼ 49.31%
screenshot-3.png5.21KB2.91KB▼ 44.27%
screenshot-2.png11.99KB7.13KB▼ 40.52%