detain/myadmin-abuse-plugin

View on GitHub

Showing 199 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

              The class ImapAbuseCheck has 26 fields. Consider redesigning ImapAbuseCheck to keep the number of fields under 15.
              Open

              class ImapAbuseCheck
              {
                  public $imap_server;
                  public $imap_username;
                  public $imap_password;
              Severity: Minor
              Found in src/ImapAbuseCheck.php by phpmd

              TooManyFields

              Since: 0.1

              Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

              Example

              class Person {
                 protected $one;
                 private $two;
                 private $three;
                 [... many more fields ...]
              }

              Source https://phpmd.org/rules/codesize.html#toomanyfields

              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

                  The property $ip_regex is not named in camelCase.
                  Open

                  class ImapAbuseCheck
                  {
                      public $imap_server;
                      public $imap_username;
                      public $imap_password;
                  Severity: Minor
                  Found in src/ImapAbuseCheck.php by phpmd

                  CamelCasePropertyName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      protected $property_name;
                  }

                  Source

                  The property $mongo_client is not named in camelCase.
                  Open

                  class ImapAbuseCheck
                  {
                      public $imap_server;
                      public $imap_username;
                      public $imap_password;
                  Severity: Minor
                  Found in src/ImapAbuseCheck.php by phpmd

                  CamelCasePropertyName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      protected $property_name;
                  }

                  Source

                  The property $client_ips is not named in camelCase.
                  Open

                  class ImapAbuseCheck
                  {
                      public $imap_server;
                      public $imap_username;
                      public $imap_password;
                  Severity: Minor
                  Found in src/ImapAbuseCheck.php by phpmd

                  CamelCasePropertyName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      protected $property_name;
                  }

                  Source

                  The property $imap_password is not named in camelCase.
                  Open

                  class ImapAbuseCheck
                  {
                      public $imap_server;
                      public $imap_username;
                      public $imap_password;
                  Severity: Minor
                  Found in src/ImapAbuseCheck.php by phpmd

                  CamelCasePropertyName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      protected $property_name;
                  }

                  Source

                  The property $all_ips is not named in camelCase.
                  Open

                  class ImapAbuseCheck
                  {
                      public $imap_server;
                      public $imap_username;
                      public $imap_password;
                  Severity: Minor
                  Found in src/ImapAbuseCheck.php by phpmd

                  CamelCasePropertyName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      protected $property_name;
                  }

                  Source

                  The parameter $delete_attachments is not named in camelCase.
                  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 by phpmd

                  CamelCaseParameterName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      public function doSomething($user_name) {
                      }
                  }

                  Source

                  Severity
                  Category
                  Status
                  Source
                  Language