Skip to content

Commit

Permalink
chore: fix analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Aug 11, 2024
1 parent dab47bd commit dfbff0d
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ words:
- chalkdart
- cirruslabs
- pubspec
- templating
3 changes: 2 additions & 1 deletion packages/cli/bin/short_warps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ void main(List<String> args) async {
// final nearbySystems = systemsCache.systems.where(
// (s) =>
// s.symbol != systemSymbol &&
// systemConnectivity.existsJumpPathBetween(s.symbol, ship.systemSymbol) &&
// systemConnectivity.existsJumpPathBetween(s.symbol,
// ship.systemSymbol) &&
// s.distanceTo(system) < maxFuel,
// );
// final routes = <RoutePlan>[];
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/lib/cache/json_list_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class JsonListStore<Record extends Object> {
file.writeAsStringSync(prettyprint);
}

/// Load records from a file.
/// Load records from a file if file exists, otherwise returns null.
static List<R>? maybeLoadRecords<R>(
FileSystem fs,
String path,
Expand All @@ -58,6 +58,7 @@ class JsonListStore<Record extends Object> {
return null;
}

/// Load records from a file or throw an exception if the file does not exist.
static List<R> loadRecords<R>(
FileSystem fs,
String path,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/lib/cache/market_listing_snapshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MarketListingSnapshot {
return MarketListingSnapshot(listings);
}

/// Load the MarketListingSnapshot for a single system.
static Future<MarketListingSnapshot> loadOneSystem(
Database db,
SystemSymbol systemSymbol,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/central_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ class CentralCommand {

final ships = await ShipSnapshot.load(db);
final phase = _determineGamePhase(ships);
print(phase);
logger.info("$phase");
config = Config(phase);

final marketListings = await MarketListingSnapshot.load(db);
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/lib/logic/printing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,12 @@ String describeShipNav(
return 'Docked at $waypoint';
case ShipNavStatus.IN_ORBIT:
final arrivalDuration = getNow().difference(nav.route.arrival);
return 'Orbiting $waypoint since ${approximateDuration(arrivalDuration)}';
final arrivalString = approximateDuration(arrivalDuration);
return 'Orbiting $waypoint since $arrivalString';
case ShipNavStatus.IN_TRANSIT:
final remainingDuration = nav.route.arrival.difference(getNow());
return 'Transit to $waypoint in ${approximateDuration(remainingDuration)}';
final remainingString = approximateDuration(remainingDuration);
return 'Transit to $waypoint in $remainingString';
}
return 'Unknown';
}
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/lib/nav/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,13 @@ Future<ShipyardListing?> nearestShipyard(
return listing;
}

/// Compute the travel time to the given waypoint considering the current ship
/// location.
Duration travelTimeTo(
RoutePlanner routePlanner, Ship ship, WaypointSymbol waypoint) {
RoutePlanner routePlanner,
Ship ship,
WaypointSymbol waypoint,
) {
final route = routePlanner.planRoute(
ship.shipSpec,
start: ship.waypointSymbol,
Expand Down
11 changes: 7 additions & 4 deletions packages/cli/lib/net/register.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import 'package:types/types.dart';

/// loadAuthTokenOrRegister loads the auth token from the given file system
/// or registers a new user and returns the auth token.
Future<String> loadAuthTokenOrRegister(Database db,
{String? agentName, String? email}) async {
Future<String> loadAuthTokenOrRegister(
Database db, {
String? agentName,
String? email,
}) async {
final token = await db.getAuthToken();
if (token != null) {
return token;
Expand All @@ -19,7 +22,7 @@ Future<String> loadAuthTokenOrRegister(Database db,
// Otherwise, register a new user.
final name = agentName ?? logger.prompt('What is your agent name?');
final token = await register(db, agentName: name, email: email);
db.setAuthToken(token);
await db.setAuthToken(token);
return token;
}
}
Expand Down Expand Up @@ -64,7 +67,7 @@ Future<String> register(
chosenFaction =
factions.firstWhere((f) => f.symbol.value == faction.toUpperCase());
} else {
logger.warn("Faction not specified. Choosing a random faction.");
logger.warn('Faction not specified. Choosing a random faction.');
chosenFaction =
recruitingFactions[Random().nextInt(recruitingFactions.length)];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/plan/accounting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:types/types.dart';
/// Compute the total value across all cargo for all ships.
Future<int> computeInventoryValue(
ShipSnapshot ships,
// TODO(eseidel): This wants a MedianPriceCache rather than MarketPriceSnapshot.
// TODO(eseidel): Use a MedianPriceCache rather than MarketPriceSnapshot.
MarketPriceSnapshot marketPrices,
) async {
final countByTradeSymbol = <TradeSymbol, int>{};
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/behavior/miner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ void main() {

final logger = _MockLogger();

final paddedArrival = arrival.add(Duration(seconds: 1));
final paddedArrival = arrival.add(const Duration(seconds: 1));
final result = await runWithLogger(logger, () async {
final result = await transferToHaulersOrWait(
state,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/net/auth_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void main() {
test('loadAuthToken', () async {
final db = _MockDatabase();
expect(() => defaultApi(db), throwsException);
when(() => db.getAuthToken()).thenAnswer((_) async => 'token');
when(db.getAuthToken).thenAnswer((_) async => 'token');
final api = await defaultApi(db);
expect(api.apiClient, isA<CountingApiClient>());
});
Expand Down

0 comments on commit dfbff0d

Please sign in to comment.