abrain/einsatzverwaltung

View on GitHub

Showing 247 of 250 total issues

File Update.php has 484 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace abrain\Einsatzverwaltung;

use WP_Error;
use WP_User;
Severity: Minor
Found in src/Update.php - About 7 hrs to fix

    File Formatter.php has 437 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    namespace abrain\Einsatzverwaltung\Util;
    
    use abrain\Einsatzverwaltung\Frontend\AnnotationIconBar;
    use abrain\Einsatzverwaltung\Model\IncidentReport;
    Severity: Minor
    Found in src/Util/Formatter.php - About 6 hrs to fix

      Function format has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          private function format(?WP_Post $post, string $pattern, string $tag, $context = 'post'): string
          {
              if ($post == null && !in_array($tag, $this->tagsNotNeedingPost)) {
                  return $pattern;
              }
      Severity: Minor
      Found in src/Util/Formatter.php - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      File ReportEditScreen.php has 344 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      namespace abrain\Einsatzverwaltung\Admin;
      
      use abrain\Einsatzverwaltung\Model\IncidentReport;
      use abrain\Einsatzverwaltung\Types\IncidentType;
      Severity: Minor
      Found in src/Admin/ReportEditScreen.php - About 4 hrs to fix

        Method renderToolPage has 106 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function renderToolPage()
            {
                $this->helper = new Helper($this->utilities, $this->data);
                $this->helper->metaFields = IncidentReport::getMetaFields();
                $this->helper->taxonomies = IncidentReport::getTerms();
        Severity: Major
        Found in src/Import/Tool.php - About 4 hrs to fix

          Function renderToolPage has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              public function renderToolPage()
              {
                  $this->helper = new Helper($this->utilities, $this->data);
                  $this->helper->metaFields = IncidentReport::getMetaFields();
                  $this->helper->taxonomies = IncidentReport::getTerms();
          Severity: Minor
          Found in src/Import/Tool.php - About 4 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method format has 102 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function format(?WP_Post $post, string $pattern, string $tag, $context = 'post'): string
              {
                  if ($post == null && !in_array($tag, $this->tagsNotNeedingPost)) {
                      return $pattern;
                  }
          Severity: Major
          Found in src/Util/Formatter.php - About 4 hrs to fix

            IncidentReport has 32 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class IncidentReport
            {
                /**
                 * Wenn es sich um einen bestehenden Beitrag handelt, ist hier das WordPress-Beitragsobjekt gespeichert.
                 *
            Severity: Minor
            Found in src/Model/IncidentReport.php - About 4 hrs to fix

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

                  public static function compare(WP_Term $unit1, WP_Term $unit2): int
                  {
                      $order1 = get_term_meta($unit1->term_id, 'unit_order', true);
                      $order2 = get_term_meta($unit2->term_id, 'unit_order', true);
              
              
              Severity: Major
              Found in src/Types/Unit.php and 1 other location - About 3 hrs to fix
              src/Types/Vehicle.php on lines 39..58

              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 static function compareVehicles(WP_Term $vehicle1, WP_Term $vehicle2): int
                  {
                      $order1 = get_term_meta($vehicle1->term_id, 'vehicleorder', true);
                      $order2 = get_term_meta($vehicle2->term_id, 'vehicleorder', true);
              
              
              Severity: Major
              Found in src/Types/Vehicle.php and 1 other location - About 3 hrs to fix
              src/Types/Unit.php on lines 37..56

              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

              File Helper.php has 307 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              namespace abrain\Einsatzverwaltung\Import;
              
              use abrain\Einsatzverwaltung\Data;
              use abrain\Einsatzverwaltung\Exceptions\ImportException;
              Severity: Minor
              Found in src/Import/Helper.php - About 3 hrs to fix

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

                class Renderer
                {
                    const TABLECLASS = 'einsatzverwaltung-reportlist';
                
                    /**
                Severity: Minor
                Found in src/Frontend/ReportList/Renderer.php by phpmd

                The class Report has 12 public methods. Consider refactoring Report to keep number of public methods under 10.
                Open

                class Report extends SubPage
                {
                    private $useReportTemplateOptions = array(
                        'no' => array(
                            'label' => 'Nicht verwenden (zeigt die klassische Einzelansicht)'
                Severity: Minor
                Found in src/Settings/Pages/Report.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 Frontend has an overall complexity of 68 which is very high. The configured complexity threshold is 50.
                Open

                class Frontend
                {
                    /**
                     * @var Formatter
                     */
                Severity: Minor
                Found in src/Frontend.php by phpmd

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

                class Data
                {
                    /**
                     * @var Options
                     */
                Severity: Minor
                Found in src/Data.php by phpmd

                The class Advanced has 11 public methods. Consider refactoring Advanced to keep number of public methods under 10.
                Open

                class Advanced extends SubPage
                {
                    /**
                     * @var array[]
                     */
                Severity: Minor
                Found in src/Settings/Pages/Advanced.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 IncidentReport has an overall complexity of 55 which is very high. The configured complexity threshold is 50.
                Open

                class IncidentReport
                {
                    /**
                     * Wenn es sich um einen bestehenden Beitrag handelt, ist hier das WordPress-Beitragsobjekt gespeichert.
                     *
                Severity: Minor
                Found in src/Model/IncidentReport.php by phpmd

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

                class Formatter
                {
                    private $tagsNotNeedingPost = array('%feedUrl%', '%yearArchive%');
                
                    /**
                Severity: Minor
                Found in src/Util/Formatter.php by phpmd

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

                class Update
                {
                    /**
                     * Fürt ein Update der Datenbank duch
                     *
                Severity: Minor
                Found in src/Update.php by phpmd

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

                class Helper
                {
                    /**
                     * @var Utilities
                     */
                Severity: Minor
                Found in src/Import/Helper.php by phpmd
                Severity
                Category
                Status
                Source
                Language