Skip to content

Commit

Permalink
Merge pull request #1305 from julien4215/lint-import
Browse files Browse the repository at this point in the history
Enable always_use_package_imports rule
  • Loading branch information
veloce authored Dec 24, 2024
2 parents 3afe9fd + 447d75c commit 59a38b0
Show file tree
Hide file tree
Showing 51 changed files with 105 additions and 152 deletions.
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ linter:
rules:
require_trailing_commas: false
prefer_single_quotes: true
always_use_package_imports: false
always_use_package_imports: true
avoid_redundant_argument_values: false
sort_pub_dependencies: true
sort_unnamed_constructors_first: false
3 changes: 1 addition & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lichess_mobile/src/app.dart';
import 'package:lichess_mobile/src/binding.dart';
import 'package:lichess_mobile/src/init.dart';
import 'package:lichess_mobile/src/intl.dart';
import 'package:lichess_mobile/src/log.dart';
import 'package:lichess_mobile/src/model/common/service/sound_service.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'src/app.dart';

Future<void> main() async {
final widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
final lichessBinding = AppLichessBinding.ensureInitialized();
Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/account/account_preferences.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lichess_mobile/src/model/account/account_repository.dart';
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
import 'package:lichess_mobile/src/network/http.dart';
import 'package:lichess_mobile/src/utils/l10n_context.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'account_repository.dart';

part 'account_preferences.g.dart';

typedef AccountPrefState =
Expand Down
5 changes: 2 additions & 3 deletions lib/src/model/account/account_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import 'package:deep_pick/deep_pick.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:http/http.dart' as http;
import 'package:lichess_mobile/src/model/account/account_preferences.dart';
import 'package:lichess_mobile/src/model/account/ongoing_game.dart';
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
import 'package:lichess_mobile/src/model/common/chess.dart';
import 'package:lichess_mobile/src/model/common/id.dart';
Expand All @@ -13,9 +15,6 @@ import 'package:lichess_mobile/src/network/http.dart';
import 'package:logging/logging.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'account_preferences.dart';
import 'ongoing_game.dart';

part 'account_repository.g.dart';

@riverpod
Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/auth/auth_controller.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import 'package:lichess_mobile/src/model/auth/auth_repository.dart';
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
import 'package:lichess_mobile/src/model/notifications/notification_service.dart';
import 'package:lichess_mobile/src/network/http.dart';
import 'package:lichess_mobile/src/network/socket.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'auth_repository.dart';

part 'auth_controller.g.dart';

@riverpod
Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/auth/auth_session.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:lichess_mobile/src/model/auth/session_storage.dart';
import 'package:lichess_mobile/src/model/common/preloaded_data.dart';
import 'package:lichess_mobile/src/model/user/user.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'session_storage.dart';

part 'auth_session.freezed.dart';
part 'auth_session.g.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lichess_mobile/src/db/database.dart';
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/correspondence/offline_correspondence_game.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:sqflite/sqflite.dart';

import 'offline_correspondence_game.dart';

part 'correspondence_game_storage.g.dart';

@Riverpod(keepAlive: true)
Expand Down
5 changes: 2 additions & 3 deletions lib/src/model/engine/engine.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:lichess_mobile/src/model/engine/uci_protocol.dart';
import 'package:lichess_mobile/src/model/engine/work.dart';
import 'package:logging/logging.dart';
import 'package:stockfish/stockfish.dart';

import 'uci_protocol.dart';
import 'work.dart';

enum EngineState { initial, loading, idle, computing, error, disposed }

abstract class Engine {
Expand Down
7 changes: 3 additions & 4 deletions lib/src/model/engine/evaluation_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ import 'package:lichess_mobile/src/model/common/chess.dart';
import 'package:lichess_mobile/src/model/common/eval.dart';
import 'package:lichess_mobile/src/model/common/preloaded_data.dart';
import 'package:lichess_mobile/src/model/common/uci.dart';
import 'package:lichess_mobile/src/model/engine/engine.dart';
import 'package:lichess_mobile/src/model/engine/work.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:stream_transform/stream_transform.dart';

import 'engine.dart';
import 'work.dart';

part 'evaluation_service.g.dart';
part 'evaluation_service.freezed.dart';
part 'evaluation_service.g.dart';

final maxEngineCores = max(Platform.numberOfProcessors - 1, 1);
final defaultEngineCores = min((Platform.numberOfProcessors / 2).ceil(), maxEngineCores);
Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/engine/uci_protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/foundation.dart';
import 'package:lichess_mobile/src/model/common/chess.dart';
import 'package:lichess_mobile/src/model/common/eval.dart';
import 'package:lichess_mobile/src/model/engine/work.dart';
import 'package:logging/logging.dart';

import 'work.dart';

const minDepth = 6;
const maxPlies = 245;

Expand Down
7 changes: 3 additions & 4 deletions lib/src/model/game/archived_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/common/perf.dart';
import 'package:lichess_mobile/src/model/common/speed.dart';
import 'package:lichess_mobile/src/model/common/time_increment.dart';
import 'package:lichess_mobile/src/model/game/game.dart';
import 'package:lichess_mobile/src/model/game/game_status.dart';
import 'package:lichess_mobile/src/model/game/material_diff.dart';
import 'package:lichess_mobile/src/model/game/player.dart';
import 'package:lichess_mobile/src/model/user/user.dart';
import 'package:lichess_mobile/src/utils/json.dart';

import 'game.dart';
import 'game_status.dart';
import 'player.dart';

part 'archived_game.freezed.dart';
part 'archived_game.g.dart';

Expand Down
7 changes: 3 additions & 4 deletions lib/src/model/game/game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/common/node.dart';
import 'package:lichess_mobile/src/model/common/perf.dart';
import 'package:lichess_mobile/src/model/common/speed.dart';
import 'package:lichess_mobile/src/model/game/game_status.dart';
import 'package:lichess_mobile/src/model/game/material_diff.dart';
import 'package:lichess_mobile/src/model/game/player.dart';
import 'package:lichess_mobile/src/network/http.dart';

import 'game_status.dart';
import 'material_diff.dart';
import 'player.dart';

part 'game.freezed.dart';
part 'game.g.dart';

Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/game/game_repository_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/game/archived_game.dart';
import 'package:lichess_mobile/src/model/game/game_repository.dart';
import 'package:lichess_mobile/src/model/game/game_storage.dart';
import 'package:lichess_mobile/src/network/http.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'game_repository.dart';

part 'game_repository_providers.g.dart';

/// Fetches a game from the local storage if available, otherwise fetches it from the server.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/model/game/over_the_board_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:lichess_mobile/src/model/common/eval.dart';
import 'package:lichess_mobile/src/model/common/id.dart';

import 'game.dart';
import 'game_status.dart';
import 'player.dart';
import 'package:lichess_mobile/src/model/game/game.dart';
import 'package:lichess_mobile/src/model/game/game_status.dart';
import 'package:lichess_mobile/src/model/game/player.dart';

part 'over_the_board_game.freezed.dart';
part 'over_the_board_game.g.dart';
Expand Down
7 changes: 3 additions & 4 deletions lib/src/model/game/playable_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/common/perf.dart';
import 'package:lichess_mobile/src/model/common/speed.dart';
import 'package:lichess_mobile/src/model/game/archived_game.dart';
import 'package:lichess_mobile/src/model/game/game.dart';
import 'package:lichess_mobile/src/model/game/game_status.dart';
import 'package:lichess_mobile/src/model/game/material_diff.dart';
import 'package:lichess_mobile/src/model/game/player.dart';
import 'package:lichess_mobile/src/model/user/user.dart';
import 'package:lichess_mobile/src/utils/json.dart';

import 'game.dart';
import 'game_status.dart';
import 'player.dart';

part 'playable_game.freezed.dart';

/// A game that can be played or watched.
Expand Down
5 changes: 2 additions & 3 deletions lib/src/model/lobby/lobby_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import 'package:http/http.dart' as http;
import 'package:lichess_mobile/src/model/common/chess.dart';
import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/common/perf.dart';
import 'package:lichess_mobile/src/model/lobby/correspondence_challenge.dart';
import 'package:lichess_mobile/src/model/lobby/game_seek.dart';
import 'package:lichess_mobile/src/network/http.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'correspondence_challenge.dart';
import 'game_seek.dart';

part 'lobby_repository.g.dart';

@riverpod
Expand Down
7 changes: 3 additions & 4 deletions lib/src/model/puzzle/puzzle_batch_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:lichess_mobile/src/db/database.dart';
import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_angle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:sqflite/sqflite.dart';

import 'puzzle.dart';
import 'puzzle_angle.dart';
import 'puzzle_theme.dart';

part 'puzzle_batch_storage.freezed.dart';
part 'puzzle_batch_storage.g.dart';

Expand Down
15 changes: 7 additions & 8 deletions lib/src/model/puzzle/puzzle_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ import 'package:intl/intl.dart';
import 'package:lichess_mobile/src/model/common/chess.dart';
import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/common/perf.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_angle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_difficulty.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_opening.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_streak.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
import 'package:lichess_mobile/src/model/puzzle/storm.dart';
import 'package:lichess_mobile/src/network/http.dart';
import 'package:lichess_mobile/src/utils/json.dart';

import 'puzzle.dart';
import 'puzzle_angle.dart';
import 'puzzle_difficulty.dart';
import 'puzzle_opening.dart';
import 'puzzle_streak.dart';
import 'puzzle_theme.dart';
import 'storm.dart';

part 'puzzle_repository.freezed.dart';

class PuzzleRepository {
Expand Down
13 changes: 6 additions & 7 deletions lib/src/model/puzzle/puzzle_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_angle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_batch_storage.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_preferences.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_repository.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_storage.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
import 'package:lichess_mobile/src/network/http.dart';
import 'package:logging/logging.dart';
import 'package:result_extensions/result_extensions.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'puzzle.dart';
import 'puzzle_angle.dart';
import 'puzzle_batch_storage.dart';
import 'puzzle_preferences.dart';
import 'puzzle_repository.dart';
import 'puzzle_theme.dart';

part 'puzzle_service.freezed.dart';
part 'puzzle_service.g.dart';

Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/puzzle/storm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import 'package:deep_pick/deep_pick.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:lichess_mobile/src/model/common/id.dart';

import 'puzzle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';

part 'storm.freezed.dart';

Expand Down
7 changes: 3 additions & 4 deletions lib/src/model/puzzle/storm_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ import 'package:lichess_mobile/src/model/auth/auth_session.dart';
import 'package:lichess_mobile/src/model/common/chess.dart';
import 'package:lichess_mobile/src/model/common/service/move_feedback.dart';
import 'package:lichess_mobile/src/model/common/service/sound_service.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_repository.dart';
import 'package:lichess_mobile/src/model/puzzle/storm.dart';
import 'package:lichess_mobile/src/network/http.dart';
import 'package:result_extensions/result_extensions.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'puzzle.dart';
import 'puzzle_repository.dart';
import 'storm.dart';

part 'storm_controller.freezed.dart';
part 'storm_controller.g.dart';

Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/relation/relation_repository_providers.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lichess_mobile/src/model/relation/relation_repository.dart';
import 'package:lichess_mobile/src/model/user/user.dart';
import 'package:lichess_mobile/src/network/http.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'relation_repository.dart';

part 'relation_repository_providers.g.dart';

@riverpod
Expand Down
9 changes: 4 additions & 5 deletions lib/src/model/tv/live_tv_channels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import 'package:dartchess/dartchess.dart';
import 'package:deep_pick/deep_pick.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:lichess_mobile/src/model/common/socket.dart';
import 'package:lichess_mobile/src/model/tv/featured_player.dart';
import 'package:lichess_mobile/src/model/tv/tv_channel.dart';
import 'package:lichess_mobile/src/model/tv/tv_game.dart';
import 'package:lichess_mobile/src/model/tv/tv_repository.dart';
import 'package:lichess_mobile/src/model/tv/tv_socket_events.dart';
import 'package:lichess_mobile/src/network/http.dart';
import 'package:lichess_mobile/src/network/socket.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'featured_player.dart';
import 'tv_channel.dart';
import 'tv_game.dart';
import 'tv_repository.dart';

part 'live_tv_channels.g.dart';

typedef LiveTvChannelsState = IMap<TvChannel, TvGameSnapshot>;
Expand Down
5 changes: 2 additions & 3 deletions lib/src/model/tv/tv_game.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import 'package:dartchess/dartchess.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/tv/featured_player.dart';
import 'package:lichess_mobile/src/model/tv/tv_channel.dart';
import 'package:lichess_mobile/src/model/user/user.dart';

import 'featured_player.dart';
import 'tv_channel.dart';

part 'tv_game.freezed.dart';

@freezed
Expand Down
5 changes: 2 additions & 3 deletions lib/src/model/tv/tv_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:http/http.dart' as http;
import 'package:lichess_mobile/src/model/common/chess.dart';
import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/tv/tv_channel.dart';
import 'package:lichess_mobile/src/model/tv/tv_game.dart';
import 'package:lichess_mobile/src/model/user/user.dart';
import 'package:lichess_mobile/src/network/http.dart';

import './tv_channel.dart';
import './tv_game.dart';

typedef TvChannels = IMap<TvChannel, TvGame>;

class TvRepository {
Expand Down
Loading

0 comments on commit 59a38b0

Please sign in to comment.