Showing 2,474 of 2,474 total issues
Function array_sort
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public static function array_sort($array, $on, $order=SORT_ASC)
{
$new_array = array();
$sortable_array = 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"
Further reading
Function update
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function update($user_id, $order = null)
{
$vindi_customer_id = get_user_meta($user_id, 'vindi_customer_id', true);
// Check meta Vindi ID
if (empty($vindi_customer_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
Function update
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function update($post_id)
{
$product = wc_get_product($post_id);
// Check if the post is of the signature type
- 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 init_form_fields
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
function init_form_fields()
{
$url = admin_url(sprintf('admin.php?page=wc-status&tab=logs&log_file=%s-%s-log', VINDI, $this->get_token()));
$logs_url = '<a href="' . $url . '" target="_blank">' . __('Ver Logs', VINDI) . '</a>';
$nfe_know_more = '<a href="http://atendimento.vindi.com.br/hc/pt-br/articles/204450944-Notas-fiscais" target="_blank">' . __('Saiba mais', VINDI) . '</a>';
Method init_form_fields
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function init_form_fields()
{
$this->form_fields = array(
'enabled' => array(
Method create
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function create($user_id, $order = null)
{
$customer = new WC_Customer($user_id);
Function getPaymentMethods
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function getPaymentMethods()
{
if (false === ($payment_methods = get_transient('vindi_payment_methods'))) {
$payment_methods = 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"
Further reading
Function create
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function create($user_id, $order = null)
{
$customer = new WC_Customer($user_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
Function build_tax_item
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function build_tax_item($order_items)
{
$total_tax = 0;
$taxItem = [];
- 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 check
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function check()
{
if(!self::check_critical_dependencies()) {
return false;
}
Method test_api_key
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function test_api_key($api_key)
{
delete_transient('vindi_merchant');
$url = $this->base_path() . 'merchant';
Method get_level3_data_from_order
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_level3_data_from_order($order)
{
// WC Versions before 3.0 don't support postcodes and are
// incompatible with level3 data.
if (VindiHelpers::is_wc_lt('3.0')) {
Method create
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function create($post_id, $post, $update, $recreated = false)
{
// Check if the post is a draft
if (strpos(get_post_status($post_id), 'draft') !== false) {
return;
Method check_critical_dependencies
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function check_critical_dependencies()
{
$critical_dependencies = [
[
'name' => 'PHP',
Method request
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function request($endpoint, $method = 'POST', $data = array(), $data_to_log = null)
{
$url = sprintf('%s%s', $this->base_path(), $endpoint);
$body = $this->build_body($data);
Function order_has_trial_and_simple_product
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function order_has_trial_and_simple_product()
{
$has_trial = false;
$has_simple_product = false;
$order_items = $this->order->get_items();
- 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 bill_paid
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function bill_paid($data)
{
try {
if (empty($data->bill->subscription)) {
$order = $this->find_order_by_id($data->bill->code);
Avoid using undefined variables such as '$subscriptionn_id' which will lead to PHP notices. Open
throw new Exception(sprintf(__('Pedido da assinatura #%s para o ciclo #%s não encontrado!', VINDI), $subscriptionn_id, $cycle), 2);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$plugin' which will lead to PHP notices. Open
array_push($errors, $plugin);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Method __construct
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(VindiSettings $vindi_settings, VindiControllers $controllers)
{
global $woocommerce;