Showing 378 of 379 total issues
Function save_ldp_meta_for_post
has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring. Open
public function save_ldp_meta_for_post( $resource_id ) {
$fields = Utils::get_resource_fields_list( $resource_id );
if ( ! empty( $fields ) ) {
foreach ( $_POST as $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
Function wpldp
has 271 lines of code (exceeds 25 allowed). Consider refactoring. Open
window.wpldp = function( store, options ) {
this.options = options || {};
this.store = store;
this.resultSet = [];
Function get_resource
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
public function get_resource( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
$params = $request->get_params();
$ldp_container = $params['ldp_container'];
$ldp_resource_slug = $params['ldp_resource'];
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$labels = array(
'name' => __( 'Sites', 'wpldp' ),
'singular_name' => __( 'Site', 'wpldp' ),
'menu_name' => __( 'Sites', 'wpldp' ),
'all_items' => __( 'All Items', 'wpldp' ),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 263.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$labels = array(
'name' => __( 'Containers', 'wpldp' ),
'singular_name' => __( 'Container', 'wpldp' ),
'menu_name' => __( 'Containers', 'wpldp' ),
'all_items' => __( 'All Items', 'wpldp' ),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 263.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File wp-ldp.php
has 500 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* The WP-LDP Plugin main file
* @package WPLDP
* @author Benoit Alessandroni
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function __construct() {
register_activation_hook( __FILE__, array( $this, 'wpldp_rewrite_flush' ) );
add_action( 'init', array( $this, 'register_site_taxonomy' ), 0 );
add_action( 'ldp_site_add_form_fields', array( $this, 'add_custom_tax_fields_oncreate_site' ) );
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 218.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function __construct() {
register_activation_hook( __FILE__, array( $this, 'wpldp_rewrite_flush' ) );
add_action( 'init', array( $this, 'register_container_taxonomy' ), 0 );
add_action( 'ldp_container_add_form_fields', array( $this, 'add_custom_tax_fields_oncreate' ) );
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 218.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function wpldp_plugin_update
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
function wpldp_plugin_update() {
$plugin_version = get_option( 'wpldp_version' );
$update_option = null;
if ( self::$version_number !== $plugin_version ) {
- 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 initialize_container
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
function initialize_container( $force = false ) {
if ( isset( $_GET['settings-updated'] ) || $force ) {
$ldp_container_init = get_option( 'ldp_container_init', false );
if ( $ldp_container_init || $force ) {
- 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 initialize_container
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initialize_container( $force = false ) {
if ( isset( $_GET['settings-updated'] ) || $force ) {
$ldp_container_init = get_option( 'ldp_container_init', false );
if ( $ldp_container_init || $force ) {
Method get_resource
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_resource( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
$params = $request->get_params();
$ldp_container = $params['ldp_container'];
$ldp_resource_slug = $params['ldp_resource'];
Function get_api_definition
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function get_api_definition( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
header( 'Content-Type: application/ld+json' );
header( 'Access-Control-Allow-Origin: *' );
$query = new \WP_Query(
- 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 get_sites_list
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function get_sites_list( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
header( 'Content-Type: application/ld+json' );
header( 'Access-Control-Allow-Origin: *' );
$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
File wpldp.js
has 273 lines of code (exceeds 250 allowed). Consider refactoring. Open
window.wpldp = function( store, options ) {
this.options = options || {};
this.store = store;
this.resultSet = [];
Function format_posts_rendering
has a Cognitive Complexity of 17 (exceeds 5 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] ) ) {
- 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
WpLdp
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class WpLdp {
/**
* The front page url, defaulted as 'wp-ldp/front'.
*/
File class-container-taxonomy.php
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Container
*
* The container taxonomy class and instance.
Method save_ldp_meta_for_post
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save_ldp_meta_for_post( $resource_id ) {
$fields = Utils::get_resource_fields_list( $resource_id );
if ( ! empty( $fields ) ) {
foreach ( $_POST as $key => $value ) {
Method wpldp_plugin_update
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wpldp_plugin_update() {
$plugin_version = get_option( 'wpldp_version' );
$update_option = null;
if ( self::$version_number !== $plugin_version ) {