72% fortytwo-two-factor-authentication

Code Review | Fortytwo - Two-Factor Authentication

WordPress plugin Fortytwo - Two-Factor Authentication scored72%from 54 tests.

About plugin

  • Plugin page: fortytwo-two-fact...
  • Plugin version: 1.1.1
  • PHP version: 7.4.16
  • WordPress compatibility: 4.4-4.7
  • WordPress version: 6.3.1
  • First release: Apr 1, 2016
  • Latest release: Dec 22, 2016
  • Number of updates: 43
  • Update frequency: every 6.3 days
  • Top authors: fortytwotele (100%)

Code review

54 tests

User reviews

2 reviews

Install metrics

10+ active /2,093 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.50MB] [CPU: ▼3.33ms] Passed 4 tests

This is a short check of server-side resources used by Fortytwo - Two-Factor Authentication
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /3.95 ▲0.4944.14 ▲3.28
Dashboard /wp-admin3.86 ▲0.5551.91 ▼3.56
Posts /wp-admin/edit.php3.91 ▲0.5555.39 ▲3.13
Add New Post /wp-admin/post-new.php6.38 ▲0.4987.91 ▼16.18
Media Library /wp-admin/upload.php3.72 ▲0.4941.25 ▲5.37
Two Factor Authentication /wp-admin/options-general.php?page=fortytwo-2fa-admin3.7135.68

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

How much does this plugin use your filesystem and database?
There were no storage issued detected upon installing this plugin
Filesystem: 902 new files
Database: no new tables, 6 new options
New WordPress options
widget_recent-posts
can_compress_scripts
widget_recent-comments
widget_theysaidso_widget
db_upgraded
theysaidso_admin_options

Browser metrics Passed 4 tests

Checking browser requirements for Fortytwo - Two-Factor Authentication
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,818 ▲5714.38 ▲0.032.11 ▲0.5145.69 ▲5.22
Dashboard /wp-admin2,202 ▲315.60 ▲0.0792.17 ▼7.4540.94 ▼3.27
Posts /wp-admin/edit.php2,104 ▲12.02 ▲0.0240.66 ▼2.6634.49 ▼2.56
Add New Post /wp-admin/post-new.php1,528 ▼923.64 ▲5.35658.17 ▲9.3953.80 ▼21.55
Media Library /wp-admin/upload.php1,398 ▲14.27 ▲0.1196.74 ▼7.3643.18 ▼3.09
Two Factor Authentication /wp-admin/options-general.php?page=fortytwo-2fa-admin1,1472.0327.8435.65

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

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
You still need to fix the following
  • This plugin does not fully uninstall, leaving 6 options in the database
    • widget_theysaidso_widget
    • widget_recent-comments
    • can_compress_scripts
    • db_upgraded
    • theysaidso_admin_options
    • widget_recent-posts

Smoke tests 25% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
These server-side errors were triggered
    • > GET request to /wp-admin/options-general.php?page=fortytwo-2fa-admin
    • > Warning in wp-content/plugins/fortytwo-two-factor-authentication/src/Artefact/LoginBehaviorSection.php+116
    count(): Parameter must be an array or an object that implements Countable

SRP 0% 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
  • 6× PHP files perform the task of outputting text when accessed with GET requests:
    • > /wp-content/plugins/fortytwo-two-factor-authentication/vendor/phpcollection/phpcollection/tests/bootstrap.php
    • > /wp-content/plugins/fortytwo-two-factor-authentication/vendor/fortytwo/php-sdk-two-factor-authentication/tests/Bootstrap.php
    • > /wp-content/plugins/fortytwo-two-factor-authentication/vendor/phpoption/phpoption/tests/bootstrap.php
    • > /wp-content/plugins/fortytwo-two-factor-authentication/vendor/fortytwo/php-sdk-core/tests/Bootstrap.php
    • > /wp-content/plugins/fortytwo-two-factor-authentication/vendor/jms/serializer/tests/benchmark.php
    • > /wp-content/plugins/fortytwo-two-factor-authentication/vendor/jms/parser-lib/tests/bootstrap.php
  • 330× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Interface 'JMS\\Serializer\\Exclusion\\ExclusionStrategyInterface' not found in wp-content/plugins/fortytwo-two-factor-authentication/vendor/jms/serializer/src/JMS/Serializer/Exclusion/GroupsExclusionStrategy.php:25
    • > PHP Fatal error
      Uncaught Error: Interface 'GuzzleHttp\\Promise\\PromiseInterface' not found in wp-content/plugins/fortytwo-two-factor-authentication/vendor/guzzlehttp/promises/src/Promise.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found in wp-content/plugins/fortytwo-two-factor-authentication/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php:6
    • > PHP Fatal error
      Uncaught Error: Class 'JMS\\Serializer\\Metadata\\ClassMetadata' not found in wp-content/plugins/fortytwo-two-factor-authentication/vendor/jms/serializer/tests/JMS/Serializer/Tests/Metadata/Driver/php/ObjectWithAbsentXmlListNode.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'Fortytwo\\Wordpress\\Plugin\\TwoFactorAuthentication\\Value\\AbstractCollectionValue' not found in wp-content/plugins/fortytwo-two-factor-authentication/src/Value/RegisterStateValue.php:12
    • > PHP Fatal error
      Uncaught Error: Class 'JMS\\Serializer\\Metadata\\ClassMetadata' not found in wp-content/plugins/fortytwo-two-factor-authentication/vendor/jms/serializer/tests/JMS/Serializer/Tests/Metadata/Driver/php/Discriminator.Car.php:5
    • > PHP Fatal error
      Uncaught Error: Interface 'Metadata\\Driver\\DriverInterface' not found in wp-content/plugins/fortytwo-two-factor-authentication/vendor/jms/serializer/src/JMS/Serializer/Metadata/Driver/AbstractDoctrineTypeDriver.php:31
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found in wp-content/plugins/fortytwo-two-factor-authentication/vendor/jms/serializer/tests/JMS/Serializer/Tests/Handler/FormErrorHandlerTest.php:15
    • > PHP Fatal error
      Uncaught Error: Class 'JMS\\Serializer\\Metadata\\PropertyMetadata' not found in wp-content/plugins/fortytwo-two-factor-authentication/vendor/jms/serializer/src/JMS/Serializer/Metadata/StaticPropertyMetadata.php:21
    • > PHP Fatal error
      Uncaught Error: Interface 'Psr\\Http\\Message\\StreamInterface' not found in wp-content/plugins/fortytwo-two-factor-authentication/vendor/guzzlehttp/psr7/src/CachingStream.php:10

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a smoke test targeting browser errors/issues
Everything seems fine on the user side

Optimizations

Plugin configuration 96% from 29 tests

readme.txt Passed 16 tests

It's important to format your readme.txt file correctly as it is parsed for the public listing of your plugin
8 plugin tags: register, two factor authentication, 2-factor, login, 2-step verification...

fortytwo-two-factor-authentication/fortytwo-2fa.php 92% from 13 tests

"Fortytwo - Two-Factor Authentication" version 1.1.1's main PHP file describes plugin functionality and also serves as the entry point to any WordPress functionality
Please take the time to fix the following:
  • Main file name: Please rename the main PHP file in this plugin to the plugin slug ("fortytwo-two-factor-authentication.php" instead of "fortytwo-2fa.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | This is an overview of file extensions present in this plugin and a short test that no dangerous files are bundled with this plugin
Good job! No executable or dangerous file extensions detected40,667 lines of code in 848 files:
LanguageFilesBlank linesComment linesLines of code
PHP5667,45615,53532,405
Markdown311,05703,643
JSON17001,346
XML108161987
reStructuredText14349455723
YAML95560712
JavaScript32059429
HTML9230363
make211031
Bourne Shell10014
CSS22014

PHP code Passed 2 tests

Analyzing cyclomatic complexity and code structure
This plugin has no cyclomatic complexity problems
Cyclomatic complexity
Average complexity per logical line of code0.24
Average class complexity5.68
▷ Minimum class complexity1.00
▷ Maximum class complexity139.00
Average method complexity1.98
▷ Minimum method complexity1.00
▷ Maximum method complexity72.00
Code structure
Namespaces92
Interfaces50
Traits5
Classes491
▷ Abstract classes285.70%
▷ Concrete classes46394.30%
▷ Final classes5211.23%
Methods2,793
▷ Static methods1043.72%
▷ Public methods2,47788.69%
▷ Protected methods1053.76%
▷ Private methods2117.55%
Functions486
▷ Named functions5912.14%
▷ Anonymous functions42787.86%
Constants103
▷ Global constants00.00%
▷ Class constants103100.00%
▷ Public constants103100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
6 PNG files occupy 0.41MB with 0.25MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
src/Img/flags.png68.14KB23.38KB▼ 65.68%
assets/screenshot-2.png25.60KB10.75KB▼ 57.99%
src/Img/flags@2x.png181.43KB64.26KB▼ 64.58%
assets/screenshot-3.png22.76KB9.86KB▼ 56.69%
assets/screenshot-4.png36.42KB13.98KB▼ 61.60%