Skip to content

Commit

Permalink
fix(analysis): INFO: DO use curly braces for all flow control structu…
Browse files Browse the repository at this point in the history
…res.
  • Loading branch information
bwnyasse committed Mar 16, 2021
1 parent f6ba3d6 commit 2a6c5d1
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/src/common/logger/common_logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void _printOutput({
levelColored = _cyan(level);
break;
}
print('${time}[${levelColored}] - ${name} : ${message}');
print('$time[$levelColored] - $name : $message');
}

/// Enables the logs to be displayed in the console.
Expand Down
13 changes: 10 additions & 3 deletions lib/src/core/client/impl/tezart_node_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,13 @@ class TezartNodeError extends CommonException {
String get message => _inputMessage ?? _computedMessage;

TezartNodeErrorTypes get _computedType {
if (RegExp(r'Counter.*already used.*').hasMatch(_errorMsg)) return TezartNodeErrorTypes.counterError;
if (RegExp(r'previously_revealed_key').hasMatch(_errorId)) return TezartNodeErrorTypes.alreadyRevealedKey;
if (RegExp(r'Counter.*already used.*').hasMatch(_errorMsg)) {
return TezartNodeErrorTypes.counterError;
}

if (RegExp(r'previously_revealed_key').hasMatch(_errorId)) {
return TezartNodeErrorTypes.alreadyRevealedKey;
}

return TezartNodeErrorTypes.unhandled;
}
Expand All @@ -96,7 +101,9 @@ class TezartNodeError extends CommonException {
String get key => EnumUtil.enumToString(type);

String get _computedMessage {
if (staticErrorsMessages.containsKey(type)) return staticErrorsMessages[type];
if (staticErrorsMessages.containsKey(type)) {
return staticErrorsMessages[type];
}

switch (type) {
case TezartNodeErrorTypes.monitoringTimedOut:
Expand Down
8 changes: 6 additions & 2 deletions lib/src/crypto/impl/crypto_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ class CryptoError extends CommonException {
String get message => _inputMessage ?? _computedMessage;

String get _computedMessage {
if (staticErrorsMessages.containsKey(type)) return staticErrorsMessages[type];
if (staticErrorsMessages.containsKey(type)) {
return staticErrorsMessages[type];
}

switch (type) {
case CryptoErrorTypes.unhandled:
Expand Down Expand Up @@ -131,7 +133,9 @@ T catchUnhandledErrors<T>(T Function() func) {
try {
return func();
} catch (e) {
if (e is CryptoError) rethrow;
if (e is CryptoError) {
rethrow;
}
throw CryptoError(type: CryptoErrorTypes.unhandled, cause: e);
}
}
4 changes: 3 additions & 1 deletion lib/src/crypto/impl/external_crypto_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import 'crypto_error.dart';

// These methods are a wrapper of (Nacl|PineNacl|Bouncy Castle) lib methods
Uint8List seedBytesFromMnemonic(String mnemonic, {String passphrase = ''}) {
if (!bip39.validateMnemonic(mnemonic)) throw CryptoError(type: CryptoErrorTypes.invalidMnemonic);
if (!bip39.validateMnemonic(mnemonic)) {
throw CryptoError(type: CryptoErrorTypes.invalidMnemonic);
}

final seedBytes = bip39.mnemonicToSeed(mnemonic, passphrase: passphrase);

Expand Down
4 changes: 3 additions & 1 deletion lib/src/crypto/impl/secret_key_seed_conversion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ String seedToSecretKey(String seed) {
const secretKeyPrefix = Prefixes.edsk;

final seedBytes = decodeWithoutPrefix(seed);
if (seedBytes.length != 32) throw CryptoError(type: CryptoErrorTypes.seedBytesLengthError);
if (seedBytes.length != 32) {
throw CryptoError(type: CryptoErrorTypes.seedBytesLengthError);
}

final secretKey = secretKeyBytesFromSeedBytes(seedBytes);

Expand Down
4 changes: 3 additions & 1 deletion lib/src/signature/impl/signature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class Signature extends Equatable {
return crypto.catchUnhandledErrors(() {
HexValidator(data).validate();
// Because two hexadecimal digits correspond to a single byte, this will throw an error if the length of the data is odd
if (data.length.isOdd) throw crypto.CryptoError(type: crypto.CryptoErrorTypes.invalidHexDataLength);
if (data.length.isOdd) {
throw crypto.CryptoError(type: crypto.CryptoErrorTypes.invalidHexDataLength);
}
var bytes = crypto.hexDecode(data);

return Signature.fromBytes(bytes: bytes, keystore: keystore, watermark: watermark);
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions tool/tezart
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ tezart::run_pana() {
log::info "$USAGE_RUN_PANA :"

# generate a bin to run on CI
dart2native tool/pana-output-parser.dart -o tool/pana-output-parser
pub global activate pana > /dev/null
dart2native tool/pana_output_parser.dart -o tool/pana-output-parser
dart pub global activate pana 0.15.3 > /dev/null
export PATH="$PATH":"$HOME/.pub-cache/bin"
pana -l 120 -j > pana_output.json
pana -j > pana_output.json

score=$(tool/pana-output-parser)
log::info "pub.dev Score is $score/100"
Expand Down

0 comments on commit 2a6c5d1

Please sign in to comment.