abrain/einsatzverwaltung

View on GitHub
src/Admin/ReportEditScreen.php

Summary

Maintainability
D
2 days
Test Coverage
F
0%

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 displayMetaBoxEinsatzdetails has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function displayMetaBoxEinsatzdetails(WP_Post $post)
        {
            // Use nonce for verification
            wp_nonce_field('save_einsatz_details', 'einsatzverwaltung_nonce');
    
    
    Severity: Major
    Found in src/Admin/ReportEditScreen.php - About 2 hrs to fix

      Method displayMetaBoxVehicles has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function displayMetaBoxVehicles(WP_Post $post)
          {
              $vehicleTaxonomy = get_taxonomy(Vehicle::getSlug());
              if (empty($vehicleTaxonomy)) {
                  return;
      Severity: Minor
      Found in src/Admin/ReportEditScreen.php - About 2 hrs to fix

        Method addMetaBoxes has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addMetaBoxes()
            {
                add_meta_box(
                    'einsatzverwaltung_meta_box',
                    __('Incident details', 'einsatzverwaltung'),
        Severity: Minor
        Found in src/Admin/ReportEditScreen.php - About 1 hr to fix

          Method echoVehiclesByUnit has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function echoVehiclesByUnit(WP_Post $post, WP_Taxonomy $vehicleTaxonomy, array $vehicles, array $assignedVehicleIds)
              {
                  $unitTaxObj = get_taxonomy(Unit::getSlug());
                  if (empty($unitTaxObj)) {
                      return;
          Severity: Minor
          Found in src/Admin/ReportEditScreen.php - About 1 hr to fix

            Method filterIncidentCategoryDropdown has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function filterIncidentCategoryDropdown(string $output, array $parsedArgs): string
                {
                    if (!array_key_exists('taxonomy', $parsedArgs) || $parsedArgs['taxonomy'] !== IncidentType::getSlug()) {
                        return $output;
                    }
            Severity: Minor
            Found in src/Admin/ReportEditScreen.php - About 1 hr to fix

              Function echoVehiclesByUnit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function echoVehiclesByUnit(WP_Post $post, WP_Taxonomy $vehicleTaxonomy, array $vehicles, array $assignedVehicleIds)
                  {
                      $unitTaxObj = get_taxonomy(Unit::getSlug());
                      if (empty($unitTaxObj)) {
                          return;
              Severity: Minor
              Found in src/Admin/ReportEditScreen.php - About 55 mins 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

              Function displayMetaBoxVehicles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function displayMetaBoxVehicles(WP_Post $post)
                  {
                      $vehicleTaxonomy = get_taxonomy(Vehicle::getSlug());
                      if (empty($vehicleTaxonomy)) {
                          return;
              Severity: Minor
              Found in src/Admin/ReportEditScreen.php - About 35 mins 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

              Avoid too many return statements within this method.
              Open

                              return $vehicle->term_id;
              Severity: Major
              Found in src/Admin/ReportEditScreen.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return $newOutput;
                Severity: Major
                Found in src/Admin/ReportEditScreen.php - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status