From 225f769a2321ad551fc55affd9066b91dc047fc3 Mon Sep 17 00:00:00 2001 From: Ranjeet Kumar Ranjan Date: Tue, 14 Sep 2021 21:13:17 +0530 Subject: [PATCH 1/5] Add a CI that fails if line length exceeds 80 --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 33662c5e38..3eae20eb6d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -391,7 +391,8 @@ jobs: bash -c "$PACKCHECK $BUILD" || exit 1 echo "Checking trailing spaces..." count=$(find . -name "*.hs" -exec grep -H '\ $' {} \; | tee /dev/tty | wc -l) - exit $count + count2=$(awk '{ if (length($0) > 80) {print "Line length exceeds 80 : " length($0); print $0; print FILENAME; } }' *.hs | tee /dev/tty | wc -l) + exit $((count+count2)) - *save workflows: From bfd1741a4f331cfe4c2e84022d8e0154bc27023d Mon Sep 17 00:00:00 2001 From: Ranjeet Kumar Ranjan Date: Tue, 14 Sep 2021 22:56:23 +0530 Subject: [PATCH 2/5] Fix Hlint --- .circleci/config.yml | 2 +- .../Internal/Data/Array/Prim/MutTypesInclude.hs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3eae20eb6d..b72b01d86d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -418,4 +418,4 @@ workflows: #- coveralls-ghc-8_10_2: # name: GHC 8.10.2 + inspection + coverage + Werror - hlint-src: - name: Hlint src + Trailing Spaces + name: Hlint src + Trailing Spaces + Column Length diff --git a/src/Streamly/Internal/Data/Array/Prim/MutTypesInclude.hs b/src/Streamly/Internal/Data/Array/Prim/MutTypesInclude.hs index a50421001b..e8784a2eb0 100644 --- a/src/Streamly/Internal/Data/Array/Prim/MutTypesInclude.hs +++ b/src/Streamly/Internal/Data/Array/Prim/MutTypesInclude.hs @@ -44,7 +44,7 @@ unsafeCopy :: -> m () unsafeCopy (Array dst#) (I# doff#) (Array src#) (I# soff#) (I# n#) = liftIO $ do - let toBytes cnt# = cnt# *# (sizeOf# (undefined :: a)) + let toBytes cnt# = cnt# *# sizeOf# (undefined :: a) primitive_ $ copyMutableByteArray# src# @@ -127,7 +127,7 @@ shrinkArray :: -> m () shrinkArray (Array arr#) (I# n#) = liftIO $ do - let bytes = n# *# (sizeOf# (undefined :: a)) + let bytes = n# *# sizeOf# (undefined :: a) primitive_ (shrinkMutableByteArray# arr# bytes) -- | Fold the whole input to a single array. @@ -215,14 +215,14 @@ writeNUnsafe n = FL.rmapM extract $ FL.foldlM' step initial fromStreamDN :: (MonadIO m, Prim a) => Int -> D.Stream m a -> m (Array a) fromStreamDN limit str = do marr <- newArray (max limit 0) - let step i x = i `seq` (unsafeWriteIndex marr i x) >> return (i + 1) + let step i x = i `seq` unsafeWriteIndex marr i x >> return (i + 1) n <- D.foldlM' step (return 0) $ D.take limit str shrinkArray marr n return marr {-# INLINE fromStreamD #-} fromStreamD :: (MonadIO m, Prim a) => D.Stream m a -> m (Array a) -fromStreamD str = D.fold write str +fromStreamD = D.fold write {-# INLINABLE fromListNM #-} fromListNM :: (MonadIO m, Prim a) => Int -> [a] -> m (Array a) @@ -336,7 +336,7 @@ packArraysChunksOf n (D.Stream step state) = then D.Skip $ SpliceYielding arr (SpliceInitial s) else D.Skip $ SpliceBuffering s arr D.Skip s -> return $ D.Skip (SpliceInitial s) - D.Stop -> return $ D.Stop + D.Stop -> return D.Stop step' gst (SpliceBuffering st buf) = do r <- step gst st From 04945cc5b6a0507d7d32437d4403fa651e3bd07d Mon Sep 17 00:00:00 2001 From: Ranjeet Kumar Ranjan Date: Mon, 8 Nov 2021 16:53:50 +0530 Subject: [PATCH 3/5] Fix review comments --- .circleci/config.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b72b01d86d..67365c6db9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -391,8 +391,15 @@ jobs: bash -c "$PACKCHECK $BUILD" || exit 1 echo "Checking trailing spaces..." count=$(find . -name "*.hs" -exec grep -H '\ $' {} \; | tee /dev/tty | wc -l) - count2=$(awk '{ if (length($0) > 80) {print "Line length exceeds 80 : " length($0); print $0; print FILENAME; } }' *.hs | tee /dev/tty | wc -l) - exit $((count+count2)) + if $count > 0 + then exit 1 + fi + git diff > tmp_len + count2=$(awk '{ if (length($0) > 80) {print "Line length exceeds 80 : " length($0); print $0; } }' tmp_len | tee /dev/tty | wc -l) + rm tmp_len + if $count2 > 0 + then exit 2 + fi - *save workflows: From 8b9b4f04d3d32671a7f1df92c7b5c4ed4c294140 Mon Sep 17 00:00:00 2001 From: Ranjeet Kumar Ranjan Date: Mon, 8 Nov 2021 17:36:20 +0530 Subject: [PATCH 4/5] Fix shell script --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 67365c6db9..a98394be02 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -391,13 +391,13 @@ jobs: bash -c "$PACKCHECK $BUILD" || exit 1 echo "Checking trailing spaces..." count=$(find . -name "*.hs" -exec grep -H '\ $' {} \; | tee /dev/tty | wc -l) - if $count > 0 + if [ $count > 0 ] then exit 1 fi git diff > tmp_len count2=$(awk '{ if (length($0) > 80) {print "Line length exceeds 80 : " length($0); print $0; } }' tmp_len | tee /dev/tty | wc -l) rm tmp_len - if $count2 > 0 + if [ $count2 > 0 ] then exit 2 fi - *save From 00296274b68bbd0e711de1d4fe4e6e7acd84c804 Mon Sep 17 00:00:00 2001 From: Ranjeet Kumar Ranjan Date: Thu, 27 Jan 2022 16:16:14 +0530 Subject: [PATCH 5/5] Fix review comments --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a98394be02..4fc74afd70 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -394,12 +394,12 @@ jobs: if [ $count > 0 ] then exit 1 fi - git diff > tmp_len + git diff master HEAD "*.hs" | grep '^+' | grep -v '^+++' > tmp_len count2=$(awk '{ if (length($0) > 80) {print "Line length exceeds 80 : " length($0); print $0; } }' tmp_len | tee /dev/tty | wc -l) rm tmp_len if [ $count2 > 0 ] then exit 2 - fi + fi - *save workflows: