jon48/webtrees-lib

View on GitHub
app/Module/GeoDispersion/Services/PlacesReferenceTableService.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

    public function targetId(string $source, string $source_format, string $target_format): ?string
    {
        // Extract parts for the WHERE clause
        $source_format = str_replace(['{', '}'], ['{#', '#}'], $source_format);
        $source_parts = preg_split('/[{}]/i', $source_format);
Severity: Minor
Found in app/Module/GeoDispersion/Services/PlacesReferenceTableService.php - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

                return $target_format;
    Severity: Major
    Found in app/Module/GeoDispersion/Services/PlacesReferenceTableService.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return str_replace(
                  array_map(fn($tag) => '{' . $tag . '}', $columns_select[1]),
                  array_map(fn($tag) => $mapping[$this->columnName($tag)] ?? '', $columns_select[1]),
                  $target_format
              );
      Severity: Major
      Found in app/Module/GeoDispersion/Services/PlacesReferenceTableService.php - About 30 mins to fix

        Avoid variables with short names like $id. Configured minimum length is 3.
        Open

                    $columns = array_unique(array_filter(array_map(fn($id) => $this->columnName($id), $columns_select[1])));

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#shortvariable

        There are no issues that match your filters.

        Category
        Status