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);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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
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)";
- Read upRead up
- Exclude checks
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)";
- Exclude checks
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)) {
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 != "") {
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) {
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' => [
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)
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)
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)
Avoid too many return
statements within this method. Open
return "Protokoll";
Avoid too many return
statements within this method. Open
return $matches['tag'] . '.' . $matches['monat'] . '.' . $matches['jahr'];
Avoid too many return
statements within this method. Open
return "Einladung";
Avoid too many return
statements within this method. Open
return "Tagesordnung";
Avoid too many return
statements within this method. Open
return "Protokoll";
Avoid too many return
statements within this method. Open
return "Einladung";
Avoid too many return
statements within this method. Open
return $matches["name"];
Avoid too many return
statements within this method. Open
return "Protokoll";
Avoid too many return
statements within this method. Open
return "Tagesordnung";
Avoid too many return
statements within this method. Open
return $matches["name"];
Avoid too many return
statements within this method. Open
return "Deckblatt";
Avoid too many return
statements within this method. Open
return trim($titel);
Avoid too many return
statements within this method. Open
return $matches['tag'] . '.' . $matches['monat'] . '.' . $matches['jahr'];
Avoid too many return
statements within this method. Open
return "Niederschrift";
Avoid too many return
statements within this method. Open
return "Nachtrag";
Avoid too many return
statements within this method. Open
return $matches['tag'] . '.' . $matches['monat'] . '.' . $matches['jahr'];
Avoid too many return
statements within this method. Open
return $matches["anfang"] . " (" . trim($matches["name"]) . ")";
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)) {
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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?
- Exclude checks