ucsd-progsys / liquid-fixpoint

Horn Clause Constraint Solving for Liquid Types
BSD 3-Clause "New" or "Revised" License
132 stars 60 forks source link

Stan static analysis using `.hie` files. #610

Open philderbeast opened 2 years ago

philderbeast commented 2 years ago

I've tried running stan over liquid-fixpoint. Some of its suggestions I expect we'd want to pursue. Like with the recent hlint changes there are some hints we'd ignore and there is a config file where we can turn those off.

philderbeast commented 2 years ago

For the foldl anti-pattern stan finds a few hints like the following:

Screen Shot 2022-07-30 at 9 23 58 AM

The same thing from the command line:

  File:         src/Language/Fixpoint/Parse.hs
  Module:       Language.Fixpoint.Parse
  LoC:          1652
  Observations: 1
  Extensions from .cabal:
  Extensions from module: FlexibleContexts, FlexibleInstances, NoMonomorphismRestriction, UndecidableInstances, DeriveGeneric, OverloadedStrings
 ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 ┃  ✦ ID:            OBS-STAN-0202-6VNRVE-1385:18
 ┃  ✦ Severity:      Error
 ┃  ✦ Inspection ID: STAN-0202
 ┃  ✦ Name:          Anti-pattern: foldl
 ┃  ✦ Description:   Usage of space-leaking function 'foldl'
 ┃  ✦ Category:      #SpaceLeak #AntiPattern
 ┃  ✦ File:          src/Language/Fixpoint/Parse.hs
 ┃
 ┃  1384 ┃
 ┃  1385 ┃     rwMap      = foldl insert (M.fromList []) rwEntries
 ┃  1386 ┃                  ^^^^^
 ┃
 ┃  💡 Possible solution:
 ┃      ⍟ Replace 'foldl' with 'foldl''
 ┃      ⍟ Use 'foldr (flip . f)` instead of 'foldl f'