abrain/einsatzverwaltung

View on GitHub

Showing 151 of 250 total issues

Function updateSequenceNumbers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function updateSequenceNumbers($yearToUpdate = null)
    {
        if (empty($yearToUpdate)) {
            $years = self::getYearsWithReports();
        }
Severity: Minor
Found in src/Data.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

Method getLabels has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getLabels(): array
    {
        return array(
            'name' => _x('Incident Reports', 'post type general name', 'einsatzverwaltung'),
            'singular_name' => _x('Incident Report', 'post type singular name', 'einsatzverwaltung'),
Severity: Minor
Found in src/Types/Report.php - About 1 hr to fix

    Method widget has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function widget($args, $instance)
        {
            $settings = wp_parse_args($instance, $this->defaults);
            $title = empty($settings['title']) ? $this->defaultTitle : $settings['title'];
            $filteredTitle = apply_filters('widget_title', $title);
    Severity: Minor
    Found in src/Widgets/RecentIncidentsFormatted.php - About 1 hr to fix

      Method onInit has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function onInit()
          {
              $this->maybeUpdate();
      
              $this->utilities = new Utilities();
      Severity: Minor
      Found in src/Core.php - About 1 hr to fix

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

            public function registerSettings()
            {
                register_setting(
                    'einsatzvw_settings_advanced',
                    'einsatzvw_rewrite_slug',
        Severity: Minor
        Found in src/Settings/Pages/Advanced.php - About 1 hr to fix

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

              public function validateMapping($mapping, $source)
              {
                  $valid = true;
          
                  // Pflichtfelder prüfen
          Severity: Minor
          Found in src/Import/Helper.php - About 1 hr to fix

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

                public function create_item($request) // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- overridden method
                {
                    $params = $request->get_params();
            
                    $start_date_time = DateTimeImmutable::createFromFormat(DATE_RFC3339, $params['date_start']);
            Severity: Minor
            Found in src/Api/Reports.php - About 1 hr to fix

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

                  public function checkPreconditions()
                  {
                      $this->fileHasHeadlines = (bool) Utilities::getArrayValueIfKey($this->args, 'has_headlines', false);
              
                      $delimiter = Utilities::getArrayValueIfKey($this->args, 'delimiter', false);
              Severity: Minor
              Found in src/Import/Sources/Csv.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

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

                      public function __construct(Data $data, Options $options, Utilities $utilities, PermalinkController $permalinkController)
                      {
                          $pluginBasename = Core::$pluginBasename;
                          add_action('admin_menu', array($this, 'hideTaxonomies'));
                          add_action('admin_notices', array($this, 'displayAdminNotices'));
                  Severity: Minor
                  Found in src/Admin/Initializer.php - About 1 hr to fix

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

                        public function render(int $postId, $annotationIds = array()): string
                        {
                            $annotationRepository = ReportAnnotationRepository::getInstance();
                            $string = '';
                            $annotations = array();
                    Severity: Minor
                    Found in src/Frontend/AnnotationIconBar.php - About 1 hr to fix

                      Method addSettingsFields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function addSettingsFields()
                          {
                              add_settings_field(
                                  'einsatzvw_einsatznummer_auto',
                                  __('Mode', 'einsatzverwaltung'),
                      Severity: Minor
                      Found in src/Settings/Pages/Numbers.php - About 1 hr to fix

                        Method getVehiclesByUnitString has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getVehiclesByUnitString(array $vehiclesByUnitId): string
                            {
                                if (empty($vehiclesByUnitId)) {
                                    return '';
                                }
                        Severity: Minor
                        Found in src/Util/Formatter.php - About 1 hr to fix

                          Function getTypesOfAlerting has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function getTypesOfAlerting(IncidentReport $report, bool $makeLinks): string
                              {
                                  if (empty($report)) {
                                      return '';
                                  }
                          Severity: Minor
                          Found in src/Util/Formatter.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 constructList has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function constructList($reports, Parameters $parameters)
                              {
                                  if (empty($reports)) {
                                      $this->string = sprintf(
                                          '<span>%s</span>',
                          Severity: Minor
                          Found in src/Frontend/ReportList/Renderer.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 getMetaQuery has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function getMetaQuery(): array
                              {
                                  $metaQuery = [];
                          
                                  if ($this->onlySpecialReports) {
                          Severity: Minor
                          Found in src/ReportQuery.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 prepareArgsForInsertPost has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function prepareArgsForInsertPost(&$insertArgs, $dateTimeFormat, $postStatus, $alarmzeit)
                              {
                                  // Datum des Einsatzes prüfen
                                  if (false === $alarmzeit) {
                                      throw new ImportPreparationException(sprintf(
                          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

                          Method getTypesOfAlerting has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function getTypesOfAlerting(IncidentReport $report, bool $makeLinks): string
                              {
                                  if (empty($report)) {
                                      return '';
                                  }
                          Severity: Minor
                          Found in src/Util/Formatter.php - About 1 hr to fix

                            Method echoFieldColumns has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function echoFieldColumns()
                                {
                                    $columnRepository = ColumnRepository::getInstance();
                                    $columnIdentifiers = explode(',', get_option('einsatzvw_list_columns', ''));
                                    $enabledColumns = $columnRepository->getColumnsByIdentifier($columnIdentifiers);
                            Severity: Minor
                            Found in src/Settings/Pages/ReportList.php - About 1 hr to fix

                              Method upgrade113 has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function upgrade113()
                                  {
                                      if (!function_exists('get_editable_roles')) {
                                          require_once(ABSPATH . 'wp-admin/includes/user.php');
                                      }
                              Severity: Minor
                              Found in src/Update.php - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language