Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Lint fixes

Neeraj Guptae9ed42309499
diff --git a/mobile/analysis_options.yaml b/mobile/analysis_options.yaml
index f30be877bd..a5fe360712 100644
--- a/mobile/analysis_options.yaml
+++ b/mobile/analysis_options.yaml
@@ -61,6 +61,7 @@ analyzer:
unnecessary_const: error
cancel_subscriptions: error
unrelated_type_equality_checks: error
+ unnecessary_cast: info
unawaited_futures: warning # convert to warning after fixing existing issues
diff --git a/mobile/lib/db/ml/clip_db.dart b/mobile/lib/db/ml/clip_db.dart
index 555f9684d4..59f6dc936b 100644
--- a/mobile/lib/db/ml/clip_db.dart
+++ b/mobile/lib/db/ml/clip_db.dart
@@ -1,4 +1,3 @@
-import "dart:io";
import "dart:typed_data";
import "package:logging/logging.dart";
@@ -98,15 +97,4 @@ extension ClipDB on MLDataDB {
embedding.version,
];
}
-
- Future<void> _clearDeprecatedStores(Directory dir) async {
- final deprecatedObjectBox = Directory(dir.path + "/object-box-store");
- if (await deprecatedObjectBox.exists()) {
- await deprecatedObjectBox.delete(recursive: true);
- }
- final deprecatedIsar = File(dir.path + "/default.isar");
- if (await deprecatedIsar.exists()) {
- await deprecatedIsar.delete();
- }
- }
}
diff --git a/mobile/lib/models/account/two_factor.dart b/mobile/lib/models/account/two_factor.dart
index 6a18f42777..45f7c8fde8 100644
--- a/mobile/lib/models/account/two_factor.dart
+++ b/mobile/lib/models/account/two_factor.dart
@@ -7,7 +7,5 @@ String twoFactorTypeToString(TwoFactorType type) {
return "totp";
case TwoFactorType.passkey:
return "passkey";
- default:
- return type.name;
}
}
diff --git a/mobile/lib/models/ffmpeg/ffprobe_keys.dart b/mobile/lib/models/ffmpeg/ffprobe_keys.dart
index c983dec5d8..c3ac792e40 100644
--- a/mobile/lib/models/ffmpeg/ffprobe_keys.dart
+++ b/mobile/lib/models/ffmpeg/ffprobe_keys.dart
@@ -93,8 +93,6 @@ enum SideDataType {
switch (this) {
case SideDataType.displayMatrix:
return 'Display Matrix';
- default:
- assert(false, 'Unknown side data type: $this');
}
}
}
diff --git a/mobile/lib/models/ffmpeg/ffprobe_props.dart b/mobile/lib/models/ffmpeg/ffprobe_props.dart
index 5ad017d462..8f248d02c6 100644
--- a/mobile/lib/models/ffmpeg/ffprobe_props.dart
+++ b/mobile/lib/models/ffmpeg/ffprobe_props.dart
@@ -2,12 +2,10 @@
import "dart:developer";
-import "package:collection/collection.dart";
import "package:intl/intl.dart";
import "package:photos/models/ffmpeg/channel_layouts.dart";
import "package:photos/models/ffmpeg/codecs.dart";
import "package:photos/models/ffmpeg/ffprobe_keys.dart";
-import "package:photos/models/ffmpeg/language.dart";
import "package:photos/models/ffmpeg/mp4.dart";
import "package:photos/models/location/location.dart";
@@ -344,12 +342,6 @@ class FFProbeProps {
return value;
}
- static String _formatLanguage(String value) {
- final language = Language.living639_2
- .firstWhereOrNull((language) => language.iso639_2 == value);
- return language?.native ?? value;
- }
-
static final _durationHmsmPattern = RegExp(r'(\d+):(\d+):(\d+)(.\d+)');
static final _durationSmPattern = RegExp(r'(\d+)(.\d+)');
static final _locationPattern = RegExp(r'([+-][.0-9]+)');
diff --git a/mobile/lib/services/location_service.dart b/mobile/lib/services/location_service.dart
index 6a3aeb9ceb..1e2a181828 100644
--- a/mobile/lib/services/location_service.dart
+++ b/mobile/lib/services/location_service.dart
@@ -267,7 +267,9 @@ Map<LocationTag, int> _getLocationTagsToOccurenceForIsolate(
for (EnteFile file in files) {
if (file.uploadedFileID == null ||
file.uploadedFileID == -1 ||
- !file.hasLocation) continue;
+ !file.hasLocation) {
+ continue;
+ }
for (LocalEntity<LocationTag> locationTagEntity in locationTagEntities) {
final locationTag = locationTagEntity.item;
final fileCoordinates = file.location!;
diff --git a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart
index 9ad92ebb5f..e19f6b3c65 100644
--- a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart
@@ -3,7 +3,6 @@ import "dart:developer";
import "dart:typed_data" show Uint8List;
import "package:computer/computer.dart";
-import "package:flutter/foundation.dart" show kDebugMode;
import "package:logging/logging.dart";
import "package:ml_linalg/dtype.dart";
import "package:ml_linalg/vector.dart";
@@ -400,7 +399,8 @@ ClusteringResult runLinearClustering(Map args) {
} else {
thresholdValue = distanceThreshold;
}
- final bool faceHasBeenRejectedBefore = sortedFaceInfos[i].rejectedClusterIds != null;
+ final bool faceHasBeenRejectedBefore =
+ sortedFaceInfos[i].rejectedClusterIds != null;
if (i % 250 == 0) {
_logger.info("Processed ${offset != null ? i + offset : i} faces");
}
@@ -416,8 +416,8 @@ ClusteringResult runLinearClustering(Map args) {
if (faceHasBeenRejectedBefore &&
sortedFaceInfos[j].clusterId != null &&
sortedFaceInfos[i].rejectedClusterIds!.contains(
- sortedFaceInfos[j].clusterId!,
- )) {
+ sortedFaceInfos[j].clusterId!,
+ )) {
continue;
}
closestDistance = distance;
@@ -736,62 +736,3 @@ Map<String, (Uint8List, int)> _updateClusterSummaries({
return newClusterSummaries;
}
-
-void _analyzeClusterResults(List<FaceInfo> sortedFaceInfos) {
- if (!kDebugMode) return;
- final stopwatch = Stopwatch()..start();
-
- final Map<String, String> faceIdToCluster = {};
- for (final faceInfo in sortedFaceInfos) {
- faceIdToCluster[faceInfo.faceID] = faceInfo.clusterId!;
- }
-
- // Find faceIDs that are part of a cluster which is larger than 5 and are new faceIDs
- final Map<String, int> clusterIdToSize = {};
- faceIdToCluster.forEach((key, value) {
- if (clusterIdToSize.containsKey(value)) {
- clusterIdToSize[value] = clusterIdToSize[value]! + 1;
- } else {
- clusterIdToSize[value] = 1;
- }
- });
-
- // print top 10 cluster ids and their sizes based on the internal cluster id
- final clusterIds = faceIdToCluster.values.toSet();
- final clusterSizes = clusterIds.map((clusterId) {
- return faceIdToCluster.values.where((id) => id == clusterId).length;
- }).toList();
- clusterSizes.sort();
- // find clusters whose size is greater than 1
- int oneClusterCount = 0;
- int moreThan5Count = 0;
- int moreThan10Count = 0;
- int moreThan20Count = 0;
- int moreThan50Count = 0;
- int moreThan100Count = 0;
-
- for (int i = 0; i < clusterSizes.length; i++) {
- if (clusterSizes[i] > 100) {
- moreThan100Count++;
- } else if (clusterSizes[i] > 50) {
- moreThan50Count++;
- } else if (clusterSizes[i] > 20) {
- moreThan20Count++;
- } else if (clusterSizes[i] > 10) {
- moreThan10Count++;
- } else if (clusterSizes[i] > 5) {
- moreThan5Count++;
- } else if (clusterSizes[i] == 1) {
- oneClusterCount++;
- }
- }
-
- // print the metrics
- log(
- "[ClusterIsolate] Total clusters ${clusterIds.length}: \n oneClusterCount $oneClusterCount \n moreThan5Count $moreThan5Count \n moreThan10Count $moreThan10Count \n moreThan20Count $moreThan20Count \n moreThan50Count $moreThan50Count \n moreThan100Count $moreThan100Count",
- );
- stopwatch.stop();
- log(
- "[ClusterIsolate] Clustering additional analysis took ${stopwatch.elapsedMilliseconds} ms",
- );
-}
diff --git a/mobile/lib/services/machine_learning/face_ml/face_detection/detection.dart b/mobile/lib/services/machine_learning/face_ml/face_detection/detection.dart
index 7c52e53046..dbe2055eb6 100644
--- a/mobile/lib/services/machine_learning/face_ml/face_detection/detection.dart
+++ b/mobile/lib/services/machine_learning/face_ml/face_detection/detection.dart
@@ -13,8 +13,6 @@ extension FaceDirectionExtension on FaceDirection {
return 'Right';
case FaceDirection.straight:
return 'Straight';
- default:
- throw Exception('Unknown FaceDirection');
}
}
}
diff --git a/mobile/lib/services/machine_learning/machine_learning_controller.dart b/mobile/lib/services/machine_learning/machine_learning_controller.dart
index 09503185cc..4cd70a4aab 100644
--- a/mobile/lib/services/machine_learning/machine_learning_controller.dart
+++ b/mobile/lib/services/machine_learning/machine_learning_controller.dart
@@ -9,8 +9,6 @@ import "package:photos/core/event_bus.dart";
import "package:photos/events/machine_learning_control_event.dart";
class MachineLearningController {
- MachineLearningController._privateConstructor();
-
final _logger = Logger("MachineLearningController");
static const kMaximumTemperature = 42; // 42 degree celsius
diff --git a/mobile/lib/services/machine_learning/ml_service.dart b/mobile/lib/services/machine_learning/ml_service.dart
index 74d6685d94..623e46c29e 100644
--- a/mobile/lib/services/machine_learning/ml_service.dart
+++ b/mobile/lib/services/machine_learning/ml_service.dart
@@ -58,7 +58,9 @@ class MLService {
Future<void> init() async {
if (_isInitialized) return;
if (!userRemoteFlagService
- .getCachedBoolValue(UserRemoteFlagService.mlEnabled)) return;
+ .getCachedBoolValue(UserRemoteFlagService.mlEnabled)) {
+ return;
+ }
_logger.info("init called");
// Check if the device has enough RAM to run local indexing
@@ -72,7 +74,9 @@ class MLService {
// Listen on MachineLearningController
Bus.instance.on<MachineLearningControlEvent>().listen((event) {
if (!userRemoteFlagService
- .getCachedBoolValue(UserRemoteFlagService.mlEnabled)) return;
+ .getCachedBoolValue(UserRemoteFlagService.mlEnabled)) {
+ return;
+ }
_mlControllerStatus = event.shouldRun;
if (_mlControllerStatus) {
diff --git a/mobile/lib/ui/components/menu_item_widget/menu_item_widget.dart b/mobile/lib/ui/components/menu_item_widget/menu_item_widget.dart
index cb18f9b26f..d1e87e26a5 100644
--- a/mobile/lib/ui/components/menu_item_widget/menu_item_widget.dart
+++ b/mobile/lib/ui/components/menu_item_widget/menu_item_widget.dart
@@ -213,7 +213,9 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
Future<void> _onTap() async {
if (executionStateNotifier.value == ExecutionState.inProgress ||
- executionStateNotifier.value == ExecutionState.successful) return;
+ executionStateNotifier.value == ExecutionState.successful) {
+ return;
+ }
_debouncer.run(
() => Future(
() {
@@ -250,7 +252,9 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
void _onTapDown(details) {
if (executionStateNotifier.value == ExecutionState.inProgress ||
- executionStateNotifier.value == ExecutionState.successful) return;
+ executionStateNotifier.value == ExecutionState.successful) {
+ return;
+ }
setState(() {
if (widget.pressedColor == null) {
hasPassedGestureCallbacks()
@@ -270,7 +274,9 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
void _onTapUp(details) {
if (executionStateNotifier.value == ExecutionState.inProgress ||
- executionStateNotifier.value == ExecutionState.successful) return;
+ executionStateNotifier.value == ExecutionState.successful) {
+ return;
+ }
Future.delayed(
const Duration(milliseconds: 100),
() => setState(() {
@@ -281,7 +287,9 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
void _onCancel() {
if (executionStateNotifier.value == ExecutionState.inProgress ||
- executionStateNotifier.value == ExecutionState.successful) return;
+ executionStateNotifier.value == ExecutionState.successful) {
+ return;
+ }
setState(() {
menuItemColor = widget.menuItemColor;
});
diff --git a/mobile/lib/ui/extents_page_view.dart b/mobile/lib/ui/extents_page_view.dart
index 65c711f5d0..dbf1b2f3fc 100644
--- a/mobile/lib/ui/extents_page_view.dart
+++ b/mobile/lib/ui/extents_page_view.dart
@@ -346,7 +346,6 @@ class _PageViewState extends State<ExtentsPageView> {
break;
case Axis.horizontal:
- default:
cacheExtent = constraints.maxWidth * widget.extents;
break;
}
diff --git a/mobile/lib/ui/tools/deduplicate_page.dart b/mobile/lib/ui/tools/deduplicate_page.dart
index da30ee51cf..8b8efd8dd8 100644
--- a/mobile/lib/ui/tools/deduplicate_page.dart
+++ b/mobile/lib/ui/tools/deduplicate_page.dart
@@ -123,8 +123,6 @@ class _DeduplicatePageState extends State<DeduplicatePage> {
return bSize - aSize;
case SortKey.count:
return second.files.length - first.files.length;
- default:
- throw Exception("Unexpected sort key $sortKey");
}
});
}
diff --git a/mobile/lib/ui/tools/editor/video_editor/crop_value.dart b/mobile/lib/ui/tools/editor/video_editor/crop_value.dart
index 96c00736c7..243c611af2 100644
--- a/mobile/lib/ui/tools/editor/video_editor/crop_value.dart
+++ b/mobile/lib/ui/tools/editor/video_editor/crop_value.dart
@@ -25,8 +25,6 @@ enum CropValue {
return Fraction.fromString("3/4");
case CropValue.ratio_4_3:
return Fraction.fromString("4/3");
- default:
- return null;
}
}
diff --git a/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart b/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart
index 058aefc456..cf71cd66a9 100644
--- a/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart
+++ b/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart
@@ -1,7 +1,6 @@
import "dart:async";
import "dart:io";
-import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";
import "package:logging/logging.dart";
import "package:media_kit/media_kit.dart";
@@ -17,7 +16,6 @@ import "package:photos/services/files_service.dart";
import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/actions/file/file_actions.dart";
-import "package:photos/ui/viewer/file/thumbnail_widget.dart";
import "package:photos/utils/debouncer.dart";
import "package:photos/utils/dialog_util.dart";
import "package:photos/utils/file_util.dart";
@@ -226,17 +224,6 @@ class _VideoWidgetMediaKitNewState extends State<VideoWidgetMediaKitNew>
});
}
}
-
- Widget _getThumbnail() {
- return Container(
- color: Colors.black,
- constraints: const BoxConstraints.expand(),
- child: ThumbnailWidget(
- widget.file,
- fit: BoxFit.contain,
- ),
- );
- }
}
class _VideoWidget extends StatefulWidget {
diff --git a/mobile/lib/ui/viewer/file_details/faces_item_widget.dart b/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
index 309b5122ef..a7c2a78018 100644
--- a/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
+++ b/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
@@ -38,16 +38,9 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
subtitleSection: _faceWidgets(context, widget.file, editMode),
hasChipButtons: true,
biggerSpinner: true,
- // editOnTap: _toggleEditMode, // TODO: re-enable at later time when the UI is less ugly
);
}
- void _toggleEditMode() {
- setState(() {
- editMode = !editMode;
- });
- }
-
Future<List<Widget>> _faceWidgets(
BuildContext context,
EnteFile file,
diff --git a/mobile/lib/ui/viewer/search/result/search_result_widget.dart b/mobile/lib/ui/viewer/search/result/search_result_widget.dart
index 6dacab459a..12a1d2182d 100644
--- a/mobile/lib/ui/viewer/search/result/search_result_widget.dart
+++ b/mobile/lib/ui/viewer/search/result/search_result_widget.dart
@@ -145,8 +145,6 @@ class SearchResultWidget extends StatelessWidget {
return "Shared";
case ResultType.faces:
return "Person";
- default:
- return type.name.toUpperCase();
}
}
}
diff --git a/mobile/lib/ui/viewer/search_tab/search_tab.dart b/mobile/lib/ui/viewer/search_tab/search_tab.dart
index bf78bb930c..27e3f46830 100644
--- a/mobile/lib/ui/viewer/search_tab/search_tab.dart
+++ b/mobile/lib/ui/viewer/search_tab/search_tab.dart
@@ -159,8 +159,6 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
snapshot.data!.elementAt(index)
as List<GenericSearchResult>,
);
- default:
- const SizedBox.shrink();
}
},
)
diff --git a/mobile/lib/utils/hierarchical_search_util.dart b/mobile/lib/utils/hierarchical_search_util.dart
index 3812d0107a..f66f88653a 100644
--- a/mobile/lib/utils/hierarchical_search_util.dart
+++ b/mobile/lib/utils/hierarchical_search_util.dart
@@ -325,7 +325,9 @@ List<ContactsFilter> _curateContactsFilter(
if (file.ownerID == Configuration.instance.getUserID() ||
file.uploadedFileID == null ||
file.uploadedFileID == -1 ||
- file.ownerID == null) continue;
+ file.ownerID == null) {
+ continue;
+ }
ownerIdToOccurrence[file.ownerID!] =
(ownerIdToOccurrence[file.ownerID] ?? 0) + 1;
}