abrain/einsatzverwaltung

View on GitHub

Showing 151 of 250 total issues

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

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

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

        public function savePostdata(int $postId, WP_Post $post)
        {
            // Schreibrechte prüfen
            if (!current_user_can('edit_einsatzbericht', $postId)) {
                return;
    Severity: Minor
    Found in src/Data.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

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

        public function upgrade180()
        {
            // Rewrite post_type to evw_legacy_unit
            global $wpdb;
            $query = $wpdb->prepare("UPDATE $wpdb->posts SET post_type = %s WHERE post_type = %s", 'evw_legacy_unit', 'evw_unit');
    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 enqueueEditScripts has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function enqueueEditScripts($hook)
        {
            if ('post.php' == $hook || 'post-new.php' == $hook) {
                // Nur auf der Bearbeitungsseite anzeigen
                wp_enqueue_script(
    Severity: Major
    Found in src/Admin/Initializer.php - About 2 hrs to fix

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

          public function form($instance): string
          {
              $values = wp_parse_args($instance, $this->defaults);
      
              echo '<p>';
      Severity: Major
      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

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

          class Update
          {
              /**
               * Fürt ein Update der Datenbank duch
               *
          Severity: Minor
          Found in src/Update.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

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

                  public function echoSettingsPage()
                  {
                      if (!current_user_can('manage_options')) {
                          wp_die(__('You do not have sufficient permissions to manage options for this site.', 'einsatzverwaltung'));
                      }
              Severity: Major
              Found in src/Settings/MainPage.php - About 2 hrs to fix

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

                    public function upgrade180()
                    {
                        // Rewrite post_type to evw_legacy_unit
                        global $wpdb;
                        $query = $wpdb->prepare("UPDATE $wpdb->posts SET post_type = %s WHERE post_type = %s", 'evw_legacy_unit', 'evw_unit');
                Severity: Minor
                Found in src/Update.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 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 echoSingleReport has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function echoSingleReport(IncidentReport $report, $instance)
                          {
                              if (true === ($instance['showAnnotations'])) {
                                  $annotationIconBar = AnnotationIconBar::getInstance();
                                  printf('<div class="annotation-icon-bar">%s</div>', $annotationIconBar->render($report->getPostId()));
                      Severity: Minor
                      Found in src/Widgets/RecentIncidents.php - About 1 hr to fix

                        Method renderToolPage has 49 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

                          Method getInsertArgs has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function getInsertArgs(ReportInsertObject $reportImportObject)
                              {
                                  $args = array(
                                      'post_type' => Report::getSlug(),
                                      'post_title' => $reportImportObject->getTitle(),
                          Severity: Minor
                          Found in src/DataAccess/ReportInserter.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',
                                        __('Incident details', 'einsatzverwaltung'),
                            Severity: Minor
                            Found in src/Admin/ReportEditScreen.php - About 1 hr 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

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

                                    public function upgrade1100()
                                    {
                                        add_option('einsatzvw_category', '-1');
                                
                                        // Get roles and check if they were allowed to edit reports before
                                Severity: Minor
                                Found in src/Update.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(WP_Query $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

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

                                    private function upgrade130()
                                    {
                                        global $wpdb;
                                
                                        $taxonomies = array(
                                Severity: Minor
                                Found in src/Update.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