72% npr-story-api

Code Review | NPR Story API

WordPress plugin NPR Story API scored72%from 54 tests.

About plugin

  • Plugin page: npr-story-api
  • Plugin version: 1.9.4.1
  • PHP version: 7.4.16
  • WordPress compatibility: 3.8.14-6.0
  • WordPress version: 6.3.1
  • First release: Jun 27, 2016
  • Latest release: Jun 24, 2022
  • Number of updates: 25
  • Update frequency: every 94.1 days
  • Top authors: jwcounts (60%)nprds (24%)inn_nerds (16%)innlabs (12%)

Code review

54 tests

User reviews

1 review

Install metrics

40+ active /2,844 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 gracefully, with no errors

Server metrics [RAM: ▼0.11MB] [CPU: ▼3.37ms] Passed 4 tests

Server-side resources used by NPR Story API
Server-side resource usage in normal parameters
PageMemory (MB)CPU Time (ms)
Home /4.01 ▲0.5546.23 ▲6.08
Dashboard /wp-admin3.93 ▲0.6358.88 ▲11.30
Posts /wp-admin/edit.php3.99 ▲0.6369.13 ▲19.29
Add New Post /wp-admin/post-new.php3.72 ▼2.1758.13 ▼43.59
Media Library /wp-admin/upload.php3.79 ▲0.5649.41 ▲12.75
NPR API Get Multi /wp-admin/options-general.php?page=ds_npr_api_get_multi_settings3.7857.22
NPR API /wp-admin/options-general.php?page=ds_npr_api3.8077.95
NPR API Field Mapping /wp-admin/options-general.php?page=ds_npr_api_push_mapping3.7659.25
NPR Stories /wp-admin/edit.php?post_type=npr_story_post3.9052.66
Get NPR Stories /wp-admin/edit.php?page=get-npr-stories3.7644.70
Add New /wp-admin/post-new.php?post_type=npr_story_post3.7259.56

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

Input-output and database impact of this plugin
No storage issues were detected
Filesystem: 68 new files
Database: no new tables, 9 new options
New WordPress options
widget_recent-comments
widget_recent-posts
dp_npr_query_multi_cron_interval
widget_theysaidso_widget
ds_npr_api_pull_url
theysaidso_admin_options
ds_npr_num
can_compress_scripts
db_upgraded

Browser metrics Passed 4 tests

This is an overview of browser requirements for NPR Story API
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,846 ▲8913.58 ▼0.791.93 ▼0.3243.19 ▲2.00
Dashboard /wp-admin2,246 ▲585.96 ▲0.08100.07 ▼8.4042.07 ▼1.95
Posts /wp-admin/edit.php2,154 ▲652.06 ▲0.0836.38 ▼6.1333.49 ▼1.60
Add New Post /wp-admin/post-new.php6,246 ▲4,71219.22 ▼3.95906.72 ▲274.7368.36 ▲19.71
Media Library /wp-admin/upload.php1,434 ▲464.22 ▲0.0596.45 ▼7.4143.57 ▼0.23
NPR API Get Multi /wp-admin/options-general.php?page=ds_npr_api_get_multi_settings1,2022.0725.4444.54
NPR API /wp-admin/options-general.php?page=ds_npr_api1,0682.0332.6737.81
NPR API Field Mapping /wp-admin/options-general.php?page=ds_npr_api_push_mapping9932.0323.0727.26
NPR Stories /wp-admin/edit.php?post_type=npr_story_post1,1051.9532.2330.95
Get NPR Stories /wp-admin/edit.php?page=get-npr-stories8192.0626.0927.45
Add New /wp-admin/post-new.php?post_type=npr_story_post2,3067.65171.0165.15

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

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
These items require your attention
  • Zombie WordPress options were found after uninstall: 8 options
    • can_compress_scripts
    • widget_recent-posts
    • ds_npr_api_pull_url
    • db_upgraded
    • widget_theysaidso_widget
    • theysaidso_admin_options
    • widget_recent-comments
    • dp_npr_query_multi_cron_interval

Smoke tests 25% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
Please fix the following server-side errors
    • > GET request to /wp-admin/post-new.php?post_type=npr_story_post
    • > Notice in wp-content/plugins/npr-story-api/push_story.php+636
    Trying to get property 'status' of non-object

SRP 0% from 2 tests

🔹 Tests weight: 20 | SRP (Single-Responsibility Principle) - PHP files must act as libraries and never output text or perform any action when accessed directly in a browser
The following issues need your attention
  • 1× PHP files perform the task of outputting text when accessed with GET requests:
    • > /wp-content/plugins/npr-story-api/tests/bootstrap.php
  • 18× PHP files trigger errors when accessed directly with GET requests (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'WP_UnitTestCase' not found in wp-content/plugins/npr-story-api/tests/test-get_stories_ui.php:3
    • > PHP Fatal error
      require_once(): Failed opening required 'NPRSTORY_PLUGIN_DIRget_stories_ui.php' (include_path='.:/usr/share/php') in wp-content/plugins/npr-story-api/get_stories.php on line 6
    • > PHP Warning
      Use of undefined constant NPRSTORY_PLUGIN_DIR - assumed 'NPRSTORY_PLUGIN_DIR' (this will throw an Error in a future version of PHP) in wp-content/plugins/npr-story-api/get_stories.php on line 6
    • > PHP Warning
      require_once(NPRSTORY_PLUGIN_DIRget_stories_ui.php): failed to open stream: No such file or directory in wp-content/plugins/npr-story-api/get_stories.php on line 6
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_filter() in wp-content/plugins/npr-story-api/get_stories_ui.php:23
    • > PHP Fatal error
      Uncaught Error: Class 'WP_UnitTestCase' not found in wp-content/plugins/npr-story-api/tests/test-settings.php:3
    • > PHP Warning
      require_once(NPRSTORY_PLUGIN_DIRclasses/NPRAPIWordpress.php): failed to open stream: No such file or directory in wp-content/plugins/npr-story-api/push_story.php on line 6
    • > PHP Fatal error
      require_once(): Failed opening required 'NPRSTORY_PLUGIN_DIRclasses/NPRAPIWordpress.php' (include_path='.:/usr/share/php') in wp-content/plugins/npr-story-api/push_story.php on line 6
    • > PHP Fatal error
      Uncaught Error: Class 'WP_UnitTestCase' not found in wp-content/plugins/npr-story-api/tests/test-settings_ui.php:3
    • > PHP Fatal error
      Uncaught Error: Call to undefined function get_option() in wp-content/plugins/npr-story-api/ds-npr-api.php:30

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
No browser errors were detected

Optimizations

Plugin configuration 96% from 29 tests

readme.txt Passed 16 tests

The readme.txt file uses markdown syntax to describe your plugin to the world
4 plugin tags: npr, news, public radio, api

npr-story-api/ds-npr-api.php 92% from 13 tests

The principal PHP file in "NPR Story API" v. 1.9.4.1 is loaded by WordPress automatically on each request
Please make the necessary changes and fix the following:
  • Main file name: It is recommended to name the main PHP file as the plugin slug ("npr-story-api.php" instead of "ds-npr-api.php")

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | An overview of files in this plugin; executable files are not allowed
Success! There were no dangerous files found in this plugin4,411 lines of code in 37 files:
LanguageFilesBlank linesComment linesLines of code
PHP184849733,169
CSS33748834
Markdown101520281
JavaScript3112971
JSON10026
YAML10016
XML10014

PHP code 50% from 2 tests

This is a short overview of cyclomatic complexity and code structure for this plugin
Please fix the following
  • Cyclomatic complexity of methods has to be reduced to less than 100 (currently 120)
Cyclomatic complexity
Average complexity per logical line of code0.40
Average class complexity27.23
▷ Minimum class complexity1.00
▷ Maximum class complexity261.00
Average method complexity4.55
▷ Minimum method complexity1.00
▷ Maximum method complexity120.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes13
▷ Abstract classes00.00%
▷ Concrete classes13100.00%
▷ Final classes00.00%
Methods96
▷ Static methods22.08%
▷ Public methods96100.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions93
▷ Named functions93100.00%
▷ Anonymous functions00.00%
Constants31
▷ Global constants2683.87%
▷ Class constants516.13%
▷ Public constants5100.00%

Plugin size 50% from 2 tests

Image compression 50% from 2 tests

It is recommended to compress PNG files in your plugin to minimize bandwidth usage
28 PNG files occupy 3.48MB with 2.01MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
docs/assets/img/wp-npr-api-get-multi-settings.png169.89KB59.21KB▼ 65.15%
assets/images/ui-icons_444444_256x240.png6.83KB4.17KB▼ 38.86%
docs/assets/img/bulk-actions-update-npr-story.png155.25KB51.53KB▼ 66.81%
docs/assets/img/npr-api-push-error.png16.10KB7.61KB▼ 52.76%
docs/assets/img/npr-story-draft.png235.42KB82.66KB▼ 64.89%