abrain/einsatzverwaltung

View on GitHub

Showing 132 of 306 total issues

File Formatter.php has 380 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 5 hrs to fix

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

        private function format($post, $pattern, $tag, $context = 'post')
        {
            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

    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

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

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

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

        <?php
        namespace abrain\Einsatzverwaltung;
        
        use abrain\Einsatzverwaltung\Types\Report;
        use abrain\Einsatzverwaltung\Types\Unit;
        Severity: Minor
        Found in src/Update.php - About 3 hrs to fix

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

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

            IncidentReport has 31 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 3 hrs to fix

              File Helper.php has 305 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

                Method form has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function form($instance)
                    {
                        $title = Utilities::getArrayValueIfKey($instance, 'title', 'Letzte Eins&auml;tze');
                        $anzahl = Utilities::getArrayValueIfKey($instance, 'anzahl', 3);
                        $selectedUnits = Utilities::getArrayValueIfKey($instance, 'units', array());
                Severity: Major
                Found in src/Widgets/RecentIncidents.php - About 3 hrs to fix

                  File Renderer.php has 297 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

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

                    Method registerPostMeta has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function registerPostMeta()
                        {
                            register_meta('post', 'einsatz_einsatzende', array(
                                'object_subtype' => self::getSlug(),
                                'type' => 'string',
                    Severity: Major
                    Found in src/Types/Report.php - About 2 hrs to fix

                      Function getCellContent has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function getCellContent($report, $colId, Parameters $parameters)
                          {
                              if (empty($report)) {
                                  return '&nbsp;';
                              }
                      Severity: Minor
                      Found in src/Frontend/ReportList/Renderer.php - About 2 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 getCellContent has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function getCellContent($report, $colId, Parameters $parameters)
                          {
                              if (empty($report)) {
                                  return '&nbsp;';
                              }
                      Severity: Major
                      Found in src/Frontend/ReportList/Renderer.php - About 2 hrs to fix

                        Function readFile has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function readFile($numLines = null, $requestedFields = array())
                            {
                                $fieldMap = array();
                                if (!empty($requestedFields)) {
                                    $fields = $this->getFields();
                        Severity: Minor
                        Found in src/Import/Sources/Csv.php - About 2 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 displayMetaBoxEinsatzdetails has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function displayMetaBoxEinsatzdetails($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

                          Function doUpdate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function doUpdate($currentDbVersion, $targetDbVersion)
                              {
                                  if (empty($targetDbVersion)) {
                                      return new WP_Error('', 'Zieldatenbankversion darf nicht leer sein');
                                  }
                          Severity: Minor
                          Found in src/Update.php - About 2 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 addMetaBoxes has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function addMetaBoxes()
                              {
                                  add_meta_box(
                                      'einsatzverwaltung_meta_box',
                                      'Einsatzdetails',
                          Severity: Major
                          Found in src/Admin/ReportEditScreen.php - About 2 hrs to fix

                            Method savePostdata has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function savePostdata($postId, $post)
                                {
                                    // Schreibrechte prüfen
                                    if (!current_user_can('edit_einsatzbericht', $postId)) {
                                        return;
                            Severity: Major
                            Found in src/Data.php - About 2 hrs to fix

                              File Data.php has 262 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              <?php
                              namespace abrain\Einsatzverwaltung;
                              
                              use abrain\Einsatzverwaltung\Model\IncidentReport;
                              use abrain\Einsatzverwaltung\Types\Report;
                              Severity: Minor
                              Found in src/Data.php - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language