10% simple-discount-badge

Code Review | Simple Discount Badge for Woocommerce

WordPress plugin Simple Discount Badge for Woocommerce scored 10% from 54 tests.

About plugin

  • Plugin page: simple-discount-b...
  • Plugin version: 1.0.1
  • PHP compatiblity: 5.4+
  • PHP version: 7.4.16
  • WordPress compatibility: 2.2-5.7.1
  • WordPress version: 5.8.1
  • First release: Jul 5, 2020
  • Latest release: May 11, 2021
  • Number of updates: 13
  • Update frequency: every 24.0 days
  • Top authors: satnam9 (100%)

Code review

54 tests

User reviews

1 review

Install metrics

100+ active / 759 total downloads

Benchmarks

Plugin footprint 58% from 16 tests

Installer 0% from 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
These installer errors require your attention
  • Install procedure had errors
    • > Notice in wp-content/plugins/simple-discount-badge/main.php+95
    Trying to access array offset on value of type bool

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

An overview of server-side resources used by Simple Discount Badge for Woocommerce
Normal server usage
PageMemory (MB)CPU Time (ms)
Home /2.84 ▲0.1233.04 ▲8.60
Dashboard /wp-admin3.08 ▲0.0246.99 ▲3.80
Posts /wp-admin/edit.php3.13 ▲0.0245.50 ▼1.81
Add New Post /wp-admin/post-new.php5.43 ▲0.0089.96 ▼557.68
Media Library /wp-admin/upload.php3.02 ▲0.0233.44 ▲1.25
Simple Discount Badge /wp-admin/options-general.php?page=simple_discount_badge2.9924.16

Server storage [IO: ▲0.01MB] [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: 4 new files
Database: no new tables, 1 new option
New WordPress options
sdb_setting_page_settings

Browser metrics Passed 4 tests

Checking browser requirements for Simple Discount Badge for Woocommerce
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,712 ▲11616.06 ▲0.0211.55 ▲2.0946.25 ▼4.36
Dashboard /wp-admin3,000 ▲696.56 ▲0.52144.04 ▼8.54110.78 ▼21.96
Posts /wp-admin/edit.php2,775 ▲363.01 ▲0.3075.15 ▲11.9087.26 ▲5.55
Add New Post /wp-admin/post-new.php1,707 ▲12618.36 ▼0.91382.52 ▼19.44102.98 ▼1.37
Media Library /wp-admin/upload.php1,766 ▼445.42 ▲0.38151.42 ▼11.07115.59 ▲1.19
Simple Discount Badge /wp-admin/options-general.php?page=simple_discount_badge1,6323.2292.5097.64

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: 1 option
    • sdb_setting_page_settings

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the server (in the Apache logs)
Even though no errors were found, this is by no means an exhaustive test

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
The following issues need your attention
  • 2× PHP files trigger server-side errors or warnings when accessed directly:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/simple-discount-badge/settings.php:4
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugin_dir_path() in wp-content/plugins/simple-discount-badge/main.php:16

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
Everything seems fine, but this is not an exhaustive test

Optimizations

Plugin configuration 93% from 29 tests

readme.txt Passed 16 tests

Often overlooked, readme.txt is one of the most important files in your plugin
7 plugin tags: products, woocommerce shop, woocommerce, themes, badge...

simple-discount-badge/main.php 85% from 13 tests

This is the main PHP file of "Simple Discount Badge for Woocommerce" version 1.0.1, providing information about the plugin in the header fields and serving as the principal entry point to the plugin's functions
You should first fix the following items:
  • Requires at least: Required version must match the one declared in readme.txt ("4.0" instead of "2.2")
  • Main file name: The principal plugin file should be the same as the plugin slug ("simple-discount-badge.php" instead of "main.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | Executable files are not allowed as they can serve as attack vectors
Success! There were no dangerous files found in this plugin290 lines of code in 3 files:
LanguageFilesBlank linesComment linesLines of code
PHP26336287
JavaScript1003

PHP code Passed 2 tests

A brief analysis of cyclomatic complexity and code structure for this plugin
There were no cyclomatic complexity issued detected
Cyclomatic complexity
Average complexity per logical line of code0.24
Average class complexity0.00
▷ Minimum class complexity0.00
▷ Maximum class complexity0.00
Average method complexity0.00
▷ Minimum method complexity0.00
▷ Maximum method complexity0.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes0
▷ Abstract classes00.00%
▷ Concrete classes00.00%
▷ Final classes00.00%
Methods0
▷ Static methods00.00%
▷ Public methods00.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions20
▷ Named functions20100.00%
▷ Anonymous functions00.00%
Constants0
▷ Global constants00.00%
▷ Class constants00.00%
▷ Public constants00.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
There are no PNG files in this plugin