XoopsModules25x/xoopspoll

View on GitHub
admin/main.php

Summary

Maintainability
D
2 days
Test Coverage

File main.php has 587 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
               XOOPS - PHP Content Management System
                   Copyright (c) 2000-2020 XOOPS.org
                      <https://xoops.org>
Severity: Major
Found in admin/main.php - About 1 day to fix

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

            $pollVars = [
                'user_id'     => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'),
                'question'    => Request::getString('question', null, 'POST'),
                'description' => Request::getText('description', null, 'POST'),
                'mail_status' => (Constants::NOTIFICATION_ENABLED === $notify) ? Constants::POLL_NOT_MAILED : Constants::POLL_MAILED,
    Severity: Major
    Found in admin/main.php and 4 other locations - About 1 day to fix
    extras/newbb_4x/irmtfan/polls.php on lines 413..427
    extras/newbb_4x/trunk_4_00/polls.php on lines 154..168
    extras/newbb_5x/irmtfan/polls.php on lines 408..422
    extras/newbb_5x/trunk_5_00/polls.php on lines 150..164

    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 256.

    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

    Further Reading

    There must be one USE keyword per declaration
    Open

    use XoopsModules\Xoopspoll\{
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

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

        case 'quickupdate':
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 144 characters
    Open

                redirect_header($_SERVER['SCRIPT_NAME'], Constants::REDIRECT_DELAY_MEDIUM, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 281 characters
    Open

            $startTimeText = new FormDateTimePicker("<div class='bold'>" . _AM_XOOPSPOLL_START_TIME . '<br>' . "<span class='x-small'>" . _AM_XOOPSPOLL_FORMAT . '<br>' . sprintf(_AM_XOOPSPOLL_CURRENTTIME, $xuCurrentFormatted) . '</span></div>', 'xu_start_time', 20, $xuStartTimestamp);
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 129 characters
    Open

                'mail_status' => (Constants::NOTIFICATION_ENABLED === $notify) ? Constants::POLL_NOT_MAILED : Constants::POLL_MAILED,
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 205 characters
    Open

                        $adminObject->addInfoBoxLine(sprintf("<img src='" . $pathIcon16 . "/forum.png' alt='" . _AM_XOOPSPOLL_NEWBB_SUPPORT . "'> " . _AM_XOOPSPOLL_NEWBB_INTRO, null, null, 'information'), '');
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 144 characters
    Open

                redirect_header($_SERVER['SCRIPT_NAME'], Constants::REDIRECT_DELAY_MEDIUM, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 122 characters
    Open

            $pollForm    = new \XoopsThemeForm(_AM_XOOPSPOLL_RESTARTPOLL, 'poll_form', $_SERVER['SCRIPT_NAME'], 'post', true);
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 197 characters
    Open

                        $end = "<span class='red'>" . _AM_XOOPSPOLL_EXPIRED . '</span><br>' . "<a href='" . $_SERVER['SCRIPT_NAME'] . "?op=restart&amp;poll_id={$id}'>" . _AM_XOOPSPOLL_RESTART . '</a>';
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 148 characters
    Open

            $endTimestamp     = empty($xuEndTimestamp) ? ($currentTimestamp + Constants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp);
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 148 characters
    Open

            $startTimestamp   = empty($xuStartTimestamp) ? ($endTimestamp - Constants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp);
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 128 characters
    Open

                            'alt'  => _AM_XOOPSPOLL_NEWBB_TOPIC . '&nbsp;' . htmlspecialchars($topic_title, ENT_QUOTES | ENT_HTML5),
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 130 characters
    Open

                redirect_header($_SERVER['SCRIPT_NAME'], Constants::REDIRECT_DELAY_SHORT, implode('<br>', $pollHandler->getErrors()));
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 144 characters
    Open

                redirect_header($_SERVER['SCRIPT_NAME'], Constants::REDIRECT_DELAY_MEDIUM, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 149 characters
    Open

            $endTimeText = new FormDateTimePicker("<div class='bold middle'>" . _AM_XOOPSPOLL_EXPIRATION . '</div>', 'xu_end_time', 20, $xuEndTimestamp);
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 148 characters
    Open

            $startTimestamp = empty($xuStartTimestamp) ? ($xuEndTimestamp - Constants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp);
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 132 characters
    Open

                             . "            <a href='{$sorthref}{$field['order']}&amp;orderdir=ASC'><img src='{$arrowUp}' alt=''></a>\n"
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 135 characters
    Open

                             . "            <a href='{$sorthref}{$field['order']}&amp;orderdir=DESC'><img src='{$arrowDown}' alt=''></a>\n"
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 198 characters
    Open

                    echo "  <tr class='{$rowClass}'><td class='center'>" . ++$i . "</td><td class='center'>{$thisOption['option_text']}</td><td class='center'>{$thisOption['option_count']}</td></tr>\n";
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 123 characters
    Open

                    if ($display[$thisId] !== $pollObj->getVar('display') || $weight[$thisId] !== $pollObj->getVar('weight')) {
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 148 characters
    Open

            redirect_header($_SERVER['SCRIPT_NAME'] . "?poll_id={$cloneId}&amp;op=edit", Constants::REDIRECT_DELAY_MEDIUM, _AM_XOOPSPOLL_CLONE_SUCCESS);
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 168 characters
    Open

            //    echo "<div class='center' style='margin-bottom: 1em;'>[ <a href='" . $_SERVER['SCRIPT_NAME'] . "?op=list'>" . _AM_XOOPSPOLL_RETURNLIST . "</a> ]</div>\n";
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 151 characters
    Open

                    $ipLabel    = (Constants::LOOK_UP_HOST === $GLOBALS['xoopsModuleConfig']['look_up_host']) ? _AM_XOOPSPOLL_HOST_NAME : _AM_XOOPSPOLL_IP;
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 122 characters
    Open

                redirect_header($_SERVER['SCRIPT_NAME'], Constants::REDIRECT_DELAY_SHORT, _AM_XOOPSPOLL_ERROR_INVALID_POLLID);
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 135 characters
    Open

            $endTimestamp   = empty($xuEndTimestamp) ? (time() + Constants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp);
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 266 characters
    Open

                        echo "        <tr class='bg1'>\n" . "          <td class='{$class} center'>{$logVals['log_id']}</td>\n" . "          <td class='{$class}'>" . $option->getVar('option_text') . "</td>\n" . "          <td class='{$class} center'>{$remoteIp}</td>\n";
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 122 characters
    Open

                redirect_header($_SERVER['SCRIPT_NAME'], Constants::REDIRECT_DELAY_SHORT, _AM_XOOPSPOLL_ERROR_INVALID_POLLID);
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 240 characters
    Open

                    echo "<table class='outer bnone width100' style='padding: 0; margin: 0;'>\n" . "  <tr>\n" . "    <td class='bg2'>\n" . "      <table class='width100 bnone pad3 marg2'>\n" . "        <thead>\n" . "        <tr class='bg3'>\n";
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 138 characters
    Open

                    $display[$thisId] = empty($display[$thisId]) ? Constants::DO_NOT_DISPLAY_POLL_IN_BLOCK : Constants::DISPLAY_POLL_IN_BLOCK;
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    Line exceeds 120 characters; contains 286 characters
    Open

            //    echo "<div class='center' style='margin-bottom: 1em;'>[ <a href='" . $_SERVER['SCRIPT_NAME'] . "?op=list'><img src='". $pathIcon16 ."/back.png' alt='" . _AM_XOOPSPOLL_RETURNLIST . "' title='" . _AM_XOOPSPOLL_RETURNLIST . "'>" . _AM_XOOPSPOLL_RETURNLIST . "</a> ]</div>\n";
    Severity: Minor
    Found in admin/main.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status