78% ad-inserter

Code Review | Ad Inserter - Ad Manager & AdSense Ads

WordPress plugin Ad Inserter - Ad Manager & AdSense Ads scored 78% from 54 tests.

About plugin

  • Plugin page: ad-inserter
  • Plugin version: 2.7.12
  • PHP compatiblity: 5.6+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.9-5.9
  • WordPress version: 5.9.2
  • First release: Nov 14, 2010
  • Latest release: Mar 10, 2022
  • Number of updates: 1,407
  • Update frequency: every 2.9 days
  • Top authors: spacetime (100%)

Code review

54 tests

User reviews

1924 reviews

Install metrics

200,000+ active / 10,380,229 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: ▲2.29MB] [CPU: ▼311.01ms] Passed 4 tests

A check of server-side resources used by Ad Inserter - Ad Manager & AdSense Ads
This plugin has minimal impact on server resources
PageMemory (MB)CPU Time (ms)
Home /5.87 ▲2.3688.25 ▲33.22
Dashboard /wp-admin5.69 ▲2.2869.67 ▼8.13
Posts /wp-admin/edit.php5.92 ▲2.2883.92 ▼16.06
Add New Post /wp-admin/post-new.php9.22 ▲2.25122.12 ▼1,247.08
Media Library /wp-admin/upload.php5.64 ▲2.3459.38 ▲27.25

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

Analyzing filesystem and database footprints of this plugin
There were no storage issued detected upon installing this plugin
Filesystem: 1,851 new files
Database: no new tables, 3 new options
New WordPress options
ai-install
dst_notification_times
widget_ai_widget

Browser metrics Passed 4 tests

A check of browser resources used by Ad Inserter - Ad Manager & AdSense Ads
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,892 ▲15015.94 ▲0.336.72 ▼0.552.35 ▲0.12
Dashboard /wp-admin2,963 ▲1026.24 ▲0.01129.50 ▼10.26190.23 ▲22.46
Posts /wp-admin/edit.php2,765 ▲773.31 ▲0.07107.09 ▲35.03172.02 ▲12.55
Add New Post /wp-admin/post-new.php1,708 ▲6817.41 ▼3.29426.03 ▼57.98215.18 ▲12.37
Media Library /wp-admin/upload.php1,768 ▲735.88 ▲0.34165.61 ▲16.37243.52 ▲0.48
Ad Inserter /wp-admin/ad-inserter.php260.940.0321.48

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

🔸 Tests weight: 35 | Checking the uninstaller removed all traces of the plugin
You still need to fix the following
  • This plugin did not uninstall successfully, leaving 3 options in the database
    • ai-install
    • dst_notification_times
    • widget_ai_widget

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | This is a short smoke test looking for server-side errors
The smoke test was a success, however most plugin functionality was not tested

SRP 50% 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
  • 808× PHP files trigger errors when accessed directly with GET requests (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Interface 'Psr\\Http\\Message\\StreamInterface' not found in wp-content/plugins/ad-inserter/includes/google-api-8/vendor/guzzlehttp/psr7/src/LazyOpenStream.php:13
    • > PHP Warning
      Class 'Google\\Http\\REST' not found in wp-content/plugins/ad-inserter/includes/google-api/src/aliases.php on line 33
    • > PHP Fatal error
      Uncaught Error: Class 'phpseclib3\\Crypt\\EC\\BaseCurves\\Prime' not found in wp-content/plugins/ad-inserter/includes/google-api-8/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php:34
    • > PHP Fatal error
      Uncaught Error: Class 'phpseclib3\\Crypt\\Common\\SymmetricKey' not found in wp-content/plugins/ad-inserter/includes/google-api/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/StreamCipher.php:25
    • > PHP Warning
      Class 'Google\\Service\\Exception' not found in wp-content/plugins/ad-inserter/includes/google-api-8/src/aliases.php on line 33
    • > PHP Warning
      Class 'Google\\Task\\Retryable' not found in wp-content/plugins/ad-inserter/includes/google-api-8/src/aliases.php on line 33
    • > PHP Fatal error
      Uncaught Error: Interface 'Psr\\Cache\\CacheException' not found in wp-content/plugins/ad-inserter/includes/google-api/vendor/psr/cache/src/InvalidArgumentException.php:11
    • > PHP Fatal error
      Uncaught Error: Class 'phpseclib3\\Math\\BigInteger\\Engines\\BCMath' not found in wp-content/plugins/ad-inserter/includes/google-api/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php:27
    • > PHP Fatal error
      Uncaught Error: Class 'phpseclib3\\Math\\BigInteger\\Engines\\OpenSSL' not found in wp-content/plugins/ad-inserter/includes/google-api/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php:27
    • > PHP Fatal error
      Uncaught Error: Class 'Monolog\\Handler\\AbstractProcessingHandler' not found in wp-content/plugins/ad-inserter/includes/google-api-8/vendor/monolog/monolog/src/Monolog/Handler/ElasticaHandler.php:37

User-side errors 0% from 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
There are user-side issues you should fix
    • > GET request to /wp-admin/ad-inserter.php
    • > Network (severe)
    wp-admin/ad-inserter.php - Failed to load resource: the server responded with a status of 404 (Not Found)

Optimizations

Plugin configuration 97% 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 your attention:
  • Tags: Please delete some tags, you are using 12 tag instead of maximum 10
The official readme.txt is a good inspiration

ad-inserter/ad-inserter.php Passed 13 tests

This is the main PHP file of "Ad Inserter - Ad Manager & AdSense Ads" version 2.7.12, providing information about the plugin in the header fields and serving as the principal entry point to the plugin's functions
88 characters long description:
Ad management with many advanced advertising features to insert ads at optimal positions

Code Analysis 95% 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 plugin204,693 lines of code in 1,278 files:
LanguageFilesBlank linesComment linesLines of code
PHP1,02125,98370,871147,504
PO File117,99510,58523,698
JavaScript1213,3452,55816,151
Markdown583,751010,851
JSON38003,845
CSS12465792,232
YAML6271164
Python24450149
XML50076
Dockerfile18010
make1409
Bourne Shell1203
HTML1001

PHP code 0% from 2 tests

A short review of cyclomatic complexity and code structure
The following items need your attention
  • Class cyclomatic complexity has to be reduced to less than 1000 (currently 2,536)
  • Cyclomatic complexity of methods has to be reduced to less than 100 (currently 579)
Cyclomatic complexity
Average complexity per logical line of code0.43
Average class complexity15.28
▷ Minimum class complexity1.00
▷ Maximum class complexity2,536.00
Average method complexity3.70
▷ Minimum method complexity1.00
▷ Maximum method complexity579.00
Code structure
Namespaces83
Interfaces90
Traits26
Classes1,326
▷ Abstract classes43332.65%
▷ Concrete classes89367.35%
▷ Final classes9210.30%
Methods7,709
▷ Static methods1,48619.28%
▷ Public methods5,89476.46%
▷ Protected methods84710.99%
▷ Private methods96812.56%
Functions753
▷ Named functions45460.29%
▷ Anonymous functions29939.71%
Constants2,444
▷ Global constants1,36855.97%
▷ Class constants1,07644.03%
▷ Public constants1,04396.93%

Plugin size Passed 2 tests

Image compression Passed 2 tests

All PNG images should be compressed to minimize bandwidth usage for end users
30 compressed PNG files occupy 0.14MB
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
images/ap-1.png8.07KB8.43KB0.00%
images/stars.png1.52KB1.49KB▼ 2.12%
css/images/switch.png0.53KB0.64KB0.00%
css/images/insertions-alignmets.png7.01KB5.67KB▼ 19.15%
css/images/icons.png6.09KB6.39KB0.00%