Skip to content
Snippets Groups Projects
  • Iustin Pop's avatar
    Further hlint fixes · 5b11f8db
    Iustin Pop authored
    Commit 2cdaf225, “Re-enable standard hlint warnings”, got it almost
    right. The only problem is that (confusingly) the default set of hints
    is not in HLint.Default, but in HLint.HLint (it includes Default and
    some built-ins).
    
    After changing the lint file to correctly include the defaults, we had
    another 128 suggestions:
    
      - Error: Eta reduce (2)
      - Error: Redundant bracket (4)
      - Error: Redundant do (17)
      - Error: Redundant lambda (7)
      - Error: Redundant return (1)
      - Warning: Avoid lambda (2)
      - Warning: Redundant $ (42)
      - Warning: Redundant bracket (35)
      - Warning: Use : (1)
      - Warning: Use String (4)
      - Warning: Use camelCase (10)
      - Warning: Use section (3)
    
    which are fixed by the current patch. Note that the 10 "Use camelCase"
    were all due to hlint not “knowing” the idiom of ‘case_’ (it does for
    ‘prop_’), for which I filled
    http://code.google.com/p/ndmitchell/issues/detail?id=558
    
    .
    
    Signed-off-by: default avatarIustin Pop <iustin@google.com>
    Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
    5b11f8db
lint-hints.hs 669 B
{-| Custom hint lints for Ganeti.

Since passing --hint to hlint will override, not extend the built-in
hints, we need to import the existing hints so that we get full
coverage.

-}

import "hint" HLint.HLint
import "hint" HLint.Dollar

-- The following two hints warn to simplify e.g. "map (\v -> (v,
-- True)) lst" to "zip lst (repeat True)", which is more abstract
warn = map (\v -> (v, x)) y ==> zip y (repeat x)
  where _ = notIn v x
warn = map (\v -> (x, v)) ==> zip (repeat x)
  where _ = notIn v x

-- The following warn on use of length instead of null
warn = length x > 0 ==> not (null x)
warn = length x /= 0 ==> not (null x)
warn = length x == 0 ==> null x