Skip to content

[detector-report] DanglingRouteNameDetector #587

Description

@jessegall

Detector: DanglingRouteNameDetector

Report (why the flagged code is CORRECT and the detector is wrong):
RouteNames::groupPrefix calls getArgs() on any call named group; a first-class callable such as self::group(...) is a CallLike whose getArgs() asserts !isFirstClassCallable() in php-parser, so the detector crashes and judge skips it. Guard with isFirstClassCallable() before reading arguments (vendor RouteNames.php:191).

Where: src/View/Kit/Rows/Prefabs/ChoiceRowPrefab.php:19

Code (src/View/Kit/Rows/Prefabs/ChoiceRowPrefab.php:19):

  16  
  17      public const Closure pick = self::pick(...);
  1819      public const Closure group = self::group(...);
  20  
  21      # ----------[ Factories ]----------
  22  
  23      public static function row(string $title, string $icon, string | null $hint = null): ChoiceRow
  24      {
  25          $row = ChoiceRow::labelled($title)->icon(Icon::of($icon));
  26  
  27          return $hint === null ? $row : $row->hint($hint);
  28      }
  29  
  30      public static function pick(string $label, string | null $meta = null): ChoiceRow
  31      {
  32          $row = ChoiceRow::labelled($label)->picking();
  33  
  34          return $meta === null ? $row : $row->explained($meta);
  35      }
  36  
  37      public static function group(ChoiceRow ...$rows): Box
  38      {
  39          return Box::build()
  40              ->style(Gap::Hairline)
  41              ->of(...$rows);
  42      }
  43  }

Where: src/View/Kit/Surfaces/Prefabs/SidebarPrefab.php:39

Code (src/View/Kit/Surfaces/Prefabs/SidebarPrefab.php:39):

  36  
  37          $groups = Box::build()
  38              ->style(SkeletonStylesheet::groups)
→ 39              ->of(...array_map(self::group(...), self::SECTIONS));
  40  
  41          return Sidebar::of($head, $groups)->on($side);
  42      }
  43  
  44      /**
  45       * @param  list<Width>  $widths
  46       */
  47      private static function group(array $widths): Box
  48      {
  49          return Box::build()
  50              ->style(SkeletonStylesheet::group)
  51              ->of(...Skeleton::lines($widths));
  52      }
  53  }

Where: src/View/Scenes/Wizards/Agent/Screens/BrowseAgents.php:184

Code (src/View/Scenes/Wizards/Agent/Screens/BrowseAgents.php:184):

  181  
  182      private static function accounts(BrowseAgents | Reactive $component): Component
  183      {
→ 184          return Listing::of(array_merge(...Components::map(self::group(...), $component->state->accounts)));
  185      }
  186  
  187      /**
  188       * @return list<Component>
  189       */
  190      private static function group(AccountGroup $group): array
  191      {
  192          return [
  193              GroupBand::of($group->label, count($group->accounts)),
  194              ChoiceRow::whenNot($group->available)
  195                  ->row(self::NOT_INSTALLED, self::ICON)
  196                  ->aliased(self::MISSING_ALIAS.$group->provider),
  197              self::accountRows($group),
  198              self::adding($group),
  199          ];
  200      }
  201  
  202      private static function accountRows(AccountGroup $group): Component
  203      {
  204          if (! $group->accounts)
  205          {
  206              return new None;
  207          }
  208  

Filed via commandments report from a consumer project.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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