codeformunich/Muenchen-Transparent

View on GitHub
protected/models/Antrag.php

Summary

Maintainability
F
3 days
Test Coverage

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

                RISTools::report_ris_parser_error("Antrag:moveToHistory Error", print_r($history->getErrors(), true));
Severity: Minor
Found in protected/models/Antrag.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 Antrag::resetPersonen() calls the typical debug function print_r() which is mostly only used during development.
Open

                RISTools::report_ris_parser_error("Antrag:resetPersonen Error", print_r($ap->getErrors(), true));
Severity: Minor
Found in protected/models/Antrag.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 Antrag::resetPersonen() calls the typical debug function print_r() which is mostly only used during development.
Open

                RISTools::report_ris_parser_error("Antrag:resetPersonen Error", print_r($ap->getErrors(), true));
Severity: Minor
Found in protected/models/Antrag.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 Antrag::rebuildVorgaenge() calls the typical debug function var_dump() which is mostly only used during development.
Open

            var_dump($e);
Severity: Minor
Found in protected/models/Antrag.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 Antrag.php has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * This is the model class for table "antraege".
 *
Severity: Minor
Found in protected/models/Antrag.php - About 5 hrs to fix

    Antrag has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Antrag extends CActiveRecord implements IRISItemHasDocuments
    {
    
        public const TYP_STADTRAT_ANTRAG = "stadtrat_antrag";
        public const TYP_STADTRAT_VORLAGE = "stadtrat_vorlage";
    Severity: Minor
    Found in protected/models/Antrag.php - About 3 hrs to fix

      The class Antrag has 19 public methods. Consider refactoring Antrag to keep number of public methods under 10.
      Open

      class Antrag extends CActiveRecord implements IRISItemHasDocuments
      {
      
          public const TYP_STADTRAT_ANTRAG = "stadtrat_antrag";
          public const TYP_STADTRAT_VORLAGE = "stadtrat_vorlage";
      Severity: Minor
      Found in protected/models/Antrag.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 Antrag has an overall complexity of 91 which is very high. The configured complexity threshold is 50.
      Open

      class Antrag extends CActiveRecord implements IRISItemHasDocuments
      {
      
          public const TYP_STADTRAT_ANTRAG = "stadtrat_antrag";
          public const TYP_STADTRAT_VORLAGE = "stadtrat_vorlage";
      Severity: Minor
      Found in protected/models/Antrag.php by phpmd

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

          private static function rebuildVorgaengeRekursiv($curr_antrag, &$gefundene_antraege, &$gefundene_tops, &$gefundene_dokumente, &$vorgang_id)
      Severity: Minor
      Found in protected/models/Antrag.php - About 35 mins to fix

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

            public function errateThemenverwandteAntraege($limit)
            {
                /** @var Antrag[] $rel_antraege */
                $rel_antraege = [];
                /** @var int[] $rel_antraege_count */
        Severity: Minor
        Found in protected/models/Antrag.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

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

            private static function rebuildVorgaengeRekursiv($curr_antrag, &$gefundene_antraege, &$gefundene_tops, &$gefundene_dokumente, &$vorgang_id)
            {
                /** @var Antrag $antrag */
                foreach (array_merge($curr_antrag->vorlage2antraege, $curr_antrag->antrag2vorlagen) as $ant) if (!isset($gefundene_antraege[$ant->id])) {
                    if ($ant->vorgang_id > 0 && $vorgang_id > 0 && $ant->vorgang_id != $vorgang_id) {
        Severity: Minor
        Found in protected/models/Antrag.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

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

                foreach ($aenderungen as $ae) {
        Severity: Minor
        Found in protected/models/Antrag.php by phpmd

        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 empty try-catch blocks in addAntrag.
        Open

                } catch (Exception $e) {
                }
        Severity: Minor
        Found in protected/models/Antrag.php by phpmd

        EmptyCatchBlock

        Since: 2.7.0

        Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

        Example

        class Foo {
        
          public function bar()
          {
              try {
                  // ...
              } catch (Exception $e) {} // empty catch block
          }
        }

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

        Avoid unused parameters such as '$von_ts'.
        Open

            public function findeAenderungen($von_ts, $bis_ts = 0)
        Severity: Minor
        Found in protected/models/Antrag.php by phpmd

        UnusedFormalParameter

        Since: 0.2

        Avoid passing parameters to methods or constructors and then not using those parameters.

        Example

        class Foo
        {
            private function bar($howdy)
            {
                // $howdy is not used
            }
        }

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

        Avoid unused parameters such as '$bis_ts'.
        Open

            public function findeAenderungen($von_ts, $bis_ts = 0)
        Severity: Minor
        Found in protected/models/Antrag.php by phpmd

        UnusedFormalParameter

        Since: 0.2

        Avoid passing parameters to methods or constructors and then not using those parameters.

        Example

        class Foo
        {
            private function bar($howdy)
            {
                // $howdy is not used
            }
        }

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

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

                foreach ($rel_antraege_count as $ant_id => $anz) {
        Severity: Minor
        Found in protected/models/Antrag.php by phpmd

        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 unused local variables such as '$gefundene_ergebnisse'.
        Open

                    $gefundene_ergebnisse[$ergebnis->id] = $ergebnis;
        Severity: Minor
        Found in protected/models/Antrag.php by phpmd

        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 empty try-catch blocks in addVorlage.
        Open

                } catch (Exception $e) {
                }
        Severity: Minor
        Found in protected/models/Antrag.php by phpmd

        EmptyCatchBlock

        Since: 2.7.0

        Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

        Example

        class Foo {
        
          public function bar()
          {
              try {
                  // ...
              } catch (Exception $e) {} // empty catch block
          }
        }

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

        TODO found
        Open

                    // @TODO var_dump($ae->getAttributes());
        Severity: Minor
        Found in protected/models/Antrag.php by fixme

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                foreach ($gestellt_von as $x) if (!in_array($x["name_normalized"], $indexed)) {
                    $indexed[]     = $x["name_normalized"];
                    $person        = Person::getOrCreate($x["name"], $x["name_normalized"]);
                    $ap            = new AntragPerson();
                    $ap->antrag_id = $this->id;
        Severity: Major
        Found in protected/models/Antrag.php and 1 other location - About 3 hrs to fix
        protected/models/Antrag.php on lines 347..358

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 159.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                foreach ($initiatorInnen as $x) if (!in_array($x["name_normalized"], $indexed)) {
                    $indexed[]     = $x["name_normalized"];
                    $person        = Person::getOrCreate($x["name"], $x["name_normalized"]);
                    $ap            = new AntragPerson();
                    $ap->antrag_id = $this->id;
        Severity: Major
        Found in protected/models/Antrag.php and 1 other location - About 3 hrs to fix
        protected/models/Antrag.php on lines 333..344

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 159.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            public function rules()
            {
                // NOTE: you should only define rules for those attributes that
                // will receive user inputs.
                return [
        Severity: Major
        Found in protected/models/Antrag.php and 1 other location - About 3 hrs to fix
        protected/models/AntragHistory.php on lines 57..73

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 151.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            public function attributeLabels()
            {
                return [
                    'id'                        => 'ID',
                    'vorgang_id'                => 'Vorgangs-ID',
        Severity: Major
        Found in protected/models/Antrag.php and 1 other location - About 2 hrs to fix
        protected/models/AntragHistory.php on lines 90..117

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 123.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            public function addAntrag($antrag)
            {
                try {
                    Yii::app()->db->createCommand()->insert("antraege_vorlagen", ["antrag2" => $antrag->id, "antrag1" => $this->id]);
                    $this->vorlage2antraege  = array_merge($this->vorlage2antraege, [$antrag]);
        Severity: Major
        Found in protected/models/Antrag.php and 1 other location - About 1 hr to fix
        protected/models/Antrag.php on lines 128..136

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 104.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            public function addVorlage($vorlage)
            {
                try {
                    Yii::app()->db->createCommand()->insert("antraege_vorlagen", ["antrag1" => $vorlage->id, "antrag2" => $this->id]);
                    $this->antrag2vorlagen     = array_merge($this->antrag2vorlagen, [$vorlage]);
        Severity: Major
        Found in protected/models/Antrag.php and 1 other location - About 1 hr to fix
        protected/models/Antrag.php on lines 141..149

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 104.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        There are no issues that match your filters.

        Category
        Status