Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a CI that fails if line length exceeds 80 #1231

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +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)
exit $count
if [ $count > 0 ]
then exit 1
fi
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The git diff output has deleted lines, changed lines and other info. We need to grep only the lines with a leading + (grep '^+') and filter out the lines with a leading +++(grep -v^+++`) from that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes!

rm tmp_len
if [ $count2 > 0 ]
then exit 2
fi
- *save

workflows:
Expand All @@ -417,4 +425,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
10 changes: 5 additions & 5 deletions src/Streamly/Internal/Data/Array/Prim/MutTypesInclude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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#
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down