88% two-factor-auth

Code Review | Two Factor Auth

WordPress plugin Two Factor Auth scored 88% from 54 tests.

About plugin

  • Plugin page: two-factor-auth
  • Plugin version: 4.4
  • PHP version: 7.4.16
  • WordPress compatibility: 3.1.0-3.9.1
  • WordPress version: 5.8.1
  • First release: Apr 20, 2013
  • Latest release: Jul 29, 2014
  • Number of updates: 111
  • Update frequency: every 4.2 days
  • Top authors: oskarhane (100%)

Code review

54 tests

User reviews

22 reviews

Install metrics

100+ active / 12,236 total downloads

Benchmarks

Plugin footprint Passed 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | All plugins must install correctly, without throwing any errors, warnings, or notices
Installer ran successfully

Server metrics [RAM: ▼0.00MB] [CPU: ▼141.87ms] Passed 4 tests

This is a short check of server-side resources used by Two Factor Auth
Normal server usage
PageMemory (MB)CPU Time (ms)
Home /2.83 ▲0.1240.68 ▲14.60
Dashboard /wp-admin3.06 ▲0.0055.90 ▼0.61
Posts /wp-admin/edit.php3.11 ▲0.0055.22 ▲1.78
Add New Post /wp-admin/post-new.php5.42 ▼0.02102.22 ▼570.20
Media Library /wp-admin/upload.php3.00 ▲0.0039.75 ▲1.55

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

A short overview of filesystem and database impact
There were no storage issued detected upon installing this plugin
Filesystem: 28 new files
Database: no new tables, no new options

Browser metrics Passed 4 tests

Two Factor Auth: an overview of browser usage
There were no issues detected in relation to browser resource usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,679 ▲9716.13 ▲0.879.33 ▼0.4849.30 ▼4.92
Dashboard /wp-admin2,967 ▲365.96 ▼0.06172.52 ▼0.88113.12 ▲4.36
Posts /wp-admin/edit.php2,739 ▼02.71 ▼0.0071.25 ▼12.36101.16 ▲5.37
Add New Post /wp-admin/post-new.php1,683 ▲6818.66 ▼2.66447.69 ▲105.27125.59 ▲16.79
Media Library /wp-admin/upload.php1,807 ▼35.01 ▼0.01179.81 ▲6.19128.61 ▲8.88

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

🔸 Tests weight: 35 | Checking the uninstaller removed all traces of the plugin
Uninstall script ran successfully

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for server-side errors
Even though no errors were found, this is by no means an exhaustive test

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 items
  • 1× PHP files output non-empty strings when accessed directly via GET requests:
    • > /wp-content/plugins/two-factor-auth/hotp-php-master/example.php
  • 14× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/two-factor-auth/two-factor-login.php:36
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-auth/hotp-php-master/hotp.php on line 128
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-auth/hotp-php-master/hotp.php on line 128
    • > PHP Fatal error
      Uncaught Error: Call to undefined function is_admin() in wp-content/plugins/two-factor-auth/admin_settings.php:3
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-auth/hotp-php-master/hotp.php on line 128
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-auth/hotp-php-master/hotp.php on line 128
    • > PHP Fatal error
      Uncaught Error: Call to undefined function delete_option() in wp-content/plugins/two-factor-auth/uninstall.php:3
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugin_dir_url() in wp-content/plugins/two-factor-auth/user_settings.php:21
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-auth/hotp-php-master/hotp.php on line 128
    • > PHP Notice
      Undefined property: HOTPResult::$hex in wp-content/plugins/two-factor-auth/hotp-php-master/hotp.php on line 128

User-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no browser errors were triggered
No browser issues were found

Optimizations

Plugin configuration 96% from 29 tests

readme.txt Passed 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
9 plugin tags: login, security, auth, security plugin, two factor auth...

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

Analyzing the main PHP file in "Two Factor Auth" version 4.4
Please make the necessary changes and fix the following:
  • Main file name: It is recommended to name the main PHP file as the plugin slug ("two-factor-auth.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
No dangerous file extensions were detected2,254 lines of code in 17 files:
LanguageFilesBlank linesComment linesLines of code
PHP93091841,264
PO File5344704864
Markdown241077
JavaScript19249

PHP code Passed 2 tests

A short review of cyclomatic complexity and code structure
No cyclomatic complexity issues were detected for this plugin
Cyclomatic complexity
Average complexity per logical line of code0.30
Average class complexity21.50
▷ Minimum class complexity4.00
▷ Maximum class complexity62.00
Average method complexity3.34
▷ Minimum method complexity1.00
▷ Maximum method complexity18.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes4
▷ Abstract classes00.00%
▷ Concrete classes4100.00%
▷ Final classes00.00%
Methods35
▷ Static methods720.00%
▷ Public methods2777.14%
▷ Protected methods00.00%
▷ Private methods822.86%
Functions21
▷ Named functions21100.00%
▷ Anonymous functions00.00%
Constants2
▷ Global constants2100.00%
▷ Class constants00.00%
▷ Public constants00.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
3 PNG files occupy 0.29MB with 0.20MB in potential savings
Potential savings
Compression of 3 random PNG files using pngquant
FileSize - originalSize - compressedSavings
img/tfa_admin_icon_32x32.png6.75KB1.70KB▼ 74.79%
img/tfa_header.png290.17KB118.72KB▼ 59.09%
img/tfa_admin_icon_16x16.png3.74KB0.98KB▼ 73.75%