Skip to content

[detector-report] PositionalTupleReturnDetector #428

Description

@jessegall

Detector: PositionalTupleReturnDetector

Report (why the flagged code is CORRECT and the detector is wrong):
This merges four lists of the SAME type into one list of that type — the method returns list and says so. A tuple bundles independent values that the caller takes apart by position; nothing here is taken apart, and every element is interchangeable with every other. The spread is concatenation, not packing.

Cleanest design the reporter can conceive:
A method that returns list building it by spreading the sublists it gathered, each of which is already list. That is what this is.

⚖️ Maintainer litmus: a valid detector-report needs the flagged code to ALREADY BE the
cleanest design. If the design above differs from the flagged code at all, THAT design is
the owed fix — close this report; the fix is still owed.

Where: src/View/Normalizers/RenderableNormalizer.php:223

Code (src/View/Normalizers/RenderableNormalizer.php:223):

  220              $renderable->looks(),
  221          );
  222223          return [...$asked, ...$puts, ...$goes, ...$looks];
  224      }
  225  
  226      /**
  227       * What the gesture must bring with it, each named field standing in for a value only the browser has.
  228       *
  229       * @param  class-string<Interaction>  $reported
  230       * @return array<string, array<string, string>>
  231       */
  232      private static function asked(string $reported): array
  233      {
  234          if (! is_a($reported, Carries::class, true))
  235          {
  236              return [];
  237          }
  238  
  239          $asked = [];
  240  
  241          foreach ($reported::carries() as $named => $field)
  242          {
  243              $asked[$named] = [self::GESTURE => $field];
  244          }
  245  
  246          return $asked;
  247      }

Filed via commandments report from a consumer project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions