abrain/einsatzverwaltung

View on GitHub

Showing 265 of 272 total issues

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

<?php
namespace abrain\Einsatzverwaltung;

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

    Function getCellContent has a Cognitive Complexity of 20 (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 66 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 registerPostMeta has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Method savePostdata has 57 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

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

              public function form($instance)
              {
                  $values = wp_parse_args($instance, $this->defaults);
          
                  echo '<p>';
          Severity: Major
          Found in src/Widgets/RecentIncidentsFormatted.php - About 2 hrs to fix

            File RecentIncidentsFormatted.php has 258 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            namespace abrain\Einsatzverwaltung\Widgets;
            
            use abrain\Einsatzverwaltung\ReportQuery;
            use abrain\Einsatzverwaltung\Types\Unit;
            Severity: Minor
            Found in src/Widgets/RecentIncidentsFormatted.php - About 2 hrs to fix

              AbstractSource has 21 functions (exceeds 20 allowed). Consider refactoring.
              Open

              abstract class AbstractSource
              {
                  /**
                   * @var Utilities
                   */
              Severity: Minor
              Found in src/Import/Sources/AbstractSource.php - About 2 hrs to fix

                Function doUpdate has a Cognitive Complexity of 16 (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 displayMetaBoxEinsatzdetails has 51 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

                  Method upgrade120 has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function upgrade120()
                      {
                          global $wpdb;
                  
                          // Alle veröffentlichten Einsatzberichte einer Kategorie hinzufügen, wenn diese in den Einstellungen für die
                  Severity: Major
                  Found in src/Update.php - About 2 hrs to fix

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

                                'labels' => array(
                                    'name' => 'Externe Einsatzmittel',
                                    'singular_name' => 'Externes Einsatzmittel',
                                    'menu_name' => 'Externe Einsatzmittel',
                                    'search_items' => 'Externe Einsatzmittel suchen',
                    Severity: Major
                    Found in src/Types/ExtEinsatzmittel.php and 1 other location - About 2 hrs to fix
                    src/Types/Alarmierungsart.php on lines 27..47

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

                    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

                                'labels' => array(
                                    'name' => 'Alarmierungsarten',
                                    'singular_name' => 'Alarmierungsart',
                                    'menu_name' => 'Alarmierungsarten',
                                    'search_items' => 'Alarmierungsart suchen',
                    Severity: Major
                    Found in src/Types/Alarmierungsart.php and 1 other location - About 2 hrs to fix
                    src/Types/ExtEinsatzmittel.php on lines 28..48

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

                    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

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

                        public function registerSettings()
                        {
                            register_setting(
                                'einsatzvw_settings_report',
                                'einsatzvw_einsatz_hideemptydetails',
                    Severity: Minor
                    Found in src/Settings/Pages/Report.php - About 2 hrs to fix

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

                          public function renderMatchForm($source, $args)
                          {
                              $defaults = array(
                                  'mapping' => array(),
                                  'next_action' => null,
                      Severity: Minor
                      Found in src/Import/Helper.php - About 1 hr to fix

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

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

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

                              public function renderToolPage()
                              {
                                  echo '<div class="wrap">';
                                  echo '<h1>' . 'Einsatzberichte exportieren' . '</h1>';
                                  echo '<p>Dieses Werkzeug exportiert Einsatzberichte in verschiedenen Formaten.</p>'; ?>
                          Severity: Minor
                          Found in src/Export/Tool.php - About 1 hr to fix

                            Function mapEntryToInsertArgs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function mapEntryToInsertArgs($mapping, $sourceEntry, &$insertArgs)
                                {
                                    foreach ($mapping as $sourceField => $ownField) {
                                        if (empty($ownField) || !is_string($ownField)) {
                                            $this->utilities->printError("Feld '$ownField' ung&uuml;ltig");
                            Severity: Minor
                            Found in src/Import/Helper.php - About 1 hr 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 addReportsToQuery has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function addReportsToQuery($query)
                                {
                                    // Nur, wenn Filter erlaubt sind, soll weitergemacht werden
                                    if (!empty($query->query_vars['suppress_filters'])) {
                                        return;
                            Severity: Minor
                            Found in src/Frontend.php - About 1 hr 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

                            Severity
                            Category
                            Status
                            Source
                            Language