hlint icon indicating copy to clipboard operation
hlint copied to clipboard

Parse errors are listed as hints

Open recursion-ninja opened this issue 6 years ago • 3 comments

When I run hlint on our code base there are 3 parse errors and two hints, however the textual report says "5 hints".

hlint --no-exit-code app test ./lib/pcg-evaluation ./lib/pcg-data-unification ./lib/pcg-error-phase ./lib/pcg-language ./lib/pcg-file-parsers ./lib/pcg-file-source ./lib/pcg-data-normalization ./lib/pcg-alphabet ./lib/pcg-utility ./lib/pcg-serialize ./lib/pcg-tcm-memo ./lib/pcg-core ./lib/pcg-validation-transformer ./lib/pcg-exportable 
./lib/pcg-file-parsers/src/File/Format/Fasta/Parser.hs:120:34: Warning: Prefer fold to mconcat
Found:
  mconcat
Perhaps:
  fold

./lib/pcg-file-parsers/src/File/Format/Fasta/Parser.hs:132:20: Warning: Prefer fold to mconcat
Found:
  mconcat
Perhaps:
  fold

./lib/pcg-data-normalization/src/Data/Normalization/Metadata/Internal.hs:73:38: Error: Parse error
Found:
      where
        f  NormalizedContinuousCharacter {}       = mempty
  >     f (NormalizedDiscreteCharacter   static ) = foldMap toList static
        f (NormalizedDynamicCharacter    dynamic) = foldMap (foldMap toList) dynamic
  

./lib/pcg-utility/src/Numeric/Cost.hs:163:21: Error: Parse error
Found:
          case hasCycle xs of
            Nothing                  -> let t@(_,r) = (v*10) `quotRem` den in go r $ xs |> t
  >         Just (static, repeating) -> render static <> addOverline (render repeating)
    
        addOverline = (<>[c]) . intersperse c
  

./lib/pcg-core/pcg-data-structures/src/Bio/Graph/PhylogeneticDAG/DynamicCharacterRerooting.hs:406:34: Error: Parse error
Found:
            deriveMinimalSequenceForDisplayTree = fmap recomputeCost . foldr1 (zipWith minimizeBlock) . fmap createZippableContext
              where
  >             minimizeBlock (static, dynCharVect1) (_, dynCharVect2) = (static, minimizedDynamicCharacterVector)
                  where
                    minimizedDynamicCharacterVector = zipWith minimizeDynamicCharacterRooting dynCharVect1 dynCharVect2
  

5 hints

Parse errors aren't really "hints," so they shouldn't counted in the total.

recursion-ninja avatar Jul 05 '19 18:07 recursion-ninja

You could just ignore parse errors if you don't care about them. However, in many cases you can change the flags to HLint to make them parse, so I by default report then.

ndmitchell avatar Jul 07 '19 06:07 ndmitchell

I think reporting the parse errors is useful and informative, but they shouldn't be included in the hint total.

I think the last line should read:

3 hints, 2 parse errors

This way you don't need to mentally parse the output to determine if there were parse errors when HLint ran, HLint tells you there were parse errors.

recursion-ninja avatar Aug 20 '19 18:08 recursion-ninja

That seems quite reasonable to adjust the status line. PR welcome!

ndmitchell avatar Sep 29 '19 21:09 ndmitchell