84% two-factor

Code Review | Two-Factor

WordPress plugin Two-Factor scored84%from 54 tests.

About plugin

  • Plugin page: two-factor
  • Plugin version: 0.8.2
  • PHP compatiblity: 5.6+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.3-6.2
  • WordPress version: 6.3.1
  • First release: Aug 10, 2015
  • Latest release: Sep 4, 2023
  • Number of updates: 183
  • Update frequency: every 16.3 days
  • Top authors: githubsync (80.87%)kasparsd (19.67%)

Code review

54 tests

User reviews

168 reviews

Install metrics

60,000+ active /687,704 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
Install script ran successfully

Server metrics [RAM: ▲0.49MB] [CPU: ▼8.56ms] Passed 4 tests

An overview of server-side resources used by Two-Factor
This plugin does not affect your website's performance
PageMemory (MB)CPU Time (ms)
Home /3.99 ▲0.5337.75 ▼0.14
Dashboard /wp-admin3.82 ▲0.5247.97 ▼11.86
Posts /wp-admin/edit.php3.87 ▲0.5248.29 ▼0.06
Add New Post /wp-admin/post-new.php6.37 ▲0.4880.90 ▼22.17
Media Library /wp-admin/upload.php3.68 ▲0.4536.97 ▲1.69

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

A short overview of filesystem and database impact
This plugin installed successfully
Filesystem: 31 new files
Database: no new tables, 6 new options
New WordPress options
theysaidso_admin_options
widget_recent-comments
widget_recent-posts
can_compress_scripts
db_upgraded
widget_theysaidso_widget

Browser metrics Passed 4 tests

An overview of browser requirements for Two-Factor
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,789 ▲4314.17 ▼0.181.63 ▼0.0041.24 ▲1.00
Dashboard /wp-admin2,192 ▲125.51 ▼0.1481.79 ▼10.1136.49 ▼1.21
Posts /wp-admin/edit.php2,097 ▼32.01 ▲0.0533.98 ▼0.1234.19 ▼2.17
Add New Post /wp-admin/post-new.php1,526 ▼2323.16 ▲4.65672.35 ▲30.5452.77 ▼9.30
Media Library /wp-admin/upload.php1,400 ▼04.19 ▲0.0393.80 ▲1.0142.23 ▼2.51

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

🔸 Tests weight: 35 | Checking the uninstaller removed all traces of the plugin
Please fix the following items
  • This plugin did not uninstall successfully, leaving 6 options in the database
    • widget_recent-comments
    • can_compress_scripts
    • db_upgraded
    • widget_recent-posts
    • widget_theysaidso_widget
    • theysaidso_admin_options

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | This is a short smoke test looking for 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 | The single-responsibility principle: PHP files have to remain inert when accessed directly, throwing no errors and performing no actions
Please fix the following items
  • 9× GET requests to PHP files have triggered server-side errors or warnings:
    • > PHP Fatal error
      Uncaught Error: Class 'Two_Factor_Provider' not found in wp-content/plugins/two-factor/providers/class-two-factor-fido-u2f.php:15
    • > PHP Fatal error
      Uncaught Error: Class 'Two_Factor_Provider' not found in wp-content/plugins/two-factor/providers/class-two-factor-totp.php:11
    • > PHP Fatal error
      Uncaught Error: Class 'Two_Factor_Provider' not found in wp-content/plugins/two-factor/providers/class-two-factor-email.php:15
    • > PHP Warning
      Use of undefined constant ABSPATH - assumed 'ABSPATH' (this will throw an Error in a future version of PHP) in wp-content/plugins/two-factor/providers/class-two-factor-fido-u2f-admin-list-table.php on line 10
    • > PHP Fatal error
      Uncaught Error: Class 'Two_Factor_Provider' not found in wp-content/plugins/two-factor/providers/class-two-factor-dummy.php:15
    • > PHP Warning
      require_once(ABSPATHwp-admin/includes/class-wp-list-table.php): failed to open stream: No such file or directory in wp-content/plugins/two-factor/providers/class-two-factor-fido-u2f-admin-list-table.php on line 10
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugin_dir_path() in wp-content/plugins/two-factor/two-factor.php:24
    • > PHP Fatal error
      require_once(): Failed opening required 'ABSPATHwp-admin/includes/class-wp-list-table.php' (include_path='.:/usr/share/php') in wp-content/plugins/two-factor/providers/class-two-factor-fido-u2f-admin-list-table.php on line 10
    • > PHP Fatal error
      Uncaught Error: Class 'Two_Factor_Provider' not found in wp-content/plugins/two-factor/providers/class-two-factor-backup-codes.php:15

User-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no browser errors were triggered
Everything seems fine on the user side

Optimizations

Plugin configuration 97% from 29 tests

readme.txt 94% from 16 tests

The readme.txt file is an important file in your plugin as it is parsed by WordPress.org to prepare the public listing of your plugin
These attributes need your attention:
  • Tags: There are too many tags (11 tag instead of maximum 10)
Please take inspiration from this readme.txt

two-factor/two-factor.php Passed 13 tests

The principal PHP file in "Two-Factor" v. 0.8.2 is loaded by WordPress automatically on each request
132 characters long description:
Two-Factor Authentication using time-based one-time passwords, Universal 2nd Factor (FIDO U2F), email and backup verification codes.

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short review of files and their extensions; it is not recommended to include executable files
Everything looks great! No dangerous files found in this plugin5,003 lines of code in 23 files:
LanguageFilesBlank linesComment linesLines of code
PHP146541,9562,607
JavaScript56215282,110
Markdown1430237
CSS211043
SVG1006

PHP code Passed 2 tests

An overview of cyclomatic complexity and code structure
Great job! No cyclomatic complexity issues were detected in this plugin
Cyclomatic complexity
Average complexity per logical line of code0.31
Average class complexity20.47
▷ Minimum class complexity1.00
▷ Maximum class complexity124.00
Average method complexity2.85
▷ Minimum method complexity1.00
▷ Maximum method complexity24.00
Code structure
Namespaces1
Interfaces0
Traits0
Classes15
▷ Abstract classes16.67%
▷ Concrete classes1493.33%
▷ Final classes00.00%
Methods164
▷ Static methods8048.78%
▷ Public methods14588.41%
▷ Protected methods127.32%
▷ Private methods74.27%
Functions7
▷ Named functions457.14%
▷ Anonymous functions342.86%
Constants40
▷ Global constants25.00%
▷ Class constants3895.00%
▷ Public constants38100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
7 compressed PNG files occupy 0.34MB
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/icon-128x128.png1.20KB1.21KB0.00%
assets/screenshot-3.png5.97KB5.52KB▼ 7.51%
assets/banner-772x250.png2.20KB2.80KB0.00%
assets/screenshot-1.png171.25KB94.11KB▼ 45.05%
assets/icon-256x256.png2.29KB2.46KB0.00%