File class-wc-email.php
has 541 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Class WC_Email file.
*
* @package WooCommerce\Emails
WC_Email
has 41 functions (exceeds 20 allowed). Consider refactoring. Open
class WC_Email extends WC_Settings_API {
/**
* Email method ID.
*
Method admin_options
has 124 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function admin_options() {
// Do admin actions.
$this->admin_actions();
?>
<h2><?php echo esc_html( $this->get_title() ); ?> <?php wc_back_link( __( 'Return to emails', 'woocommerce' ), admin_url( 'admin.php?page=wc-settings&tab=email' ) ); ?></h2>
Function admin_options
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function admin_options() {
// Do admin actions.
$this->admin_actions();
?>
<h2><?php echo esc_html( $this->get_title() ); ?> <?php wc_back_link( __( 'Return to emails', 'woocommerce' ), admin_url( 'admin.php?page=wc-settings&tab=email' ) ); ?></h2>
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function admin_actions
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function admin_actions() {
// Handle any actions.
if (
( ! empty( $this->template_html ) || ! empty( $this->template_plain ) )
&& ( ! empty( $_GET['move_template'] ) || ! empty( $_GET['delete_template'] ) )
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method init_form_fields
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function init_form_fields() {
/* translators: %s: list of placeholders */
$placeholder_text = sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '<code>' . esc_html( implode( '</code>, <code>', array_keys( $this->placeholders ) ) ) . '</code>' );
$this->form_fields = array(
'enabled' => array(
Function save_template
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function save_template( $template_code, $template_path ) {
if ( current_user_can( 'edit_themes' ) && ! empty( $template_code ) && ! empty( $template_path ) ) {
$saved = false;
$file = get_stylesheet_directory() . '/' . WC()->template_path() . $template_path;
$code = wp_unslash( $template_code );
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function style_inline
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function style_inline( $content ) {
if ( in_array( $this->get_content_type(), array( 'text/html', 'multipart/alternative' ), true ) ) {
ob_start();
wc_get_template( 'emails/email-styles.php' );
$css = apply_filters( 'woocommerce_email_styles', ob_get_clean(), $this );
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method send
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function send( $to, $subject, $message, $headers, $attachments ) {
Function get_headers
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get_headers() {
$header = 'Content-Type: ' . $this->get_content_type() . "\r\n";
if ( in_array( $this->id, array( 'new_order', 'cancelled_order', 'failed_order' ), true ) ) {
if ( $this->object && $this->object->get_billing_email() && ( $this->object->get_billing_first_name() || $this->object->get_billing_last_name() ) ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function delete_template_action
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function delete_template_action( $template_type ) {
$template = $this->get_template( $template_type );
if ( $template ) {
if ( ! empty( $template ) ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"