Skip to content

Commit facefec

Browse files
Merge #4889
4889: Remove use of multiline literals r=newhoggy a=newhoggy Also the style-guide in the Wiki has been updated with a new section: https://github.com/input-output-hk/cardano-node/wiki/Style-guide#multi-line-string-literals Resolves #4585 Co-authored-by: John Ky <[email protected]>
2 parents 2590e48 + e609e9e commit facefec

File tree

28 files changed

+1370
-1077
lines changed

28 files changed

+1370
-1077
lines changed

cardano-api/src/Cardano/Api/ProtocolParameters.hs

+11-9
Original file line numberDiff line numberDiff line change
@@ -1790,15 +1790,17 @@ data ProtocolParametersError =
17901790
deriving Show
17911791

17921792
instance Error ProtocolParametersError where
1793-
displayError (PParamsErrorMissingMinUTxoValue (AnyCardanoEra era)) =
1794-
"The " <> show era <> " protocol parameters value is missing the following \
1795-
\field: MinUTxoValue. Did you intend to use a " <> show era <> " protocol \
1796-
\ parameters value?"
1797-
displayError PParamsErrorMissingAlonzoProtocolParameter =
1798-
"The Alonzo era protocol parameters in use is missing one or more of the \
1799-
\following fields: UTxOCostPerWord, CostModels, Prices, MaxTxExUnits, \
1800-
\MaxBlockExUnits, MaxValueSize, CollateralPercent, MaxCollateralInputs. Did \
1801-
\you intend to use an Alonzo era protocol parameters value?"
1793+
displayError (PParamsErrorMissingMinUTxoValue (AnyCardanoEra era)) = mconcat
1794+
[ "The " <> show era <> " protocol parameters value is missing the following "
1795+
, "field: MinUTxoValue. Did you intend to use a " <> show era <> " protocol "
1796+
, " parameters value?"
1797+
]
1798+
displayError PParamsErrorMissingAlonzoProtocolParameter = mconcat
1799+
[ "The Alonzo era protocol parameters in use is missing one or more of the "
1800+
, "following fields: UTxOCostPerWord, CostModels, Prices, MaxTxExUnits, "
1801+
, "MaxBlockExUnits, MaxValueSize, CollateralPercent, MaxCollateralInputs. Did "
1802+
, "you intend to use an Alonzo era protocol parameters value?"
1803+
]
18021804

18031805
checkProtocolParameters
18041806
:: forall era. IsCardanoEra era

cardano-api/src/Cardano/Api/SerialiseBech32.hs

+14-12
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,17 @@ instance Error Bech32DecodeError where
155155
<> ", but it was expected to be "
156156
<> List.intercalate " or " (map show (Set.toList permitted))
157157

158-
Bech32DataPartToBytesError _dataPart ->
159-
"There was an error in extracting the bytes from the data part of the \
160-
\Bech32-encoded string."
161-
162-
Bech32DeserialiseFromBytesError _bytes ->
163-
"There was an error in deserialising the data part of the \
164-
\Bech32-encoded string into a value of the expected type."
165-
166-
Bech32WrongPrefix actual expected ->
167-
"Mismatch in the Bech32 prefix: the actual prefix is " <> show actual
168-
<> ", but the prefix for this payload value should be " <> show expected
169-
158+
Bech32DataPartToBytesError _dataPart -> mconcat
159+
[ "There was an error in extracting the bytes from the data part of the "
160+
, "Bech32-encoded string."
161+
]
162+
163+
Bech32DeserialiseFromBytesError _bytes -> mconcat
164+
[ "There was an error in deserialising the data part of the "
165+
, "Bech32-encoded string into a value of the expected type."
166+
]
167+
168+
Bech32WrongPrefix actual expected -> mconcat
169+
[ "Mismatch in the Bech32 prefix: the actual prefix is " <> show actual
170+
, ", but the prefix for this payload value should be " <> show expected
171+
]

cardano-api/src/Cardano/Api/TxBody.hs

+24-18
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ import qualified Cardano.Crypto.Hashing as Byron
203203

204204
import qualified Cardano.Ledger.Address as Shelley
205205
import qualified Cardano.Ledger.AuxiliaryData as Ledger
206+
import Cardano.Ledger.Babbage.TxBody (BabbageEraTxBody (..),
207+
BabbageTxBody (BabbageTxBody), BabbageTxOut (BabbageTxOut))
206208
import Cardano.Ledger.BaseTypes (StrictMaybe (..), maybeToStrictMaybe)
207209
import qualified Cardano.Ledger.Block as Ledger
208210
import qualified Cardano.Ledger.Coin as Ledger
@@ -214,8 +216,6 @@ import Cardano.Ledger.Crypto (StandardCrypto)
214216
import qualified Cardano.Ledger.Era as CC
215217
import qualified Cardano.Ledger.Keys as Shelley
216218
import qualified Cardano.Ledger.SafeHash as SafeHash
217-
import Cardano.Ledger.Babbage.TxBody (BabbageEraTxBody (..),
218-
BabbageTxBody (BabbageTxBody), BabbageTxOut (BabbageTxOut))
219219
import qualified Cardano.Ledger.TxIn as Ledger
220220
import Cardano.Ledger.Val (isZero)
221221

@@ -226,23 +226,23 @@ import qualified Cardano.Ledger.Shelley.Metadata as Shelley
226226
import qualified Cardano.Ledger.Shelley.Tx as Shelley
227227
import qualified Cardano.Ledger.Shelley.TxBody as Shelley
228228

229-
import qualified Cardano.Ledger.ShelleyMA.AuxiliaryData as Allegra
229+
import Cardano.Ledger.Mary.Value (MaryValue)
230230
import Cardano.Ledger.ShelleyMA.AuxiliaryData (MAAuxiliaryData (..))
231+
import qualified Cardano.Ledger.ShelleyMA.AuxiliaryData as Allegra
232+
import Cardano.Ledger.ShelleyMA.TxBody (MATxBody (..))
231233
import qualified Cardano.Ledger.ShelleyMA.TxBody as Allegra
232234
import qualified Cardano.Ledger.ShelleyMA.TxBody as Mary
233-
import Cardano.Ledger.ShelleyMA.TxBody (MATxBody (..))
234-
import Cardano.Ledger.Mary.Value (MaryValue)
235235

236+
import Cardano.Ledger.Alonzo.Data (AlonzoAuxiliaryData (AlonzoAuxiliaryData))
237+
import qualified Cardano.Ledger.Alonzo.Data as Alonzo
236238
import qualified Cardano.Ledger.Alonzo.Language as Alonzo
237239
import qualified Cardano.Ledger.Alonzo.PParams as Alonzo
238240
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
239241
import qualified Cardano.Ledger.Alonzo.Tx as Alonzo
240-
import qualified Cardano.Ledger.Alonzo.TxBody as Alonzo
241-
import qualified Cardano.Ledger.Alonzo.TxWitness as Alonzo
242-
import Cardano.Ledger.Alonzo.Data (AlonzoAuxiliaryData (AlonzoAuxiliaryData))
243-
import qualified Cardano.Ledger.Alonzo.Data as Alonzo
244242
import Cardano.Ledger.Alonzo.TxBody (AlonzoTxBody (AlonzoTxBody),
245243
AlonzoTxOut (AlonzoTxOut))
244+
import qualified Cardano.Ledger.Alonzo.TxBody as Alonzo
245+
import qualified Cardano.Ledger.Alonzo.TxWitness as Alonzo
246246

247247
import qualified Cardano.Ledger.Babbage.PParams as Babbage
248248
import qualified Cardano.Ledger.Babbage.TxBody as Babbage
@@ -1909,9 +1909,11 @@ deserialiseShelleyBasedTxBody era bs =
19091909
4 -> do
19101910
sValiditySupported <-
19111911
case txScriptValiditySupportedInShelleyBasedEra era of
1912-
Nothing -> fail $ "deserialiseShelleyBasedTxBody: Expected an era that supports the \
1913-
\script validity flag but got: "
1914-
<> show era
1912+
Nothing -> fail $ mconcat
1913+
[ "deserialiseShelleyBasedTxBody: Expected an era that supports the "
1914+
, "script validity flag but got: "
1915+
, show era
1916+
]
19151917
Just supported -> return supported
19161918

19171919
txbody <- fromCBOR
@@ -1928,16 +1930,20 @@ deserialiseShelleyBasedTxBody era bs =
19281930
6 -> do
19291931
sDataSupported <-
19301932
case scriptDataSupportedInEra (shelleyBasedToCardanoEra era) of
1931-
Nothing -> fail $ "deserialiseShelleyBasedTxBody: Expected an era that supports script\
1932-
\ data but got: "
1933-
<> show era
1933+
Nothing -> fail $ mconcat
1934+
[ "deserialiseShelleyBasedTxBody: Expected an era that supports script"
1935+
, " data but got: "
1936+
, show era
1937+
]
19341938
Just supported -> return supported
19351939

19361940
sValiditySupported <-
19371941
case txScriptValiditySupportedInShelleyBasedEra era of
1938-
Nothing -> fail $ "deserialiseShelleyBasedTxBody: Expected an era that supports the \
1939-
\script validity flag but got: "
1940-
<> show era
1942+
Nothing -> fail $ mconcat
1943+
[ "deserialiseShelleyBasedTxBody: Expected an era that supports the "
1944+
, "script validity flag but got: "
1945+
, show era
1946+
]
19411947
Just supported -> return supported
19421948

19431949
txbody <- fromCBOR

cardano-cli/src/Cardano/CLI/Parsers.hs

+8-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ command' c descr p =
2626
opts :: ParserInfo ClientCommand
2727
opts =
2828
Opt.info (parseClientCommand <**> Opt.helper)
29-
( Opt.fullDesc
30-
<> Opt.header
31-
"cardano-cli - utility to support a variety of key\
32-
\ operations (genesis generation, migration,\
33-
\ pretty-printing..) for different system generations."
29+
( mconcat
30+
[ Opt.fullDesc
31+
, Opt.header $ mconcat
32+
[ "cardano-cli - utility to support a variety of key"
33+
, " operations (genesis generation, migration,"
34+
, " pretty-printing..) for different system generations."
35+
]
36+
]
3437
)
3538

3639
pref :: ParserPrefs

cardano-cli/src/Cardano/CLI/Shelley/Output.hs

+6-3
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,12 @@ instance FromJSON QueryTipLocalStateOutput where
219219
mEra'
220220
mEpoch'
221221
mSyncProgress'
222-
(_,_,_) -> fail "QueryTipLocalStateOutput was incorrectly JSON encoded.\
223-
\ Expected slot, header hash and block number (ChainTip)\
224-
\ or none (ChainTipAtGenesis)"
222+
(_,_,_) ->
223+
fail $ mconcat
224+
[ "QueryTipLocalStateOutput was incorrectly JSON encoded."
225+
, " Expected slot, header hash and block number (ChainTip)"
226+
, " or none (ChainTipAtGenesis)"
227+
]
225228

226229
data ScriptCostOutput =
227230
ScriptCostOutput

0 commit comments

Comments
 (0)