78% two-factor-authentication

Code Review | Two Factor Authentication

WordPress plugin Two Factor Authentication scored 78% from 54 tests.

About plugin

  • Plugin page: two-factor-authen...
  • Plugin version: 1.14.17
  • PHP compatiblity: 5.6+
  • PHP version: 7.4.16
  • WordPress compatibility: 3.4-6.3
  • WordPress version: 6.3.1
  • First release: Mar 20, 2015
  • Latest release: Aug 26, 2023
  • Number of updates: 159
  • Update frequency: every 19.4 days
  • Top authors: DavidAnderson (100%)

Code review

54 tests

User reviews

72 reviews

Install metrics

20,000+ active / 698,591 total downloads

Benchmarks

Plugin footprint 83% 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.08MB] [CPU: ▼7.16ms] Passed 4 tests

Server-side resources used by Two Factor Authentication
This plugin has minimal impact on server resources
PageMemory (MB)CPU Time (ms)
Home /3.55 ▲0.0938.39 ▼3.21
Dashboard /wp-admin3.39 ▲0.0845.12 ▼3.56
Posts /wp-admin/edit.php3.50 ▲0.1448.00 ▼1.26
Add New Post /wp-admin/post-new.php5.97 ▲0.0882.21 ▼20.61
Media Library /wp-admin/upload.php3.31 ▲0.0834.78 ▲4.03
Two Factor Authentication /wp-admin/options-general.php?page=two-factor-auth3.3834.31

Server storage [IO: ▲0.49MB] [DB: ▲0.07MB] Passed 3 tests

Filesystem and database footprint
The plugin installed successfully
Filesystem: 37 new files
Database: no new tables, 6 new options
New WordPress options
db_upgraded
widget_recent-posts
widget_recent-comments
theysaidso_admin_options
can_compress_scripts
widget_theysaidso_widget

Browser metrics Passed 4 tests

A check of browser resources used by Two Factor Authentication
This plugin renders optimally with no browser resource issues detected
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,815 ▲8014.47 ▲0.201.59 ▼0.3541.16 ▼2.42
Dashboard /wp-admin2,224 ▲395.83 ▲0.97101.30 ▲0.5964.26 ▲17.33
Posts /wp-admin/edit.php2,107 ▲181.98 ▼0.0337.64 ▼2.8634.51 ▼0.66
Add New Post /wp-admin/post-new.php1,527 ▲1023.15 ▲5.46769.69 ▲167.3150.42 ▲1.31
Media Library /wp-admin/upload.php1,403 ▲154.23 ▼0.04102.97 ▲7.1646.24 ▲6.24
Two Factor Authentication /wp-admin/options-general.php?page=two-factor-auth1,1252.0724.3527.12

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

🔸 Tests weight: 35 | The uninstall procedure must remove all plugin files and extra database tables
You still need to fix the following
  • This plugin did not uninstall successfully, leaving 6 options in the database
    • theysaidso_admin_options
    • db_upgraded
    • widget_theysaidso_widget
    • widget_recent-posts
    • can_compress_scripts
    • widget_recent-comments

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no server-side errors were triggered
The smoke test was a success, however most plugin functionality was not tested

SRP 0% from 2 tests

🔹 Tests weight: 20 | A shallow check of the single-responsibility principle; PHP files should perform no action - including output of placeholder text - and trigger no errors when accessed directly
Please fix the following
  • 9× PHP files output non-empty strings when accessed directly via GET requests:
    • > /wp-content/plugins/two-factor-authentication/simba-tfa/includes/tfa_frontend.php
    • > /wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/hotp-php-master/example.php
    • > /wp-content/plugins/two-factor-authentication/simba-tfa/templates/admin-settings.php
    • > /wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/loader.php
    • > /wp-content/plugins/two-factor-authentication/simba-tfa/includes/tfa-encryption-muplugin.php
    • > /wp-content/plugins/two-factor-authentication/simba-tfa/templates/user-settings.php
    • > /wp-content/plugins/two-factor-authentication/simba-tfa/templates/shortcode-tfa-user-settings.php
    • > /wp-content/plugins/two-factor-authentication/simba-tfa/simba-tfa.php
    • > /wp-content/plugins/two-factor-authentication/simba-tfa/includes/login-form-integrations.php
  • 12× PHP files trigger server errors when accessed directly (only 10 are shown):
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/hotp-php-master/hotp.php on line 128
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/hotp-php-master/hotp.php on line 128
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/hotp-php-master/hotp.php on line 128
    • > PHP Fatal error
      Uncaught Error: Call to undefined function current_user_can() in wp-content/plugins/two-factor-authentication/simba-tfa/templates/settings-intro-notices.php:4
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/hotp-php-master/hotp.php on line 128
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/hotp-php-master/hotp.php on line 128
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/hotp-php-master/hotp.php on line 128
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/hotp-php-master/hotp.php on line 128
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/hotp-php-master/hotp.php on line 128
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-authentication/simba-tfa/providers/totp/hotp-php-master/hotp.php on line 128

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 93% from 29 tests

readme.txt 94% from 16 tests

The readme.txt file is undoubtedly the most important file in your plugin, preparing it for public listing on WordPress.org
These attributes need to be fixed:
  • Screenshots: Screenshot #13 (Allowing users to have trusted devices (Premium version)) image not found
Please take inspiration from this readme.txt

two-factor-authentication/two-factor-login.php 92% from 13 tests

The entry point to "Two Factor Authentication" version 1.14.17 is a PHP file that has certain tags in its header comment area
The following require your attention:
  • Main file name: The principal plugin file should be the same as the plugin slug ("two-factor-authentication.php" instead of "two-factor-login.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | Executable files are considered dangerous and should not be included with any WordPress plugin
Everything looks great! No dangerous files found in this plugin5,900 lines of code in 29 files:
LanguageFilesBlank linesComment linesLines of code
JavaScript86774032,455
PHP158281,1042,408
PO File3468586980
Markdown220047
CSS12110

PHP code Passed 2 tests

This is a short overview of cyclomatic complexity and code structure for this plugin
No complexity issues detected
Cyclomatic complexity
Average complexity per logical line of code0.48
Average class complexity57.33
▷ Minimum class complexity4.00
▷ Maximum class complexity285.00
Average method complexity4.21
▷ Minimum method complexity1.00
▷ Maximum method complexity41.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes9
▷ Abstract classes00.00%
▷ Concrete classes9100.00%
▷ Final classes00.00%
Methods158
▷ Static methods74.43%
▷ Public methods13283.54%
▷ Protected methods74.43%
▷ Private methods1912.03%
Functions2
▷ Named functions150.00%
▷ Anonymous functions150.00%
Constants4
▷ Global constants375.00%
▷ Class constants125.00%
▷ Public constants1100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Using a strong compression for your PNG files is a great way to speed-up your plugin
2 PNG files occupy 0.01MB with 0.01MB in potential savings
Potential savings
Compression of 2 random PNG files using pngquant
FileSize - originalSize - compressedSavings
simba-tfa/includes/tfa_admin_icon_32x32.png6.75KB1.70KB▼ 74.79%
simba-tfa/includes/tfa_admin_icon_16x16.png3.74KB0.98KB▼ 73.75%