@@ -526,17 +526,20 @@ reportImportCyclesRule :: Recorder (WithPriority Log) -> Rules ()
526
526
reportImportCyclesRule recorder =
527
527
defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ ReportImportCycles file -> fmap (\ errs -> if null errs then (Just " 1" ,([] , Just () )) else (Nothing , (errs, Nothing ))) $ do
528
528
DependencyInformation {.. } <- useNoFile_ GetModuleGraph
529
- let fileId = pathToId depPathIdMap file
530
- case IntMap. lookup (getFilePathId fileId) depErrorNodes of
531
- Nothing -> pure []
532
- Just errs -> do
533
- let cycles = mapMaybe (cycleErrorInFile fileId) (toList errs)
534
- -- Convert cycles of files into cycles of module names
535
- forM cycles $ \ (imp, files) -> do
536
- modNames <- forM files $ \ fileId -> do
537
- let file = idToPath depPathIdMap fileId
538
- getModuleName file
539
- pure $ toDiag imp $ sort modNames
529
+ case pathToId depPathIdMap file of
530
+ -- The header of the file does not parse, so it can't be part of any import cycles.
531
+ Nothing -> pure []
532
+ Just fileId ->
533
+ case IntMap. lookup (getFilePathId fileId) depErrorNodes of
534
+ Nothing -> pure []
535
+ Just errs -> do
536
+ let cycles = mapMaybe (cycleErrorInFile fileId) (toList errs)
537
+ -- Convert cycles of files into cycles of module names
538
+ forM cycles $ \ (imp, files) -> do
539
+ modNames <- forM files $ \ fileId -> do
540
+ let file = idToPath depPathIdMap fileId
541
+ getModuleName file
542
+ pure $ toDiag imp $ sort modNames
540
543
where cycleErrorInFile f (PartOfCycle imp fs)
541
544
| f `elem` fs = Just (imp, fs)
542
545
cycleErrorInFile _ _ = Nothing
0 commit comments