rblaze/bond-haskell

View on GitHub

Showing 16 of 16 total issues

Use <$>
Open

    bondGetBonded = do
        v <- ask
        return $ BondedStream $ BL.append (protoSig JsonProto) (A.encode v)

Found

do v <- ask
   return $ BondedStream $ BL.append (protoSig JsonProto) (A.encode v)

Perhaps

do BondedStream . BL.append (protoSig JsonProto) . A.encode <$> ask

Reduce duplication
Open

    typeName = mkType $ makeDeclName decl

Found

typeName = mkType $ makeDeclName decl
typeParams
  = map (\ TypeParam{paramName} -> UnkindedVar $ mkVar paramName)
      declParams
fieldModules
  = unique $
      filter (/= moduleName) $
        filter (/= internalModuleAlias) $
          concatMap (getTypeModules . snd) fields
mkField f
  = ([mkVar $ makeFieldName f],
     hsType (setType opts) ctx (fieldType f))
ownFields = map mkField structFields
fields
  | Just base <- structBase =
    ([baseStructField], hsType (setType opts) ctx base) : ownFields
  | otherwise = ownFields

Perhaps

Combine with compiler/src/Language/Bond/Codegen/Haskell/StructDecl.hs:193:5

Reduce duplication
Open

        stream <- either throwError return $ bondMarshal CompactBinaryProto v

Found

stream <- either throwError return $
            bondMarshal CompactBinaryProto v
putWord32le $ fromIntegral $ BL.length stream
putLazyByteString stream

Perhaps

Combine with runtime/src/Data/Bond/Internal/SimpleBinaryProto.hs:262:9

Use tuple-section
Open

makeHsBootModule opts ctx decl = fmap (\ c -> (hsBootName, Nothing, c)) code

Found

\ c -> (hsBootName, Nothing, c)

Perhaps

(hsBootName, Nothing,)

Applying this change:

  • may require {-# LANGUAGE TupleSections #-} adding to the top of the file

Reduce duplication
Open

        v <- bondUnmarshalWithSchema schema stream

Found

v <- bondUnmarshalWithSchema schema stream
s <- bondMarshalWithSchema t schema v
return (BondedStream s)

Perhaps

Combine with runtime/src/Data/Bond/Internal/BondedUtils.hs:45:9

Use hierarchical imports
Open

import IO
Severity: Minor
Found in compiler/app/Main.hs by hlint

Found

import IO

Perhaps

import System.IO
import System.IO.Error
import Control.Exception ( bracket, bracket_ )

Redundant bracket
Open

                            | V.length a == 1 -> (Just . head) <$> bondGetList

Found

(Just . head) <$> bondGetList

Perhaps

Just . head <$> bondGetList

Reduce duplication
Open

    let et = getWireType (Proxy :: Proxy a)

Found

let et = getWireType (Proxy :: Proxy a)
(t, n) <- getListHeader
unless (t == et) $
  fail $
    "invalid element tag " ++
      bondTypeName t ++
        " in list field, " ++ bondTypeName et ++ " expected"

Perhaps

Combine with runtime/src/Data/Bond/Internal/CompactBinaryProto.hs:337:5

Use tuple-section
Open

makeModule opts ctx decl = fmap (\ c -> (sourceName, Just printName, c)) code

Found

\ c -> (sourceName, Just printName, c)

Perhaps

(sourceName, Just printName,)

Applying this change:

  • may require {-# LANGUAGE TupleSections #-} adding to the top of the file

Reduce duplication
Open

        v <- bondUnmarshalTagged stream

Found

v <- bondUnmarshalTagged stream
s <- bondMarshalWithSchema t schema v
return (BondedStream s)

Perhaps

Combine with runtime/src/Data/Bond/Internal/BondedUtils.hs:59:9

Reduce duplication
Open

    let et = getWireType (Proxy :: Proxy a)

Found

let et = getWireType (Proxy :: Proxy a)
(t, n) <- getListHeader
unless (t == et) $
  fail $
    "invalid element tag " ++
      bondTypeName t ++
        " in list field, " ++ bondTypeName et ++ " expected"

Perhaps

Combine with runtime/src/Data/Bond/Internal/FastBinaryProto.hs:211:5

Reduce duplication
Open

        size <- getWord32le

Found

size <- getWord32le
bs <- getLazyByteString (fromIntegral size)
return $ BondedStream bs

Perhaps

Combine with runtime/src/Data/Bond/Internal/SimpleBinaryProto.hs:216:9

Use newtype instead of data
Open

data BondedException = BondedException String
    deriving (Show, Typeable)

Found

data BondedException
  = BondedException String
  deriving (Show, Typeable)

Perhaps

newtype BondedException
  = BondedException String
  deriving (Show, Typeable)

Applying this change:

  • decreases laziness

Reduce duplication
Open

    sig = BL.take 4 stream

Found

sig = BL.take 4 stream
schema = getSchema (Proxy :: Proxy a)
taggedSigs
  = [protoSig FastBinaryProto, protoSig CompactBinaryProto,
     protoSig CompactBinaryV1Proto]
isTaggedSource = sig `elem` taggedSigs

Perhaps

Combine with runtime/src/Data/Bond/Internal/BondedUtils.hs:49:5

Reduce duplication
Open

        keyTypeDef <- makeElementTypeDef key

Found

keyTypeDef <- makeElementTypeDef key
valueTypeDef <- makeElementTypeDef value
return
  defaultValue{TD.id = bT_MAP, TD.element = Just valueTypeDef,
               TD.key = Just keyTypeDef}

Perhaps

Combine with runtime/src/Data/Bond/Internal/SchemaOps.hs:282:9

Reduce duplication
Open

        v <- bondUnmarshalWithSchema schema stream

Found

v <- bondUnmarshalWithSchema schema stream
s <- bondMarshalWithSchema t schema v
return (BondedStream s)

Perhaps

Combine with runtime/src/Data/Bond/Internal/BondedUtils.hs:63:9
Severity
Category
Status
Source
Language