Skip to content

Commit 0648d5d

Browse files
committed
Fix
1 parent 5e5356c commit 0648d5d

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/ShellCheck/Analytics.hs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3314,14 +3314,12 @@ checkUncheckedCdPushdPopd params root =
33143314
checkElement _ = return ()
33153315
getName t = fromMaybe "" $ getCommandName t
33163316
isLastCommandInFunction t =
3317-
case getPath (parentMap params) t of
3318-
_ NE.:| T_BraceGroup _ commands:T_Function {}:_ -> t `isLastOf` commands
3319-
_ -> False
3320-
isLastOf t commands =
3321-
case commands of
3322-
[x] -> x == t
3323-
_:rest -> isLastOf t rest
3324-
[] -> False
3317+
go $ NE.tail $ getPath (parentMap params) t
3318+
where
3319+
go (child:T_BraceGroup _ commands:T_Function {}:_) =
3320+
not (null commands) && getId (last commands) == getId child
3321+
go (_:rest) = go rest
3322+
go [] = False
33253323
isSafeDir t = case oversimplify t of
33263324
[_, str] -> str `matches` regex
33273325
_ -> False

0 commit comments

Comments
 (0)