vindi/vindi-woocommerce

View on GitHub
src/includes/admin/Settings.php

Summary

Maintainability
A
2 hrs
Test Coverage

Showing 171 of 171 total issues

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>';
Severity: Major
Found in src/includes/admin/Settings.php - About 2 hrs to fix

    Avoid unused private fields such as '$plugin'.
    Open

    private $plugin;
    Severity: Minor
    Found in src/includes/admin/Settings.php by phpmd

    Avoid unused local variables such as '$sand_box_article'.
    Open

    $sand_box_article = '<a href="https://atendimento.vindi.com.br/hc/pt-br/articles/115012242388-Sandbox" target="_blank">' . __('DĆŗvidas?', VINDI) . '</a>';
    Severity: Minor
    Found in src/includes/admin/Settings.php by phpmd

    The method get_return_status uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

    } else {
    return 'processing';
    }
    Severity: Minor
    Found in src/includes/admin/Settings.php by phpmd

    The method check_ssl uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

    } else {
    return is_ssl();
    }
    Severity: Minor
    Found in src/includes/admin/Settings.php by phpmd

    The method api_key_field uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

    } else {
    update_option('vindi_invalid_api_key', false);
    $this->invalidApiKey = false;
    }
    Severity: Minor
    Found in src/includes/admin/Settings.php by phpmd

    Visibility must be declared on method "__construct"
    Open

    function __construct()

    Visibility must be declared on method "init_form_fields"
    Open

    function init_form_fields()

    Visibility must be declared on method "checkKey"
    Open

    function checkKey()

    The 'get_is_active_sandbox()' method which returns a boolean should be named 'is...()' or 'has...()'
    Open

    public function get_is_active_sandbox()
    {
    return $this->settings['sandbox'];
    }
    Severity: Minor
    Found in src/includes/admin/Settings.php by phpmd

    Line exceeds 120 characters; contains 159 characters
    Open

    $nfe_know_more = '<a href="http://atendimento.vindi.com.br/hc/pt-br/articles/204450944-Notas-fiscais" target="_blank">' . __('Saiba mais', VINDI) . '</a>';

    Line exceeds 120 characters; contains 136 characters
    Open

    $prospects_url = '<a href="https://app.vindi.com.br/prospects/new" target="_blank">' . __('NĆ£o possui uma conta?', VINDI) . '</a>';

    Line exceeds 120 characters; contains 123 characters
    Open

    $url = admin_url(sprintf('admin.php?page=wc-status&tab=logs&log_file=%s-%s-log', VINDI, $this->get_token()));

    Line exceeds 120 characters; contains 128 characters
    Open

    'description' => __('Status que o pedido deverĆ” ter apĆ³s receber a confirmaĆ§Ć£o de pagamento da Vindi.', VINDI),

    Line exceeds 120 characters; contains 159 characters
    Open

    $sand_box_article = '<a href="https://atendimento.vindi.com.br/hc/pt-br/articles/115012242388-Sandbox" target="_blank">' . __('DĆŗvidas?', VINDI) . '</a>';

    Line exceeds 120 characters; contains 166 characters
    Open

    'description' => sprintf(__('Envia informaƧƵes de RG e InscriĆ§Ć£o Estadual para EmissĆ£o de NFe\'s com nossos parceiros. %s', VINDI), $nfe_know_more),

    Line exceeds 120 characters; contains 133 characters
    Open

    'description' => sprintf(__('Ative esta opĆ§Ć£o para habilitar logs de depuraĆ§Ć£o do servidor. %s', VINDI), $logs_url),

    Line exceeds 120 characters; contains 126 characters
    Open

    'description' => __('Ative esta opĆ§Ć£o para habilitar a comunicaĆ§Ć£o com o ambiente Sandbox da Vindi.', VINDI),

    Spaces must be used to indent lines; tabs are not allowed
    Open

    public function get_webhooks_url() {

    Spaces must be used to indent lines; tabs are not allowed
    Open

    return sprintf('%s/index.php/wc-api/%s?token=%s',

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->form_fields = array(

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    ),

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    'sandbox' => array(

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->debug = $this->get_option('debug') == 'yes' ? true : false;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public static function add_settings_tab($settings_tabs)

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    wc_get_template(

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    'testing' => array(

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public $woocommerce;

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    global $woocommerce;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function settings_tab()

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function get_template($name, $args = array())

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    ),

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    'vindi_synchronism' => array(

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function get_is_active_sandbox()

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    private $plugin;

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    'debug' => array(

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    private $token;

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->init_form_fields();

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->routes = new VindiRoutes($this);

    Space after opening parenthesis of function call prohibited
    Open

    $this->invalidApiKey = get_option( 'vindi_invalid_api_key', false );

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    sprintf(

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    ),

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    function checkKey()

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    private $debug;

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->logger = new VindiLogger(VINDI, $this->debug);

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    $name,

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $nfe_know_more = '<a href="http://atendimento.vindi.com.br/hc/pt-br/articles/204450944-Notas-fiscais" target="_blank">' . __('Saiba mais', VINDI) . '</a>';

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    function __construct()

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->init_settings();

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $settings_tabs['settings_vindi'] = __('Vindi', VINDI);

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Multi-line function call not indented correctly; expected 8 spaces but found 6
    Open

    '',

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    '',

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    ),

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->token = sanitize_file_name(wp_hash(VINDI));

    Multi-line function call not indented correctly; expected 8 spaces but found 6
    Open

    $args,

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $sand_box_article = '<a href="https://atendimento.vindi.com.br/hc/pt-br/articles/115012242388-Sandbox" target="_blank">' . __('DĆŗvidas?', VINDI) . '</a>';

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function get_api_key()

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    return $this->settings['sandbox'];

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->api = new VindiApi($this->get_api_key(), $this->logger, $this->get_is_active_sandbox());

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    if (is_admin()) {

    Multi-line function call not indented correctly; expected 8 spaces but found 6
    Open

    $name,

    Multi-line function call not indented correctly; expected 8 spaces but found 6
    Open

    sprintf(

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function get_token()

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    )

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    'api_key' => array(

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public $routes;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    private $invalidApiKey;

    Multi-line function call not indented correctly; expected 8 spaces but found 6
    Open

    )

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    'shipping_and_tax_config' => array(

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    ),

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public $api;

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    }

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    return $settings_tabs;

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    ),

    Line indented incorrectly; expected at least 10 spaces, found 4
    Open

    );

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    return 'text';

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public $dependencies;

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->woocommerce = $woocommerce;

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->dependencies = new VindiDependencies;

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->invalidApiKey = get_option( 'vindi_invalid_api_key', false );

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    function init_form_fields()

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $url = admin_url(sprintf('admin.php?page=wc-status&tab=logs&log_file=%s-%s-log', VINDI, $this->get_token()));

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $logs_url = '<a href="' . $url . '" target="_blank">' . __('Ver Logs', VINDI) . '</a>';

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    'return_status' => array(

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    ),

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    ),

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    return $this->settings['api_key'];

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    $args,

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

    'send_nfe_information' => array(

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    return $this->token;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public $logger;

    Expected 0 spaces before closing bracket; 1 found
    Open

    $this->invalidApiKey = get_option( 'vindi_invalid_api_key', false );

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->get_template('admin-settings.html.php', array('settings' => $this));

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    );

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $prospects_url = '<a href="https://app.vindi.com.br/prospects/new" target="_blank">' . __('NĆ£o possui uma conta?', VINDI) . '</a>';

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    update_option('vindi_invalid_api_key', false);

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    if(isset($this->settings['return_status'])) {

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    }

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    return true;

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function get_return_status()

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    } else {

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    $this->invalidApiKey = true;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function is_api_key_valid()

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    return 'yes' === $this->settings['shipping_and_tax_config'];

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    return 'yes' === $this->settings['send_nfe_information'];

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    if ($this->get_is_active_sandbox()) {

    Expected 1 space after IF keyword; 0 found
    Open

    if($this->invalidApiKey) {

    Expected 1 space after IF keyword; 0 found
    Open

    if(isset($this->settings['return_status'])) {

    Multi-line function call not indented correctly; expected 8 spaces but found 4
    Open

    );

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $this->api = new VindiApi($api_key, $this->logger, $this->get_is_active_sandbox());

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function check_ssl()

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    }

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    } else {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Opening brace should be on a new line
    Open

    public function get_webhooks_url() {

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    update_option('vindi_invalid_api_key', true);

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    return 'yes' === $this->settings['vindi_synchronism'];

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    if ('unauthorized' === $this->api->test_api_key($api_key)) {

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    }

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    }

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function send_nfe_information()

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    if (!$api_key) {

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    include_once VINDI_SRC . 'views/invalid-api-key.php';

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    $this->invalidApiKey = false;

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    if($this->invalidApiKey) {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    $api_key = $this->get_api_key();

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function api_key_field()

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function get_shipping_and_tax_config()

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    return is_ssl();

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    return 'processing';

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    return $this->settings['return_status'];

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    }

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    return;

    Line indented incorrectly; expected at least 12 spaces, found 6
    Open

    include_once VINDI_SRC . 'views/invalid-api-key.php';

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

    {

    Opening parenthesis of a multi-line function call must be the last content on the line
    Open

    return sprintf('%s/index.php/wc-api/%s?token=%s',

    Line indented incorrectly; expected at least 8 spaces, found 4
    Open

    );

    Line indented incorrectly; expected 8 spaces, found 4
    Open

    } else {

    Closing brace indented incorrectly; expected 4 spaces, found 2
    Open

    }

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    public function get_synchronism_status()

    Line indented incorrectly; expected 4 spaces, found 2
    Open

    }

    There are no issues that match your filters.

    Category
    Status