jon48/webtrees-mod-maj-geodata-france

View on GitHub

Showing 8 of 8 total issues

Function mappingsForMap has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function mappingsForMap(string $map_id): array
    {
        $mapping = [];
        if ($this->endsWith($map_id, '-departements')) {
            return self::MAPPINGS_DEPARTEMENTS;
Severity: Minor
Found in app/PlaceMappers/SimpleFrancePlaceMapper.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 listMapDefinition has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function listMapDefinition(): array
    {
        $filesystem = new Filesystem(new LocalFilesystemAdapter($this->resourcesFolder() . 'maps/'));

        //phpcs:disable Generic.Files.LineLength.TooLong
Severity: Minor
Found in app/GeoDataFranceModule.php - About 1 hr to fix

    Method placeMapProvider has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function placeMapProvider(): array
        {
            $valid_resources = __DIR__ . '/../../resources/valid';
            $invalid_resources = __DIR__ . '/../../resources/invalid';
            $not_exist_resources = __DIR__ . '/../../resources/doesnotexist';
    Severity: Minor
    Found in tests/unit/PlaceMappers/SimpleFrancePlaceMapperTest.php - About 1 hr to fix

      Method mappingsForMap has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function mappingsForMap(string $map_id): array
          {
              $mapping = [];
              if ($this->endsWith($map_id, '-departements')) {
                  return self::MAPPINGS_DEPARTEMENTS;
      Severity: Minor
      Found in app/PlaceMappers/SimpleFrancePlaceMapper.php - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                return $mapping;
        Severity: Major
        Found in app/PlaceMappers/SimpleFrancePlaceMapper.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return $mapping;
          Severity: Major
          Found in app/PlaceMappers/SimpleFrancePlaceMapper.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return array_merge(
                                $mapping,
                                $mappings_new_communes['12'] ?? [],
                                $mappings_new_communes['15'] ?? [],
                                $mappings_new_communes['43'] ?? [],
            Severity: Major
            Found in app/PlaceMappers/SimpleFrancePlaceMapper.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return array_merge($mapping, $mappings_new_communes[$dept_match[1]] ?? []);
              Severity: Major
              Found in app/PlaceMappers/SimpleFrancePlaceMapper.php - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language