codeformunich/Muenchen-Transparent

View on GitHub
protected/commands/GoogleSitemapCreateCommand.php

Summary

Maintainability
F
4 days
Test Coverage

Method run has 93 lines of code (exceeds 30 allowed). Consider refactoring.
Open

    public function run($args)
    {

        $sitemap_files = [];

Severity: Major
Found in protected/commands/GoogleSitemapCreateCommand.php - About 3 hrs to fix

    The method run() has 139 lines of code. Current threshold is set to 100. Avoid really long methods.
    Open

        public function run($args)
        {
    
            $sitemap_files = [];
    
    

    The method run() has an NPath complexity of 4608. The configured NPath complexity threshold is 200.
    Open

        public function run($args)
        {
    
            $sitemap_files = [];
    
    

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

        public function run($args)
        {
    
            $sitemap_files = [];
    
    

    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 parameters such as '$args'.
    Open

        public function run($args)

    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 using count() function in for loops.
    Open

                for ($i = $sm_page * 30000; $i < ($sm_page + 1) * 30000 && $i < count($termine); $i++) {
                    $dok = $termine[$i];
                    fwrite($fp, "<url>\n<loc>" . SITE_BASE_URL . "/termine/" . $dok["id"] . "/</loc>\n");
                    fwrite($fp, "<changefreq>weekly</changefreq>\n");
                    fwrite($fp, "<lastmod>" . $datumformat($dok["datum_letzte_aenderung"]) . "</lastmod>\n");

    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 using count() function in for loops.
    Open

                for ($i = $sm_page * 30000; $i < ($sm_page + 1) * 30000 && $i < count($dokumente); $i++) {
                    $dok = $dokumente[$i];
                    fwrite($fp, "<url>\n<loc>" . SITE_BASE_URL . "/dokumente/" . $dok["id"] . "/</loc>\n");
                    fwrite($fp, "<changefreq>monthly</changefreq>\n");
                    fwrite($fp, "<lastmod>" . $datumformat($dok["datum"]) . "</lastmod>\n");

    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 using count() function in for loops.
    Open

                for ($i = $sm_page * 30000; $i < ($sm_page + 1) * 30000 && $i < count($antraege); $i++) {
                    $dok = $antraege[$i];
                    fwrite($fp, "<url>\n<loc>" . SITE_BASE_URL . "/antraege/" . $dok["id"] . "/</loc>\n");
                    fwrite($fp, "<changefreq>weekly</changefreq>\n");
                    fwrite($fp, "<lastmod>" . $datumformat($dok["datum_letzte_aenderung"]) . "</lastmod>\n");

    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

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

            for ($sm_page = 0; $sm_page < $sm_num; $sm_page++) {
                echo "Anträge - Seite $sm_page\n";
    
                $sitemap_file = "sitemap-antraege-" . $sm_page . ".xml";
                $fp           = fopen($sitemap_basepath . $sitemap_file, "w");
    Severity: Major
    Found in protected/commands/GoogleSitemapCreateCommand.php and 2 other locations - About 1 day to fix
    protected/commands/GoogleSitemapCreateCommand.php on lines 29..49
    protected/commands/GoogleSitemapCreateCommand.php on lines 87..107

    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 287.

    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 3 locations. Consider refactoring.
    Open

            for ($sm_page = 0; $sm_page < $sm_num; $sm_page++) {
                echo "Termine - Seite $sm_page\n";
    
                $sitemap_file = "sitemap-termine-" . $sm_page . ".xml";
                $fp           = fopen($sitemap_basepath . $sitemap_file, "w");
    Severity: Major
    Found in protected/commands/GoogleSitemapCreateCommand.php and 2 other locations - About 1 day to fix
    protected/commands/GoogleSitemapCreateCommand.php on lines 29..49
    protected/commands/GoogleSitemapCreateCommand.php on lines 58..78

    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 287.

    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 3 locations. Consider refactoring.
    Open

            for ($sm_page = 0; $sm_page < $sm_num; $sm_page++) {
                echo "Dokumente - Seite $sm_page\n";
    
                $sitemap_file = "sitemap-dokumente-" . $sm_page . ".xml";
                $fp           = fopen($sitemap_basepath . $sitemap_file, "w");
    Severity: Major
    Found in protected/commands/GoogleSitemapCreateCommand.php and 2 other locations - About 1 day to fix
    protected/commands/GoogleSitemapCreateCommand.php on lines 58..78
    protected/commands/GoogleSitemapCreateCommand.php on lines 87..107

    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 287.

    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