ndmitchell / hlint

Haskell source code suggestions
Other
1.47k stars 196 forks source link

Parse errors are listed as hints #704

Open recursion-ninja opened 5 years ago

recursion-ninja commented 5 years ago

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.

ndmitchell commented 5 years ago

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.

recursion-ninja commented 5 years ago

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.

ndmitchell commented 5 years ago

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