Showing 45 of 379 total issues
Method add_custom_tax_fields_onedit
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function add_custom_tax_fields_onedit( $term ) {
$term_id = $term->term_id;
$term_meta = get_option( "ldp_container_$term_id" );
$ldp_model = ! empty( $term_meta['ldp_model'] ) ? stripslashes_deep( $term_meta['ldp_model'] ) : '';
$ldp_rdf_type = isset( $term_meta['ldp_rdf_type'] ) ? $term_meta['ldp_rdf_type'] : '';
Method wpldpfront_enqueue_script
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function wpldpfront_enqueue_script() {
$current_url = $_SERVER['REQUEST_URI'];
if ( strstr( $current_url, Wpldp::FRONT_PAGE_URL ) ) {
// Loading the JqueryUI library.
wp_register_script(
Function wpldp_db_upgrade
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function wpldp_db_upgrade() {
$flush_cache = wp_cache_flush();
global $wpdb;
$wpdb->query(
"UPDATE $wpdb->postmeta
- 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 wpldp
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
window.wpldp = function( store, options ) {
this.options = options || {};
this.store = store;
this.resultSet = [];
- 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_search_results
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_search_results( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
header( 'Content-Type: application/ld+json' );
header( 'Access-Control-Allow-Origin: *' );
$params = $request->get_params();
Method wpldp_edit_form_advanced
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function wpldp_edit_form_advanced( $post ) {
if ( Wpldp::RESOURCE_POST_TYPE === $post->post_type ) {
$resource_uri = Utils::get_resource_uri( $post );
$term = get_the_terms( $post->post_id, 'ldp_container' );
Method menu_setup
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function menu_setup() {
global $submenu;
// Removing all resources menu.
remove_submenu_page( 'edit.php?post_type=ldp_resource', 'edit.php?post_type=ldp_resource' );
$terms = get_terms(
Method get_resources_from_container
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_resources_from_container( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
$params = $request->get_params();
$ldp_container = $params['ldp_container'];
$headers = $request->get_headers();
Function wpldp_edit_form_advanced
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function wpldp_edit_form_advanced( $post ) {
if ( Wpldp::RESOURCE_POST_TYPE === $post->post_type ) {
$resource_uri = Utils::get_resource_uri( $post );
$term = get_the_terms( $post->post_id, 'ldp_container' );
- 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 menu_setup
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function menu_setup() {
global $submenu;
// Removing all resources menu.
remove_submenu_page( 'edit.php?post_type=ldp_resource', 'edit.php?post_type=ldp_resource' );
$terms = get_terms(
- 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 register_site_taxonomy
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function register_site_taxonomy() {
$labels = array(
'name' => __( 'Sites', 'wpldp' ),
'singular_name' => __( 'Site', 'wpldp' ),
'menu_name' => __( 'Sites', 'wpldp' ),
Method register_container_taxonomy
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function register_container_taxonomy() {
$labels = array(
'name' => __( 'Containers', 'wpldp' ),
'singular_name' => __( 'Container', 'wpldp' ),
'menu_name' => __( 'Containers', 'wpldp' ),
Method create_ldp_type
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create_ldp_type() {
register_post_type( 'ldp_resource',
array(
'labels' => array(
'name' => __( 'Resources', 'wpldp' ),
Function bindEvents
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.bindEvents = function() {
var instance = this;
jQuery('.remove-field-button').click( function( event ) {
instance.removeField( event );
});
Method format_posts_rendering
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function format_posts_rendering( $result, $posts ) {
$count = 0;
foreach ( $posts as $post ) {
$values = get_the_terms( $post->ID, 'ldp_container' );
if ( empty( $values[0] ) ) {
Method wpldp_db_upgrade
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function wpldp_db_upgrade() {
$flush_cache = wp_cache_flush();
global $wpdb;
$wpdb->query(
"UPDATE $wpdb->postmeta
Function wpldp_validation_notice
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function wpldp_validation_notice() {
global $pagenow;
if ( 'options-general.php' === $pagenow && 'wpldp' === $_GET['page'] ) { // change my-plugin to your plugin page.
if ( ( isset( $_GET['settings-updated'] ) && 'true' === $_GET['settings-updated'] ) ) {
- 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 container_meta_box_callback
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function container_meta_box_callback( $post ) {
wp_nonce_field(
'wpldp_save_container_box_data',
'wpldp_container_box_nonce'
);
Function ldp_resource_post_link
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function ldp_resource_post_link( $post_link, $id = 0 ) {
$post = get_post( $id );
if ( Wpldp::RESOURCE_POST_TYPE === get_post_type( $post ) ) {
if ( is_object( $post ) ) {
- 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 ( empty( $term ) || ! is_array( $term ) ) {
$site_url_parsed = wp_parse_url( $site );
$term = wp_insert_term(
$site_url_parsed['host'] . ' ' . $site_url_parsed['path'],
'ldp_site'