Showing 11 of 34 total issues
Function filter_json
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function filter_json( $data, $element, $submission = null ) {
$data = parent::filter_json( $data, $element, $submission );
$settings = $this->get_settings( $element );
- 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 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function filter_json( $data, $element, $submission = null ) {
$data = parent::filter_json( $data, $element, $submission );
$settings = $this->get_settings( $element );
Function source
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
source: function( request, response ) {
var restUrl = scriptData.restUrl + searchRoute.replace( '%search%', request.term );
$.ajax( restUrl, {
method: 'GET',
Method filter_json
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function filter_json( $data, $element, $submission = null ) {
global $wp_locale;
$data = parent::filter_json( $data, $element, $submission );
Function source
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
source: function( request, response ) {
var restUrl = scriptData.restUrl + searchRoute.replace( '%search%', request.term );
$.ajax( restUrl, {
method: 'GET',
Function validate_field
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function validate_field( $value, $element, $submission ) {
$settings = $this->get_settings( $element );
// Support Y-m-d string passed, just so that submission editing with single field works too.
if ( is_string( $value ) && 2 === substr_count( $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 ( ! isset( $item->$property ) ) {
$not_found = true;
break;
}
Method process_response
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function process_response( $response, $connection, $route_slug, $submission, $form ) {
Function validate_field
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function validate_field( $value, $element, $submission ) {
$settings = $this->get_settings( $element );
$value = (int) trim( $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 too many return
statements within this method. Open
return $parsed_value;
Function detect_date_fields_order
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function detect_date_fields_order() {
$date_format = get_option( 'date_format' );
$date_format = str_split( $date_format );
$year_group = array( 'Y', 'y' );
- 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"