Skip to content

Commit

Permalink
Wrap ABSPATH existence short-circuit with code coverage ignore comments
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Jan 21, 2025
1 parent c270c43 commit 95884d6
Show file tree
Hide file tree
Showing 74 changed files with 177 additions and 58 deletions.
5 changes: 3 additions & 2 deletions plugins/auto-sizes/auto-sizes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* @package auto-sizes
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

// Define the constant.
if ( defined( 'IMAGE_AUTO_SIZES_VERSION' ) ) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/auto-sizes/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* @since 1.0.0
*/

// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Displays the HTML generator tag for the plugin.
Expand Down
2 changes: 2 additions & 0 deletions plugins/dominant-color-images/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
* @since 1.0.0
*/

// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Add the dominant color metadata to the attachment.
Expand Down
5 changes: 3 additions & 2 deletions plugins/dominant-color-images/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* @package dominant-color-images
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

// Define required constants.
if ( defined( 'DOMINANT_COLOR_IMAGES_VERSION' ) ) {
Expand Down
5 changes: 3 additions & 2 deletions plugins/embed-optimizer/class-embed-optimizer-tag-visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.2.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Tag visitor that optimizes embeds.
Expand Down
2 changes: 2 additions & 0 deletions plugins/embed-optimizer/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* @package embed-optimizer
*/

// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Add hooks.
Expand Down
5 changes: 3 additions & 2 deletions plugins/embed-optimizer/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* @package embed-optimizer
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

(
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.1.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Tag visitor that optimizes elements with background-image styles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.1.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Tag visitor that optimizes IMG tags.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.1.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Tag visitor that optimizes image tags.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
* @since 0.2.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Image Prioritizer: Image_Prioritizer_Video_Tag_Visitor class
Expand Down
2 changes: 2 additions & 0 deletions plugins/image-prioritizer/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* @since 0.1.0
*/

// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Initializes Image Prioritizer when Optimization Detective has loaded.
Expand Down
2 changes: 2 additions & 0 deletions plugins/image-prioritizer/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
* @since 0.1.0
*/

// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

add_action( 'od_init', 'image_prioritizer_init' );
5 changes: 3 additions & 2 deletions plugins/image-prioritizer/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
* @package image-prioritizer
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

(
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.1.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Exception thrown when failing to validate URL Metrics data.
Expand Down
5 changes: 3 additions & 2 deletions plugins/optimization-detective/class-od-element.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.7.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Data for a single element in a URL Metric.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.1.1
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Extension to WP_HTML_Tag_Processor that supports injecting HTML and obtaining XPath for the current tag.
Expand Down
5 changes: 3 additions & 2 deletions plugins/optimization-detective/class-od-link-collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.3.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Collection for links added to the document.
Expand Down
5 changes: 3 additions & 2 deletions plugins/optimization-detective/class-od-strict-url-metric.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.6.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Representation of the measurements taken from a single client's visit to a specific URL without additionalProperties allowed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.4.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Context for tag visitors invoked for each tag while walking over a document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.3.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Registry for tag visitors invoked for each tag while walking over a document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.1.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Collection of URL groups according to the breakpoints.
Expand Down
5 changes: 3 additions & 2 deletions plugins/optimization-detective/class-od-url-metric-group.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.1.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* URL Metrics grouped by viewport according to breakpoints.
Expand Down
5 changes: 3 additions & 2 deletions plugins/optimization-detective/class-od-url-metric.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* @since 0.1.0
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Representation of the measurements taken from a single client's visit to a specific URL.
Expand Down
2 changes: 2 additions & 0 deletions plugins/optimization-detective/detection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* @since 0.1.0
*/

// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Obtains the ID for a post related to this response so that page caches can be told to invalidate their cache.
Expand Down
2 changes: 2 additions & 0 deletions plugins/optimization-detective/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* @since 0.1.0
*/

// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Initializes extensions for Optimization Detective.
Expand Down
2 changes: 2 additions & 0 deletions plugins/optimization-detective/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* @since 0.1.0
*/

// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

add_action( 'init', 'od_initialize_extensions', PHP_INT_MAX );
add_filter( 'template_include', 'od_buffer_output', PHP_INT_MAX );
Expand Down
5 changes: 3 additions & 2 deletions plugins/optimization-detective/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* @package optimization-detective
*/

// Exit if accessed directly.
// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

(
/**
Expand Down
2 changes: 2 additions & 0 deletions plugins/optimization-detective/optimization.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* @since 0.1.0
*/

// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Starts output buffering at the end of the 'template_include' filter.
Expand Down
2 changes: 2 additions & 0 deletions plugins/optimization-detective/site-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* @since n.e.x.t
*/

// @codeCoverageIgnoreStart
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// @codeCoverageIgnoreEnd

/**
* Adds the Optimization Detective REST API check to site health tests.
Expand Down
Loading

0 comments on commit 95884d6

Please sign in to comment.