Function get_values
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
public function get_values( $element, $submission = null ) {
$values = array();
if ( $submission ) {
$all_values = $submission->get_element_values_data();
if ( isset( $all_values[ $element->id ] ) ) {
- 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
File element-type.php
has 362 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Element type base class
*
* @package TorroForms
Element_Type
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Element_Type {
/**
* Error code to use when the error says the field is required.
*
Function sanitize_settings_fields
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
final protected function sanitize_settings_fields() {
$defaults = array(
'section' => '',
'type' => 'text',
'label' => '',
- 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 get_values
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_values( $element, $submission = null ) {
$values = array();
if ( $submission ) {
$all_values = $submission->get_element_values_data();
if ( isset( $all_values[ $element->id ] ) ) {
Function filter_json
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function filter_json( $data, $element, $submission = null ) {
$data['template_suffix'] = $this->slug;
$settings = $this->get_settings( $element );
$values = $this->get_values( $element, $submission );
- 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 filter_json
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function filter_json( $data, $element, $submission = null ) {
$data['template_suffix'] = $this->slug;
$settings = $this->get_settings( $element );
$values = $this->get_values( $element, $submission );
Method sanitize_settings_fields
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
final protected function sanitize_settings_fields() {
$defaults = array(
'section' => '',
'type' => 'text',
'label' => '',
Function escape_single_value_for_export
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function escape_single_value_for_export( $value, $export_format ) {
switch ( $export_format ) {
case 'xls':
case 'csv':
if ( is_array( $value ) && is_string( $value[ key( $value ) ] ) ) {
- 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
Avoid deeply nested control flow statements. Open
if ( is_array( $get_params ) ) {
foreach ( $get_params as $field => $value ) {
if ( empty( $values[ $field ] ) ) {
if ( ! empty( $choices[ $field ] ) ) {
if ( isset( $choices[ $field ][ $value ] ) ) {
Function get_edit_submission_fields_args
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_edit_submission_fields_args( $element ) {
$settings = $this->get_settings( $element );
$slug = $this->get_edit_submission_field_slug( $element->id );
$args = array(
- 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"