74% htaccess-ip-block

Code Review | <.htaccess> IP block

WordPress plugin <.htaccess> IP block scored 74% from 54 tests.

About plugin

  • Plugin page: htaccess-ip-block
  • Plugin version: 1.0
  • PHP version: 7.4.16
  • WordPress version: 5.8.1
  • First release: Oct 12, 2016
  • Latest release: Oct 16, 2016
  • Number of updates: 8
  • Update frequency: every 0.5 days
  • Top authors: EazyServer (100%)

Code review

54 tests

User reviews

2 reviews

Install metrics

10+ active / 1,027 total downloads

Benchmarks

Plugin footprint 65% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
The plugin installed successfully, without throwing any errors or notices

Server metrics [RAM: ▲0.20MB] [CPU: ▼139.79ms] Passed 4 tests

An overview of server-side resources used by <.htaccess> IP block
Normal server usage
PageMemory (MB)CPU Time (ms)
Home /3.00 ▲0.2833.22 ▲11.45
Dashboard /wp-admin3.29 ▲0.2455.54 ▲9.15
Posts /wp-admin/edit.php3.34 ▲0.2352.24 ▲2.08
Add New Post /wp-admin/post-new.php5.59 ▲0.1691.89 ▼574.31
Media Library /wp-admin/upload.php3.17 ▲0.1739.09 ▲3.92

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

Input-output and database impact of this plugin
This plugin was installed successfully
Filesystem: 7 new files
Database: 1 new table, 1 new option
New tables
wp_htaccess_map
New WordPress options
HTACCESS_IP_BLOCK_FILE_MAP_NAME

Browser metrics Passed 4 tests

This is an overview of browser requirements for <.htaccess> IP block
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,723 ▲12715.92 ▲0.0310.81 ▲2.4745.50 ▼8.10
Dashboard /wp-admin2,993 ▲605.90 ▼0.05143.38 ▼0.57122.73 ▲13.34
Posts /wp-admin/edit.php2,759 ▲202.69 ▲0.0067.36 ▼2.0086.13 ▲0.76
Add New Post /wp-admin/post-new.php1,628 ▼5521.48 ▲3.11284.27 ▼101.43109.98 ▼3.63
Media Library /wp-admin/upload.php1,827 ▲205.01 ▼0.00152.73 ▼2.68125.55 ▼1.36

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
These items require your attention
  • Zombie tables were found after uninstall: 1 table
    • wp_htaccess_map
  • The uninstall procedure has failed, leaving 1 option in the database
    • HTACCESS_IP_BLOCK_FILE_MAP_NAME

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
Even though no errors were found, this is by no means an exhaustive test

SRP 50% from 2 tests

🔹 Tests weight: 20 | SRP (Single-Responsibility Principle) - PHP files must act as libraries and never output text or perform any action when accessed directly in a browser
Almost there! Just fix the following items
  • 6× PHP files trigger errors when accessed directly with GET requests:
    • > PHP Fatal error
      Uncaught Error: Cannot access self:: when no class scope is active in wp-content/plugins/htaccess-ip-block/inc/jquery.php:29
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/htaccess-ip-block/inc/ajax.php:8
    • > PHP Warning
      require_once(HTACCESS_IP_BLOCK_PATHinc/WP_List_Table_Htaccess_Ip_Block.php): failed to open stream: No such file or directory in wp-content/plugins/htaccess-ip-block/inc/IpListTable.php on line 10
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugin_dir_path() in wp-content/plugins/htaccess-ip-block/index.php:11
    • > PHP Warning
      Use of undefined constant HTACCESS_IP_BLOCK_PATH - assumed 'HTACCESS_IP_BLOCK_PATH' (this will throw an Error in a future version of PHP) in wp-content/plugins/htaccess-ip-block/inc/IpListTable.php on line 10
    • > PHP Fatal error
      require_once(): Failed opening required 'HTACCESS_IP_BLOCK_PATHinc/WP_List_Table_Htaccess_Ip_Block.php' (include_path='.:/usr/share/php') in wp-content/plugins/htaccess-ip-block/inc/IpListTable.php on line 10

User-side errors Passed 1 test

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

Optimizations

Plugin configuration 93% 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
Please fix the following attributes:
  • Screenshots: Screenshot #1 (Example Control Panel) image not found
The official readme.txt might help

htaccess-ip-block/index.php 92% from 13 tests

The main PHP script in "<.htaccess> IP block" version 1.0 is automatically included on every request by WordPress
Please make the necessary changes and fix the following:
  • Main file name: Please rename the main PHP file in this plugin to the plugin slug ("htaccess-ip-block.php" instead of "index.php")

Code Analysis Passed 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 plugin1,095 lines of code in 5 files:
LanguageFilesBlank linesComment linesLines of code
PHP52945621,095

PHP code Passed 2 tests

Analyzing cyclomatic complexity and code structure
There are no cyclomatic complexity problems detected for this plugin
Cyclomatic complexity
Average complexity per logical line of code0.37
Average class complexity48.67
▷ Minimum class complexity14.00
▷ Maximum class complexity117.00
Average method complexity2.97
▷ Minimum method complexity1.00
▷ Maximum method complexity19.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes3
▷ Abstract classes00.00%
▷ Concrete classes3100.00%
▷ Final classes00.00%
Methods70
▷ Static methods811.43%
▷ Public methods4767.14%
▷ Protected methods2130.00%
▷ Private methods22.86%
Functions4
▷ Named functions375.00%
▷ Anonymous functions125.00%
Constants7
▷ Global constants114.29%
▷ Class constants685.71%
▷ Public constants6100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

PNG files should be compressed to save space and minimize bandwidth usage
1 PNG file occupies 0.13MB with 0.08MB in potential savings
Potential savings
Compression of 1 random PNG file using pngquant
FileSize - originalSize - compressedSavings
screenshot-1.png133.74KB47.16KB▼ 64.74%