79% if-file-exists

Code Review | If File Exists

WordPress plugin If File Exists scored79%from 54 tests.

About plugin

  • Plugin page: if-file-exists
  • Plugin version: 2.3.1
  • PHP version: 7.4.16
  • WordPress compatibility: 2.7-6.3
  • WordPress version: 6.3.1
  • First release: Jun 12, 2009
  • Latest release: Aug 21, 2023
  • Number of updates: 23
  • Update frequency: every 226.0 days
  • Top authors: coffee2code (100%)

Code review

54 tests

User reviews

1 review

Install metrics

20+ active /7,930 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 successfully, without throwing any errors or notices

Server metrics [RAM: ▲0.02MB] [CPU: ▼8.16ms] Passed 4 tests

This is a short check of server-side resources used by If File Exists
Normal server usage
PageMemory (MB)CPU Time (ms)
Home /3.49 ▲0.0339.93 ▼0.17
Dashboard /wp-admin3.33 ▲0.0350.96 ▼5.23
Posts /wp-admin/edit.php3.38 ▲0.0346.39 ▼5.90
Add New Post /wp-admin/post-new.php5.91 ▲0.0385.69 ▼21.35
Media Library /wp-admin/upload.php3.25 ▲0.0239.39 ▲1.55

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

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

Browser metrics Passed 4 tests

Checking browser requirements for If File Exists
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,789 ▲2814.25 ▼0.171.68 ▼0.0343.75 ▲4.89
Dashboard /wp-admin2,198 ▲405.62 ▼0.0486.85 ▼13.0540.34 ▼5.75
Posts /wp-admin/edit.php2,100 ▼01.99 ▼0.0338.55 ▼0.5237.81 ▼0.38
Add New Post /wp-admin/post-new.php1,526 ▼023.61 ▲0.44656.19 ▼15.3259.00 ▲3.87
Media Library /wp-admin/upload.php1,400 ▼04.16 ▼0.1198.00 ▼10.2341.73 ▼4.05

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

🔸 Tests weight: 35 | It is important to correctly uninstall your plugin, without leaving any traces
The following items require your attention
  • Zombie WordPress options detected upon uninstall: 6 options
    • widget_recent-posts
    • widget_theysaidso_widget
    • db_upgraded
    • theysaidso_admin_options
    • can_compress_scripts
    • widget_recent-comments

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A smoke test targeting 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 | It is important to ensure that your PHP files perform no action when accessed directly, respecting the single-responsibility principle
Almost there! Just fix the following items
  • 1× PHP files perform the action of outputting non-empty strings when accessed directly:
    • > /wp-content/plugins/if-file-exists/tests/phpunit/bootstrap.php
  • 2× GET requests to PHP files trigger server-side errors or Error 500 responses:
    • > PHP Warning
      require_once(/tmp/wordpress-tests-lib/tests/phpunit/includes/functions.php): failed to open stream: No such file or directory in wp-content/plugins/if-file-exists/tests/phpunit/bootstrap.php on line 29
    • > PHP Fatal error
      require_once(): Failed opening required '/tmp/wordpress-tests-lib/tests/phpunit/includes/functions.php' (include_path='.:/usr/share/php') in wp-content/plugins/if-file-exists/tests/phpunit/bootstrap.php on line 29

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 Passed 29 tests

readme.txt Passed 16 tests

The readme.txt file is undoubtedly the most important file in your plugin, preparing it for public listing on WordPress.org
5 plugin tags: existence, file, coffee2code, filesystem, exists

if-file-exists/if-file-exists.php Passed 13 tests

The main file in "If File Exists" v. 2.3.1 serves as a complement to information provided in readme.txt and as the entry point to the plugin
103 characters long description:
Check if a file exists and return true/false or display a string containing information about the file.

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | This is an overview of programming languages used in this plugin; dangerous file extensions are not allowed
Success! There were no dangerous files found in this plugin516 lines of code in 10 files:
LanguageFilesBlank linesComment linesLines of code
Markdown4990257
PHP471182224
Bourne Shell16221
XML10014

PHP code Passed 2 tests

This plugin's cyclomatic complexity and code structure detailed below
No complexity issues detected
Cyclomatic complexity
Average complexity per logical line of code0.27
Average class complexity1.00
▷ Minimum class complexity1.00
▷ Maximum class complexity1.00
Average method complexity1.00
▷ Minimum method complexity1.00
▷ Maximum method complexity1.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes1
▷ Abstract classes00.00%
▷ Concrete classes1100.00%
▷ Final classes00.00%
Methods22
▷ Static methods00.00%
▷ Public methods22100.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions5
▷ Named functions5100.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
PNG images were not found in this plugin