78% caret-two-stage-authentication

Code Review | Caret Two Stage Authentication

WordPress plugin Caret Two Stage Authentication scored 78% from 54 tests.

About plugin

  • Plugin page: caret-two-stage-a...
  • Plugin version: 1.0.2
  • PHP version: 7.4.16
  • WordPress compatibility: 3.0.0-4.9.8
  • WordPress version: 5.8.1
  • First release: May 24, 2013
  • Latest release: Aug 6, 2018
  • Number of updates: 9
  • Update frequency: every 211.1 days
  • Top authors: caret (100%)

Code review

54 tests

User reviews

1 review

Install metrics

10+ active / 902 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
The plugin installed gracefully, with no errors

Server metrics [RAM: ▼0.87MB] [CPU: ▼206.13ms] Passed 4 tests

An overview of server-side resources used by Caret Two Stage Authentication
This plugin does not affect your website's performance
PageMemory (MB)CPU Time (ms)
Home /2.88 ▲0.1530.75 ▲11.19
Dashboard /wp-admin2.78 ▼0.2824.16 ▼20.39
Posts /wp-admin/edit.php2.78 ▼0.3325.97 ▼21.40
Add New Post /wp-admin/post-new.php2.78 ▼2.6624.40 ▼776.02
Media Library /wp-admin/upload.php2.78 ▼0.2324.58 ▼6.69
ベーシック認証設定 /wp-admin/options-general.php?page=CaretTwoStageAuthentication2.7824.15

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

How much does this plugin use your filesystem and database?
No storage issues were detected
Filesystem: 4 new files
Database: 1 new table, no new options
New tables
wp_caret2sa

Browser metrics Passed 4 tests

A check of browser resources used by Caret Two Stage Authentication
This plugin renders optimally with no browser resource issues detected
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,718 ▲12215.83 ▲0.0810.53 ▲1.5548.02 ▲1.06
Dashboard /wp-admin2,982 ▲516.07 ▼0.09143.30 ▲2.27119.08 ▲12.78
Posts /wp-admin/edit.php2,754 ▲152.72 ▲0.0262.83 ▼3.4896.57 ▲4.61
Add New Post /wp-admin/post-new.php1,510 ▼2,23318.76 ▼0.43378.18 ▼53.95116.52 ▲2.01
Media Library /wp-admin/upload.php1,822 ▼05.02 ▼0.03144.18 ▲4.83131.19 ▲19.74
ベーシック認証設定 /wp-admin/options-general.php?page=CaretTwoStageAuthentication1,1062.0854.26132.02

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
It is recommended to fix the following
  • This plugin cannot be uninstalled
    • > User deprecated in wp-includes/functions.php+5495
    has_cap was called with an argument that is deprecated since version 2.0.0! Usage of user levels is deprecated. Use capabilities instead.

Smoke tests 50% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
Almost there, just fix the following server-side errors
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/options-general.php?page=CaretTwoStageAuthentication
    • > User deprecated in wp-includes/functions.php+5495
    has_cap was called with an argument that is deprecated since version 2.0.0! Usage of user levels is deprecated. Use capabilities instead.
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/options-general.php?page=CaretTwoStageAuthentication
    • > Notice in wp-content/plugins/caret-two-stage-authentication/setup.php+4
    Undefined index: action
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/options-general.php?page=CaretTwoStageAuthentication
    • > Notice in wp-content/plugins/caret-two-stage-authentication/setup.php+50
    Undefined index: user
    • > GET request to /wp-admin/options-general.php?page=CaretTwoStageAuthentication
    • > Warning in wp-content/plugins/caret-two-stage-authentication/setup.php+28
    count(): Parameter must be an array or an object that implements Countable
  • 10 occurences, only the last one shown
    • > GET request to /wp-admin/options-general.php?page=CaretTwoStageAuthentication
    • > Notice in wp-content/plugins/caret-two-stage-authentication/setup.php+55
    Trying to access array offset on value of type null
  • 4 occurences, only the last one shown
    • > GET request to /wp-admin/options-general.php?page=CaretTwoStageAuthentication
    • > Notice in wp-content/plugins/caret-two-stage-authentication/setup.php+55
    Undefined index: error
    • > GET request to /wp-admin/options-general.php?page=CaretTwoStageAuthentication
    • > Notice in wp-content/plugins/caret-two-stage-authentication/setup.php+54
    Undefined index: passwd

SRP 50% 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
  • 9× PHP files trigger server errors when accessed directly:
    • > PHP Notice
      Undefined index: caret2sa in wp-content/plugins/caret-two-stage-authentication/setup.php on line 4
    • > PHP Notice
      Trying to access array offset on value of type null in wp-content/plugins/caret-two-stage-authentication/setup.php on line 28
    • > PHP Warning
      count(): Parameter must be an array or an object that implements Countable in wp-content/plugins/caret-two-stage-authentication/setup.php on line 28
    • > PHP Notice
      Undefined index: caret2sa in wp-content/plugins/caret-two-stage-authentication/setup.php on line 28
    • > PHP Notice
      Trying to access array offset on value of type null in wp-content/plugins/caret-two-stage-authentication/setup.php on line 4
    • > PHP Fatal error
      Uncaught Error: Call to a member function get_var() on null in wp-content/plugins/caret-two-stage-authentication/CaretTwoStageAuthentication.php:113
    • > PHP Warning
      Use of undefined constant CARET2SA_TABLE - assumed 'CARET2SA_TABLE' (this will throw an Error in a future version of PHP) in wp-content/plugins/caret-two-stage-authentication/setup.php on line 12
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_attr() in wp-content/plugins/caret-two-stage-authentication/setup.php:50
    • > PHP Notice
      Trying to get property 'prefix' of non-object in wp-content/plugins/caret-two-stage-authentication/CaretTwoStageAuthentication.php on line 33

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
There were no browser issues found

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 88% from 16 tests

The readme.txt file describes your plugin functionality and requirements and it is parsed to prepare the your plugin's listing
These attributes need to be fixed:
  • Plugin Name: Please specify the plugin name on the first line ( === caret-two-stage-authentication === )
  • Screenshots: Screenshot #1 (設定画面) image not found
You can look at the official readme.txt

caret-two-stage-authentication/CaretTwoStageAuthentication.php 92% from 13 tests

Analyzing the main PHP file in "Caret Two Stage Authentication" version 1.0.2
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 ("caret-two-stage-authentication.php" instead of "CaretTwoStageAuthentication.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short check of programming languages and file extensions; no executable files are allowed
No dangerous file extensions were detected234 lines of code in 2 files:
LanguageFilesBlank linesComment linesLines of code
PHP25521234

PHP code Passed 2 tests

A short review of cyclomatic complexity and code structure
No complexity issues detected
Cyclomatic complexity
Average complexity per logical line of code0.44
Average class complexity36.00
▷ Minimum class complexity36.00
▷ Maximum class complexity36.00
Average method complexity3.69
▷ Minimum method complexity1.00
▷ Maximum method complexity11.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes1
▷ Abstract classes00.00%
▷ Concrete classes1100.00%
▷ Final classes00.00%
Methods13
▷ Static methods00.00%
▷ Public methods13100.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions2
▷ Named functions2100.00%
▷ Anonymous functions00.00%
Constants1
▷ Global constants1100.00%
▷ Class constants00.00%
▷ Public constants00.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

All PNG images should be compressed to minimize bandwidth usage for end users
1 PNG file occupies 0.01MB with 0.00MB in potential savings
Potential savings
Compression of 1 random PNG file using pngquant
FileSize - originalSize - compressedSavings
screenshot-1.png12.02KB8.85KB▼ 26.37%