From 83fda9ddf5e77de845855b3016e001e4ba992546 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Wed, 29 Nov 2023 10:26:56 +0100 Subject: [PATCH] Add pre-commit with formatting and linting. --- .pre-commit-config.yaml | 26 +++++++++++++++++++++++ lib/android/tap_request_dialog.dart | 3 ++- lib/exception/apdu_exception.dart | 1 - lib/exception/cancellation_exception.dart | 4 +--- lib/oath/icon_provider/icon_pack.dart | 3 ++- lib/widgets/focus_utils.dart | 3 +-- 6 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..da5ca8e9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +repos: +# Flutter +- repo: https://github.com/dluksza/flutter-analyze-pre-commit + rev: "4afcaa82fc368d40d486256bf4edba329bf667bb" + hooks: + - id: flutter-analyze + args: [lib/*] + - id: dart-format + args: [lib/*] + +# Python +- repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + files: helper/ +- repo: https://github.com/psf/black + rev: 23.11.0 + hooks: + - id: black + files: helper/ +- repo: https://github.com/PyCQA/bandit + rev: 1.7.5 + hooks: + - id: bandit + files: helper/ # keep in sync with .bandit file diff --git a/lib/android/tap_request_dialog.dart b/lib/android/tap_request_dialog.dart index 87dad68e..64ef60cd 100755 --- a/lib/android/tap_request_dialog.dart +++ b/lib/android/tap_request_dialog.dart @@ -160,7 +160,8 @@ class _DialogProvider { _DDesc.oathDeleteAccount => l10n.s_nfc_dialog_oath_delete_account, _DDesc.oathCalculateCode => l10n.s_nfc_dialog_oath_calculate_code, _DDesc.oathActionFailure => l10n.s_nfc_dialog_oath_failure, - _DDesc.oathAddMultipleAccounts => l10n.s_nfc_dialog_oath_add_multiple_accounts, + _DDesc.oathAddMultipleAccounts => + l10n.s_nfc_dialog_oath_add_multiple_accounts, _ => '' }; } diff --git a/lib/exception/apdu_exception.dart b/lib/exception/apdu_exception.dart index 385dcf1a..68fa8852 100644 --- a/lib/exception/apdu_exception.dart +++ b/lib/exception/apdu_exception.dart @@ -26,4 +26,3 @@ class ApduException implements Exception { return 'ApduException[$message; dec: $sw]'; } } - diff --git a/lib/exception/cancellation_exception.dart b/lib/exception/cancellation_exception.dart index 803a4338..d1c14c76 100644 --- a/lib/exception/cancellation_exception.dart +++ b/lib/exception/cancellation_exception.dart @@ -14,6 +14,4 @@ * limitations under the License. */ -class CancellationException implements Exception { - -} +class CancellationException implements Exception {} diff --git a/lib/oath/icon_provider/icon_pack.dart b/lib/oath/icon_provider/icon_pack.dart index 67dd498a..122d0a5c 100644 --- a/lib/oath/icon_provider/icon_pack.dart +++ b/lib/oath/icon_provider/icon_pack.dart @@ -61,7 +61,8 @@ class IconPack { element.issuer.any((element) => element == issuer.toUpperCase())); final issuerImageFile = matching.isNotEmpty - ? File(join(directory.path, getLocalIconFileName(matching.first.filename))) + ? File( + join(directory.path, getLocalIconFileName(matching.first.filename))) : null; if (issuerImageFile != null && !issuerImageFile.existsSync()) { diff --git a/lib/widgets/focus_utils.dart b/lib/widgets/focus_utils.dart index 94fca1b0..4393b096 100644 --- a/lib/widgets/focus_utils.dart +++ b/lib/widgets/focus_utils.dart @@ -1,4 +1,3 @@ - import 'package:flutter/cupertino.dart'; import 'package:logging/logging.dart'; @@ -15,4 +14,4 @@ class FocusUtils { currentFocus.unfocus(); } } -} \ No newline at end of file +}