detain/myadmin-abuse-plugin

View on GitHub

Showing 17 of 199 total issues

Function process has a Cognitive Complexity of 149 (exceeds 5 allowed). Consider refactoring.
Open

    public function process($type = 'spam', $limit = false)
    {
        //print_r($this->MC);
        if ($this->MC->Nmsgs > 0) {
            $abused = 0;
Severity: Minor
Found in src/ImapAbuseCheck.php - About 3 days to fix

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 abuse_admin has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring.
Open

function abuse_admin()
{
    function_requirements('get_server_from_ip');
    function_requirements('class.ImapAbuseCheck');
    add_js('bootstrap');
Severity: Minor
Found in src/abuse_admin.php - About 1 day to fix

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 abuse_admin has 351 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function abuse_admin()
{
    function_requirements('get_server_from_ip');
    function_requirements('class.ImapAbuseCheck');
    add_js('bootstrap');
Severity: Major
Found in src/abuse_admin.php - About 1 day to fix

    Method process has 154 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function process($type = 'spam', $limit = false)
        {
            //print_r($this->MC);
            if ($this->MC->Nmsgs > 0) {
                $abused = 0;
    Severity: Major
    Found in src/ImapAbuseCheck.php - About 6 hrs to fix

      Function abuse has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

      function abuse()
      {
          /*
          CREATE TABLE my.abuse (
          abuse_id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
      Severity: Minor
      Found in src/abuse.php - About 5 hrs to fix

      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

      File ImapAbuseCheck.php has 395 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * TF Related Functionality
       * @author Joe Huss <detain@interserver.net>
       * @copyright 2019
      Severity: Minor
      Found in src/ImapAbuseCheck.php - About 5 hrs to fix

        File abuse_admin.php has 355 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Administrative Functionality
         * @author Joe Huss <detain@interserver.net>
         * @copyright 2019
        Severity: Minor
        Found in src/abuse_admin.php - About 4 hrs to fix

          Method abuse has 75 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function abuse()
          {
              /*
              CREATE TABLE my.abuse (
              abuse_id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
          Severity: Major
          Found in src/abuse.php - About 3 hrs to fix

            Function getpart has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getpart($mid, $p, $partno)
                {
                    // $partno = '1', '2', '2.1', '2.1.3', etc for multipart, 0 if simple
                    // DECODE DATA
                    $data = $partno ? imap_fetchbody($this->mbox, $mid, $partno) : // multipart
            Severity: Minor
            Found in src/ImapAbuseCheck.php - About 2 hrs to fix

            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 getpart has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getpart($mid, $p, $partno)
                {
                    // $partno = '1', '2', '2.1', '2.1.3', etc for multipart, 0 if simple
                    // DECODE DATA
                    $data = $partno ? imap_fetchbody($this->mbox, $mid, $partno) : // multipart
            Severity: Minor
            Found in src/ImapAbuseCheck.php - About 1 hr to fix

              Function fix_headers has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function fix_headers($headers)
                  {
                      $out = '';
                      $state = 0;
                      $headers = false;
              Severity: Minor
              Found in src/ImapAbuseCheck.php - About 1 hr to fix

              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 __construct has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function __construct($imap_server, $username, $password, $db, $delete_attachments = 1, $limit_ips = false)
                  {
                      $this->imap_server = $imap_server;
                      $this->imap_folder = preg_replace('/^{.*}/m', '', $this->imap_server);
                      $this->imap_username = $username;
              Severity: Minor
              Found in src/ImapAbuseCheck.php - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                                if (($logged_in && $GLOBALS['tf']->accounts->data['account_lid'] == $server_data['email']) || ($logged_in && $GLOBALS['tf']->accounts->data['account_lid'] == $db->Record['abuse_lid']) || ($logged_in == false) || ($GLOBALS['tf']->ima == 'admin')) {
                                    if (isset($GLOBALS['tf']->variables->request['response'])) {
                                        $db->query("update abuse set abuse_status='" . $db->real_escape($GLOBALS['tf']->variables->request['response_status']) . "' where abuse_id={$id}", __LINE__, __FILE__);
                                        $db->query("update abuse_data set abuse_response='" . $db->real_escape($GLOBALS['tf']->variables->request['response']) . "' where abuse_id={$id}", __LINE__, __FILE__);
                                        $db->query("select * from abuse left join abuse_data using (abuse_id) where abuse_id={$id}");
                Severity: Major
                Found in src/abuse.php - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                      if ($db->num_rows() > 0) {
                                                          $db->next_record(MYSQL_ASSOC);
                                                          $data = $GLOBALS['tf']->accounts->read($db->Record['mail_custid']);
                                                          $email = (!isset($data['email_abuse']) || trim($data['email_abuse']) == '') ? $data['account_lid'] : $data['email_abuse'];
                                                          $server_data = [
                  Severity: Major
                  Found in src/ImapAbuseCheck.php - About 45 mins to fix

                    Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function __construct($imap_server, $username, $password, $db, $delete_attachments = 1, $limit_ips = false)
                    Severity: Minor
                    Found in src/ImapAbuseCheck.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if ($date < $limit_date) {
                                                  continue;
                                              }
                      Severity: Major
                      Found in src/abuse_admin.php - About 45 mins to fix

                        Function __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function __construct($imap_server, $username, $password, $db, $delete_attachments = 1, $limit_ips = false)
                            {
                                $this->imap_server = $imap_server;
                                $this->imap_folder = preg_replace('/^{.*}/m', '', $this->imap_server);
                                $this->imap_username = $username;
                        Severity: Minor
                        Found in src/ImapAbuseCheck.php - About 35 mins to fix

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language