Method create
has 35 lines of code (exceeds 25 allowed). Consider refactoring.
function create($post_id, $post, $update, $recreated = false)
{
if (strpos(get_post_status($post_id), 'draft') !== false) {
return;
Method update
has 28 lines of code (exceeds 25 allowed). Consider refactoring.
function update($post_id)
{
$product = wc_get_product($post_id);
Function create
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
function create($post_id, $post, $update, $recreated = false)
{
if (strpos(get_post_status($post_id), 'draft') !== false) {
return;
Avoid too many return
statements within this method.
return $createdProduct;
The method create() has an NPath complexity of 768. The configured NPath complexity threshold is 200.
function create($post_id, $post, $update, $recreated = false)
{
if (strpos(get_post_status($post_id), 'draft') !== false) {
return;
The method create() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
function create($post_id, $post, $update, $recreated = false)
{
if (strpos(get_post_status($post_id), 'draft') !== false) {
return;
The method create has a boolean flag argument $recreated, which is a certain sign of a Single Responsibility Principle violation.
function create($post_id, $post, $update, $recreated = false)
The method update uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
set_transient('vindi_product_message', 'error', 60);
}
The method create uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
set_transient('vindi_product_message', 'error', 60);
}
Avoid unused private fields such as '$types'.
private $types;
Avoid unused parameters such as '$update'.
function create($post_id, $post, $update, $recreated = false)
Avoid unused parameters such as '$post'.
function create($post_id, $post, $update, $recreated = false)
Visibility must be declared on method "trash"
function trash($post_id)
Blank line found at start of control structure
if(empty($vindi_product_id)) {
Visibility must be declared on method "update"
function update($post_id)
Visibility must be declared on method "create"
function create($post_id, $post, $update, $recreated = false)
Visibility must be declared on method "untrash"
function untrash($post_id)
Visibility must be declared on method "__construct"
function __construct(VindiSettings $vindi_settings)
Line exceeds 120 characters; contains 128 characters
if(!$recreated && get_post_status($post_id) != 'publish' || !empty(get_post_meta($post_id, 'vindi_product_id', true))) {
Line indented incorrectly; expected at least 12 spaces, found 10
return;
Line indented incorrectly; expected 12 spaces, found 10
}
Line indented incorrectly; expected at least 12 spaces, found 10
return;
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 12 spaces, found 10
return $this->update($post_id);
Line indented incorrectly; expected at least 14 spaces, found 12
set_transient('vindi_product_message', 'created', 60);
Multi-line function call not indented correctly; expected 12 spaces but found 10
array(
Line indented incorrectly; expected 4 spaces, found 2
function trash($post_id)
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 10 spaces, found 8
);
Line indented incorrectly; expected at least 10 spaces, found 8
return $activatedProduct;
Expected 1 space after IF keyword; 0 found
if($updatedProduct) {
Line indented incorrectly; expected 12 spaces, found 8
}
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected 12 spaces, found 8
} else {
Line indented incorrectly; expected 4 spaces, found 2
function untrash($post_id)
Line indented incorrectly; expected at least 4 spaces, found 2
{
Expected 0 spaces before closing bracket; 1 found
update_post_meta( $post_id, 'vindi_product_id', $createdProduct['id'] );
Line indented incorrectly; expected at least 12 spaces, found 10
return;
Expected 1 space after IF keyword; 0 found
if(empty($vindi_product_id)) {
Line indented incorrectly; expected at least 12 spaces, found 10
return;
Space after opening parenthesis of function call prohibited
update_post_meta( $post_id, 'vindi_product_id', $createdProduct['id'] );
Multi-line function call not indented correctly; expected 12 spaces but found 10
$vindi_product_id,
Multi-line function call not indented correctly; expected 12 spaces but found 10
)
Line indented incorrectly; expected 10 spaces, found 8
if($updatedProduct) {
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 12 spaces, found 10
return $this->create($post_id, '', '', true);
Line indented incorrectly; expected at least 10 spaces, found 8
return $inactivatedProduct;
Line indented incorrectly; expected 4 spaces, found 2
function __construct(VindiSettings $vindi_settings)
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 12 spaces, found 8
return $createdProduct;
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 12 spaces, found 10
return;
Line indented incorrectly; expected at least 12 spaces, found 10
return;
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 12 spaces, found 10
return;
Line indented incorrectly; expected at least 14 spaces, found 10
set_transient('vindi_product_message', 'updated', 60);
Line indented incorrectly; expected at least 12 spaces, found 10
return;
Line indented incorrectly; expected at least 12 spaces, found 10
return;
Line indented incorrectly; expected at least 4 spaces, found 2
{
Expected 1 space after IF keyword; 0 found
if(!$recreated && get_post_status($post_id) != 'publish' || !empty(get_post_meta($post_id, 'vindi_product_id', true))) {
Line indented incorrectly; expected 12 spaces, found 10
} else {
Line indented incorrectly; expected 4 spaces, found 2
function update($post_id)
Line indented incorrectly; expected at least 4 spaces, found 2
{
Expected 1 space after IF keyword; 0 found
if(empty($vindi_product_id)) {
Line indented incorrectly; expected 4 spaces, found 2
function create($post_id, $post, $update, $recreated = false)
Line indented incorrectly; expected at least 16 spaces, found 12
set_transient('vindi_product_message', 'error', 60);
Line indented incorrectly; expected at least 12 spaces, found 8
return $updatedProduct;
Expected 1 space after IF keyword; 0 found
if(empty($vindi_product_id)) {
Line indented incorrectly; expected at least 14 spaces, found 12
update_post_meta( $post_id, 'vindi_product_id', $createdProduct['id'] );
Line indented incorrectly; expected at least 16 spaces, found 10
set_transient('vindi_product_message', 'error', 60);
Line indented incorrectly; expected at least 12 spaces, found 10
return;
There are no issues that match your filters.