codeformunich/Muenchen-Transparent

View on GitHub
protected/RISParser/CalendarAgendaUpdater.php

Summary

Maintainability
A
1 hr
Test Coverage

The method CalendarAgendaUpdater::getVorlagenId() calls the typical debug function var_dump() which is mostly only used during development.
Open

            var_dump($item);

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

Method updateAgendaItem has 54 lines of code (exceeds 30 allowed). Consider refactoring.
Open

    private function updateAgendaItem(Termin $agenda, CalendarAgendaItem $newItem): string
    {
        $top = $this->findAndRemoveMatchingOldItem($newItem);
        if ($top) {
            $oldDataCopy = new Tagesordnungspunkt();
Severity: Major
Found in protected/RISParser/CalendarAgendaUpdater.php - About 1 hr to fix

    The method updateAgendaItem() has an NPath complexity of 16392. The configured NPath complexity threshold is 200.
    Open

        private function updateAgendaItem(Termin $agenda, CalendarAgendaItem $newItem): string
        {
            $top = $this->findAndRemoveMatchingOldItem($newItem);
            if ($top) {
                $oldDataCopy = new Tagesordnungspunkt();

    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 updateAgendaItem() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10.
    Open

        private function updateAgendaItem(Termin $agenda, CalendarAgendaItem $newItem): string
        {
            $top = $this->findAndRemoveMatchingOldItem($newItem);
            if ($top) {
                $oldDataCopy = new Tagesordnungspunkt();

    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

    The method getVorlagenId() contains an exit expression.
    Open

                die("More than one Vorlage");

    ExitExpression

    Since: 0.2

    An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

    Example

    class Foo {
        public function bar($param)  {
            if ($param === 42) {
                exit(23);
            }
        }
    }

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

    Avoid unused local variables such as '$parsedItem'.
    Open

            $top->entscheidung = $parsedItem->decision ?? $newItem->disclosure;

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid using count() function in for loops.
    Open

            for ($i = 0; $i < count($this->unmatchedOldItems); $i++) {
                $oldItem = $this->unmatchedOldItems[$i];
                if ($this->isEquivalentAgendaItem($oldItem, $newItem)) {
                    array_splice($this->unmatchedOldItems, $i, 1); // Remove this object
    
    

    CountInLoopExpression

    Since: 2.7.0

    Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

    Example

    class Foo {
    
      public function bar()
      {
        $array = array();
    
        for ($i = 0; count($array); $i++) {
          // ...
        }
      }
    }

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

    Avoid excessively long variable names like $stadtratsvorlageParser. Keep variable name length under 20.
    Open

        public function __construct(StadtratsvorlageParser $stadtratsvorlageParser)

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $stadtratsvorlageParser. Keep variable name length under 20.
    Open

        private StadtratsvorlageParser $stadtratsvorlageParser;

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    There are no issues that match your filters.

    Category
    Status