78% affinipay-payment-gateway

Code Review | AffiniPay WordPress

WordPress plugin AffiniPay WordPress scored78%from 54 tests.

About plugin

Code review

54 tests

User reviews

1 review

Install metrics

90+ active /4,768 total downloads

Benchmarks

Plugin footprint 82% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | The install procedure must perform silently
Installer ran successfully

Server metrics [RAM: ▲0.58MB] [CPU: ▼4.34ms] 75% from 4 tests

An overview of server-side resources used by AffiniPay WordPress
It is recommended to improve the following
  • CPU: Try to keep total CPU usage under 500.00ms (currently 652.17ms on /wp-admin/options-general.php?page=affinipay-payment-gateway/lib/class-affinipay-settings.php)
PageMemory (MB)CPU Time (ms)
Home /4.07 ▲0.6139.94 ▼2.62
Dashboard /wp-admin3.92 ▲0.6149.18 ▼13.39
Posts /wp-admin/edit.php3.97 ▲0.6154.64 ▲7.31
Add New Post /wp-admin/post-new.php6.44 ▲0.5585.58 ▼7.47
Media Library /wp-admin/upload.php3.78 ▲0.5541.02 ▲6.12
Affinipay Payments /wp-admin/options-general.php?page=affinipay-payment-gateway/lib/class-affinipay-settings.php3.78652.17

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

Input-output and database impact of this plugin
There were no storage issued detected upon installing this plugin
Filesystem: 1,766 new files
Database: no new tables, 6 new options
New WordPress options
widget_recent-comments
widget_recent-posts
theysaidso_admin_options
widget_theysaidso_widget
can_compress_scripts
db_upgraded

Browser metrics Passed 4 tests

A check of browser resources used by AffiniPay WordPress
There were no issues detected in relation to browser resource usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,812 ▲7713.70 ▼0.651.53 ▼0.4538.38 ▼6.01
Dashboard /wp-admin2,210 ▲225.80 ▲0.89102.12 ▼6.0439.73 ▲2.09
Posts /wp-admin/edit.php2,102 ▲132.04 ▲0.0439.87 ▲5.3235.35 ▲1.04
Add New Post /wp-admin/post-new.php1,525 ▼1123.25 ▲0.14673.63 ▲72.9845.40 ▼5.40
Media Library /wp-admin/upload.php1,393 ▲24.24 ▲0.1293.25 ▼5.7142.41 ▼3.90
Affinipay Payments /wp-admin/options-general.php?page=affinipay-payment-gateway/lib/class-affinipay-settings.php8332.1923.9628.25

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

🔸 Tests weight: 35 | The uninstall procedure must remove all plugin files and extra database tables
You still need to fix the following
  • Zombie WordPress options detected upon uninstall: 6 options
    • widget_recent-comments
    • db_upgraded
    • widget_recent-posts
    • can_compress_scripts
    • theysaidso_admin_options
    • widget_theysaidso_widget

Smoke tests 50% 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 everything seems fine, this is not an exhaustive test

SRP 0% 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
Almost there! Just fix the following items
  • 8× PHP files output text when accessed directly:
    • > /wp-content/plugins/affinipay-payment-gateway/public/loader.php
    • > /wp-content/plugins/affinipay-payment-gateway/views/admin-accounts-response.php
    • > /wp-content/plugins/affinipay-payment-gateway/affinipay-wordpress.php
    • > /wp-content/plugins/affinipay-payment-gateway/vendor/phpunit/phpunit/tests/TextUI/_files/phpt_external.php
    • > /wp-content/plugins/affinipay-payment-gateway/views/admin-settings-default.php
    • > /wp-content/plugins/affinipay-payment-gateway/build/loader.php
    • > /wp-content/plugins/affinipay-payment-gateway/views/admin-settings-saved.php
    • > /wp-content/plugins/affinipay-payment-gateway/affinipay-wp.php
  • 819× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/affinipay-payment-gateway/vendor/phpunit/phpunit/src/Framework/WarningTestCase.php:15
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\Constraint\\Constraint' not found in wp-content/plugins/affinipay-payment-gateway/vendor/phpunit/phpunit/src/Framework/Constraint/LessThan.php:18
    • > PHP Fatal error
      Uncaught Error: Interface 'Prophecy\\Prediction\\PredictionInterface' not found in wp-content/plugins/affinipay-payment-gateway/vendor/phpspec/prophecy/src/Prophecy/Prediction/CallbackPrediction.php:25
    • > PHP Fatal error
      Uncaught Error: Class 'SebastianBergmann\\CodeCoverage\\TestCase' not found in wp-content/plugins/affinipay-payment-gateway/vendor/phpunit/php-code-coverage/tests/tests/CodeCoverageTest.php:19
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/affinipay-payment-gateway/vendor/phpunit/phpunit/tests/Util/TestTest.php:19
    • > PHP Fatal error
      Uncaught Error: Class 'ChargeIO_Transaction' not found in wp-content/plugins/affinipay-payment-gateway/vendor/affinipay/chargeio-php/lib/ChargeIO/Charge.php:3
    • > PHP Fatal error
      Uncaught Error: Class 'Prophecy\\Exception\\Doubler\\DoubleException' not found in wp-content/plugins/affinipay-payment-gateway/vendor/phpspec/prophecy/src/Prophecy/Exception/Doubler/ClassNotFoundException.php:14
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found in wp-content/plugins/affinipay-payment-gateway/vendor/phpdocumentor/reflection-common/tests/unit/FqsenTest.php:18
    • > PHP Fatal error
      Uncaught Error: Class 'PhpSpec\\ObjectBehavior' not found in wp-content/plugins/affinipay-payment-gateway/vendor/phpspec/prophecy/spec/Prophecy/Argument/ArgumentsWildcardSpec.php:8
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/affinipay-payment-gateway/vendor/phar-io/manifest/tests/values/LibraryTest.php:19

User-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the browser (console and network errors and warnings)
No browser errors were detected

Optimizations

Plugin configuration 96% from 29 tests

readme.txt Passed 16 tests

Don't ignore readme.txt as it is the file that instructs WordPress.org on how to present your plugin to the world
2 plugin tags: affinipay, payments

affinipay-payment-gateway/affinipay-wordpress.php 92% from 13 tests

The main file in "AffiniPay WordPress" v. 1.0 serves as a complement to information provided in readme.txt and as the entry point to the plugin
It is important to fix the following:
  • Main file name: Name the main plugin file the same as the plugin slug ("affinipay-payment-gateway.php" instead of "affinipay-wordpress.php")

Code Analysis 97% from 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 detected130,208 lines of code in 1,587 files:
LanguageFilesBlank linesComment linesLines of code
PHP1,29823,08463,615100,313
JSON4115014,966
CSS117782513,660
Markdown721,67603,171
XML7794172,440
HTML11116361,815
JavaScript272095341,473
Ant171250734
YAML251411636
SVG100288
XSD100267
Groovy12224163
TypeScript2103145
Bourne Shell22111134
INI1003

PHP code 50% from 2 tests

This plugin's cyclomatic complexity and code structure detailed below
Please fix the following
  • Method cyclomatic complexity has to be reduced to less than 100 (currently 127)
Cyclomatic complexity
Average complexity per logical line of code0.25
Average class complexity4.56
▷ Minimum class complexity1.00
▷ Maximum class complexity216.00
Average method complexity1.85
▷ Minimum method complexity1.00
▷ Maximum method complexity127.00
Code structure
Namespaces112
Interfaces86
Traits4
Classes1,246
▷ Abstract classes352.81%
▷ Concrete classes1,21197.19%
▷ Final classes514.21%
Methods5,559
▷ Static methods5049.07%
▷ Public methods4,88587.88%
▷ Protected methods3786.80%
▷ Private methods2965.32%
Functions238
▷ Named functions15263.87%
▷ Anonymous functions8636.13%
Constants117
▷ Global constants1916.24%
▷ Class constants9883.76%
▷ Public constants98100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
4 PNG files occupy 0.04MB with 0.02MB in potential savings
Potential savings
Compression of 4 random PNG files using pngquant
FileSize - originalSize - compressedSavings
vendor/myclabs/deep-copy/doc/clone.png12.09KB5.48KB▼ 54.70%
vendor/myclabs/deep-copy/doc/deep-copy.png10.64KB5.23KB▼ 50.84%
vendor/myclabs/deep-copy/doc/graph.png6.29KB3.03KB▼ 51.86%
vendor/myclabs/deep-copy/doc/deep-clone.png13.68KB6.54KB▼ 52.22%