codeformunich/Muenchen-Transparent

View on GitHub
protected/components/RISTools.php

Summary

Maintainability
D
2 days
Test Coverage

The method RISTools::send_email() calls the typical debug function print_r() which is mostly only used during development.
Open

        $fp = fopen("/tmp/mail.log", "a"); fwrite($fp, print_r($message, true)); fclose($fp);
Severity: Minor
Found in protected/components/RISTools.php by phpmd

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

The method RISTools::send_email() calls the typical debug function print_r() which is mostly only used during development.
Open

            $fp = fopen("/tmp/mail.log", "a"); fwrite($fp, print_r($response, true)); fclose($fp);
Severity: Minor
Found in protected/components/RISTools.php by phpmd

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

File RISTools.php has 356 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use Laminas\Mail\Message;

class RISTools
Severity: Minor
Found in protected/components/RISTools.php - About 4 hrs to fix

    The class RISTools has 13 public methods. Consider refactoring RISTools to keep number of public methods under 10.
    Open

    class RISTools
    {
    
        const STD_USER_AGENT = "RISParser (Muenchen Transparent)";
    
    
    Severity: Minor
    Found in protected/components/RISTools.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

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

    The class RISTools has an overall complexity of 67 which is very high. The configured complexity threshold is 50.
    Open

    class RISTools
    {
    
        const STD_USER_AGENT = "RISParser (Muenchen Transparent)";
    
    
    Severity: Minor
    Found in protected/components/RISTools.php by phpmd

    Method korrigiereDokumentenTitel has 80 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

        public static function korrigiereDokumentenTitel($titel)
        {
            $titel = trim(str_replace("_", " ", $titel));
    
            if (preg_match("/^[0-9]+to[0-9]+$/siu", $titel)) {
    Severity: Major
    Found in protected/components/RISTools.php - About 3 hrs to fix

      Method download_file has 36 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

          public static function download_file($url_to_read, $filename, $username = "", $password = "", $timeout = 30)
          {
              $ch = curl_init();
      
              if ($username != "" || $password != "") {
      Severity: Minor
      Found in protected/components/RISTools.php - About 1 hr to fix

        Method normalize_antragvon has 34 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

            public static function normalize_antragvon(string $str): array
            {
                $a   = explode(",", $str);
                $ret = [];
                foreach ($a as $y) {
        Severity: Minor
        Found in protected/components/RISTools.php - About 1 hr to fix

          Method send_email has 32 lines of code (exceeds 30 allowed). Consider refactoring.
          Open

              public static function send_email($email, $betreff, $text_plain, $text_html = null, $mail_tag = null)
              {
                  if (defined("MAILJET_PUBLIC_KEY") && defined("MAILJET_PRIVATE_KEY") && $mail_tag != "system" && stripos($email, '@muenchen.de') === false) {
                      $mailjetMessage = [
                          'From'     => [
          Severity: Minor
          Found in protected/components/RISTools.php - About 1 hr to fix

            Method send_email has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public static function send_email($email, $betreff, $text_plain, $text_html = null, $mail_tag = null)
            Severity: Minor
            Found in protected/components/RISTools.php - About 35 mins to fix

              Method download_file has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public static function download_file($url_to_read, $filename, $username = "", $password = "", $timeout = 30)
              Severity: Minor
              Found in protected/components/RISTools.php - About 35 mins to fix

                Method set_zend_email_data has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private static function set_zend_email_data($message, $email, $betreff, $text_plain, $text_html = null)
                Severity: Minor
                Found in protected/components/RISTools.php - About 35 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return "Protokoll";
                  Severity: Major
                  Found in protected/components/RISTools.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return $matches['tag'] . '.' . $matches['monat'] . '.' . $matches['jahr'];
                    Severity: Major
                    Found in protected/components/RISTools.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return "Einladung";
                      Severity: Major
                      Found in protected/components/RISTools.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return "Tagesordnung";
                        Severity: Major
                        Found in protected/components/RISTools.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return "Protokoll";
                          Severity: Major
                          Found in protected/components/RISTools.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return "Einladung";
                            Severity: Major
                            Found in protected/components/RISTools.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return $matches["name"];
                              Severity: Major
                              Found in protected/components/RISTools.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return "Protokoll";
                                Severity: Major
                                Found in protected/components/RISTools.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return "Tagesordnung";
                                  Severity: Major
                                  Found in protected/components/RISTools.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return $matches["name"];
                                    Severity: Major
                                    Found in protected/components/RISTools.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return "Deckblatt";
                                      Severity: Major
                                      Found in protected/components/RISTools.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                return trim($titel);
                                        Severity: Major
                                        Found in protected/components/RISTools.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                      return $matches['tag'] . '.' . $matches['monat'] . '.' . $matches['jahr'];
                                          Severity: Major
                                          Found in protected/components/RISTools.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                        return "Niederschrift";
                                            Severity: Major
                                            Found in protected/components/RISTools.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                          return "Nachtrag";
                                              Severity: Major
                                              Found in protected/components/RISTools.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                            return $matches['tag'] . '.' . $matches['monat'] . '.' . $matches['jahr'];
                                                Severity: Major
                                                Found in protected/components/RISTools.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                              return $matches["anfang"] . " (" . trim($matches["name"]) . ")";
                                                  Severity: Major
                                                  Found in protected/components/RISTools.php - About 30 mins to fix

                                                    The method korrigiereDokumentenTitel() has an NPath complexity of 262144. The configured NPath complexity threshold is 200.
                                                    Open

                                                        public static function korrigiereDokumentenTitel($titel)
                                                        {
                                                            $titel = trim(str_replace("_", " ", $titel));
                                                    
                                                            if (preg_match("/^[0-9]+to[0-9]+$/siu", $titel)) {
                                                    Severity: Minor
                                                    Found in protected/components/RISTools.php by phpmd

                                                    NPathComplexity

                                                    Since: 0.1

                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                    Example

                                                    class Foo {
                                                        function bar() {
                                                            // lots of complicated code
                                                        }
                                                    }

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

                                                    The method korrigiereDokumentenTitel() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10.
                                                    Open

                                                        public static function korrigiereDokumentenTitel($titel)
                                                        {
                                                            $titel = trim(str_replace("_", " ", $titel));
                                                    
                                                            if (preg_match("/^[0-9]+to[0-9]+$/siu", $titel)) {
                                                    Severity: Minor
                                                    Found in protected/components/RISTools.php by phpmd

                                                    CyclomaticComplexity

                                                    Since: 0.1

                                                    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                    Example

                                                    // Cyclomatic Complexity = 11
                                                    class Foo {
                                                    1   public function example() {
                                                    2       if ($a == $b) {
                                                    3           if ($a1 == $b1) {
                                                                    fiddle();
                                                    4           } elseif ($a2 == $b2) {
                                                                    fiddle();
                                                                } else {
                                                                    fiddle();
                                                                }
                                                    5       } elseif ($c == $d) {
                                                    6           while ($c == $d) {
                                                                    fiddle();
                                                                }
                                                    7        } elseif ($e == $f) {
                                                    8           for ($n = 0; $n < $h; $n++) {
                                                                    fiddle();
                                                                }
                                                            } else {
                                                                switch ($z) {
                                                    9               case 1:
                                                                        fiddle();
                                                                        break;
                                                    10              case 2:
                                                                        fiddle();
                                                                        break;
                                                    11              case 3:
                                                                        fiddle();
                                                                        break;
                                                                    default:
                                                                        fiddle();
                                                                        break;
                                                                }
                                                            }
                                                        }
                                                    }

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

                                                    TODO found
                                                    Open

                                                            $titel = str_replace(["Ae", "Oe", "Ue", "ae", "oe", "ue"], ["Ä", "Ö", "Ü", "ä", "ö", "ü"], $titel); // @TODO: False positives filtern? Geht das überhaupt?
                                                    Severity: Minor
                                                    Found in protected/components/RISTools.php by fixme

                                                    There are no issues that match your filters.

                                                    Category
                                                    Status