ImpressCMS/impresscms

View on GitHub
htdocs/modules/system/admin/autotasks/main.php

Summary

Maintainability
A
0 mins
Test Coverage

The method editautotasks has a boolean flag argument $showmenu, which is a certain sign of a Single Responsibility Principle violation.
Open

function editautotasks($showmenu = FALSE, $autotasksid = 0, $clone = FALSE) {

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method editautotasks has a boolean flag argument $clone, which is a certain sign of a Single Responsibility Principle violation.
Open

function editautotasks($showmenu = FALSE, $autotasksid = 0, $clone = FALSE) {

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

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

    } else {
        $autotasksObj->setVar('sat_id', 0);

        $sform = $autotasksObj->getForm(_CO_ICMS_AUTOTASKS_CREATE, 'addautotasks');
        $sform->assign($icmsAdminTpl);

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$showmenu'.
Open

function editautotasks($showmenu = FALSE, $autotasksid = 0, $clone = FALSE) {

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_type', 'center', 120, 'getTypeForDisplay'));

Call to method addIntroButton from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addIntroButton('addautotasks', 'admin.php?fct=autotasks&op=mod', _CO_ICMS_AUTOTASKS_CREATE);

Call to method fetch from undeclared class \icms_ipf_view_Table
Open

        $icmsAdminTpl->assign('icms_autotasks_table', $objectTable->fetch());

Call to method __construct from undeclared class \icms_ipf_view_Table
Open

        $objectTable = new icms_ipf_view_Table($icms_autotasks_handler, FALSE, array('edit'));

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_onfinish', 'center', 120, 'getOnFinishForDisplay'));

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_type', 'center', 120, 'getTypeForDisplay'));

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_repeat', 'center', 80, 'getRepeatForDisplay'));

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_lastruntime', 'center', 180, 'getLastRunTimeForDisplay'));

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_name', 'left', FALSE, 'getNameForDisplay'));

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_interval', 'center', 80, 'getIntervalForDisplay'));

Reference to static property user from undeclared class \icms
Open

if (!is_object(icms::$user) || !is_object(icms::$module) || !icms::$user->isAdmin(icms::$module->getVar('mid'))) {

Call to method addCustomAction from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addCustomAction('getDeleteButtonForDisplay');

Variable $icmsAdminTpl is undeclared
Open

        $icmsAdminTpl->assign('icms_autotasks_table', $objectTable->fetch());

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_enabled', 'center', 80, 'getEnableForDisplay'));

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_lastruntime', 'center', 180, 'getLastRunTimeForDisplay'));

Call to method handleObjectDeletion from undeclared class \icms_ipf_Controller
Open

        $controller->handleObjectDeletion();

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_name', 'left', FALSE, 'getNameForDisplay'));

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_repeat', 'center', 80, 'getRepeatForDisplay'));

Variable $icmsAdminTpl is undeclared
Open

        $icmsAdminTpl->display('db:system_adm_autotasks.html');

Reference to static property module from undeclared class \icms
Open

if (!is_object(icms::$user) || !is_object(icms::$module) || !icms::$user->isAdmin(icms::$module->getVar('mid'))) {

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_interval', 'center', 80, 'getIntervalForDisplay'));

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_enabled', 'center', 80, 'getEnableForDisplay'));

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_onfinish', 'center', 120, 'getOnFinishForDisplay'));

Call to method __construct from undeclared class \icms_ipf_Controller
Open

        $controller = new icms_ipf_Controller($icms_autotasks_handler);

Call to method addQuickSearch from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addQuickSearch(array('title', 'summary', 'description'));

Call to method storeFromDefaultForm from undeclared class \icms_ipf_Controller
Open

        $controller->storeFromDefaultForm(_CO_ICMS_AUTOTASKS_CREATED, _CO_ICMS_AUTOTASKS_MODIFIED, ICMS_URL . '/modules/system/admin.php?fct=autotasks');

Call to method __construct from undeclared class \icms_ipf_Controller
Open

        $controller = new icms_ipf_Controller($icms_autotasks_handler);

Avoid excessively long variable names like $icms_autotasks_handler. Keep variable name length under 20.
Open

    global $icms_autotasks_handler, $icmsAdminTpl;

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

function editautotasks($showmenu = FALSE, $autotasksid = 0, $clone = FALSE) {

The CASE body must start on the line following the statement
Open

    case "mod":

Expected 1 blank line at end of file; 2 found
Open

icms_cp_footer();

The DEFAULT body must start on the line following the statement
Open

    default:

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

        $objectTable->addColumn(new icms_ipf_view_Column('sat_name', 'left', FALSE, 'getNameForDisplay'));

Blank line found at start of control structure
Open

    if (!$clone && !$autotasksObj->isNew()) {

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

function editautotasks($showmenu = FALSE, $autotasksid = 0, $clone = FALSE) {

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

}

The CASE body must start on the line following the statement
Open

    case "clone":

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        editautotasks(TRUE, $autotasksid, TRUE);

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

        $objectTable = new icms_ipf_view_Table($icms_autotasks_handler, FALSE, array('edit'));

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        editautotasks(TRUE, $autotasksid);

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        editautotasks(TRUE, $autotasksid, TRUE);

Inline control structures are not allowed
Open

if (isset($_POST['op'])) $op = filter_input(INPUT_POST, 'op', FILTER_SANITIZE_STRING);

Inline control structures are not allowed
Open

if (isset($_GET['op'])) $op = filter_input(INPUT_GET, 'op', FILTER_SANITIZE_STRING);

The variable $icms_autotasks_handler is not named in camelCase.
Open

function editautotasks($showmenu = FALSE, $autotasksid = 0, $clone = FALSE) {
    global $icms_autotasks_handler, $icmsAdminTpl;

    icms_cp_header();

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $icms_autotasks_handler is not named in camelCase.
Open

function editautotasks($showmenu = FALSE, $autotasksid = 0, $clone = FALSE) {
    global $icms_autotasks_handler, $icmsAdminTpl;

    icms_cp_header();

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status