Skip to content

Commit 1978547

Browse files
committed
refactor: clean up code warnings
1 parent 4a9d159 commit 1978547

File tree

8 files changed

+26
-43
lines changed

8 files changed

+26
-43
lines changed

SendItems/Services/CommandService.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public class CommandService : ICommandService
1212
private bool _savedGameLoaded = false;
1313

1414
private readonly IMod _mod;
15-
private readonly IConfigurationService _configService;
1615
private readonly IFarmerService _farmerService;
1716

1817
private const string _meCommand = "si_me";
@@ -25,11 +24,9 @@ public class CommandService : ICommandService
2524

2625
public CommandService(
2726
IMod mod,
28-
IConfigurationService configService,
2927
IFarmerService farmerService)
3028
{
3129
_mod = mod;
32-
_configService = configService;
3330
_farmerService = farmerService;
3431

3532
RegisterCommands();
@@ -105,13 +102,13 @@ private void HandleCommand(string command, string[] args)
105102
switch (command)
106103
{
107104
case _meCommand:
108-
ShowMyDetails(args);
105+
ShowMyDetails();
109106
break;
110107
case _localFarmersCommand:
111-
ListLocalFarmers(args);
108+
ListLocalFarmers();
112109
break;
113110
case _addLocalFarmersCommand:
114-
AddLocalFarmers(args);
111+
AddLocalFarmers();
115112
break;
116113
case _addFriendCommand:
117114
AddFriend(args);
@@ -120,25 +117,25 @@ private void HandleCommand(string command, string[] args)
120117
RemoveFriend(args);
121118
break;
122119
case _removeAllFriendsCommand:
123-
RemoveAllFriends(args);
120+
RemoveAllFriends();
124121
break;
125122
case _myFriendsCommand:
126-
ListMyFriends(args);
123+
ListMyFriends();
127124
break;
128125
default:
129126
throw new NotImplementedException($"Send Items received unknown command '{command}'.");
130127
}
131128
}
132129

133-
private void ShowMyDetails(string[] args)
130+
private void ShowMyDetails()
134131
{
135132
_mod.Monitor.Log("This is your \"friend command\". Get your friends to run this command in the SMAPI console to add you as a friend. Each farmer (saved game) has it's own list of friends.", LogLevel.Info);
136133
_mod.Monitor.Log($"{_addFriendCommand} {_farmerService.CurrentFarmer.Id} {_farmerService.CurrentFarmer.ConsoleSafeName} {_farmerService.CurrentFarmer.ConsoleSaveFarmName}", LogLevel.Info);
137134
}
138135

139-
private void ListLocalFarmers(string[] args)
136+
private void ListLocalFarmers()
140137
{
141-
var farmers = Repository.Instance.Fetch<Domain.Farmer>();
138+
var farmers = Repository.Instance.Fetch<Farmer>();
142139
if (farmers.Any())
143140
{
144141
_mod.Monitor.Log("Here are all the local farmers (saved games)...", LogLevel.Info);
@@ -154,9 +151,9 @@ private void ListLocalFarmers(string[] args)
154151
}
155152
}
156153

157-
private void AddLocalFarmers(string[] args)
154+
private void AddLocalFarmers()
158155
{
159-
var farmers = Repository.Instance.Fetch<Domain.Farmer>();
156+
var farmers = Repository.Instance.Fetch<Farmer>();
160157
var count = 0;
161158
foreach (var farmer in farmers)
162159
{
@@ -222,7 +219,7 @@ private void RemoveFriend(string[] args)
222219
}
223220
}
224221

225-
private void RemoveAllFriends(string[] args)
222+
private void RemoveAllFriends()
226223
{
227224
var success = _farmerService.RemoveAllFriendFromCurrentPlayer();
228225
if (success)
@@ -235,7 +232,7 @@ private void RemoveAllFriends(string[] args)
235232
}
236233
}
237234

238-
private void ListMyFriends(string[] args)
235+
private void ListMyFriends()
239236
{
240237
var friends = _farmerService.CurrentFarmer.Friends;
241238
if (friends.Any())

SendItems/Services/ConfigurationService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace Denifia.Stardew.SendItems.Services
1010
// TODO: Add private members for each of the public properties for performance
1111
public class ConfigurationService : IConfigurationService
1212
{
13-
private IModHelper _modHelper;
14-
private ModConfig _modConfig;
13+
private readonly IModHelper _modHelper;
14+
private readonly ModConfig _modConfig;
1515
private const string _databaseName = ModConstants.DatabaseName;
1616
private string _connectionString = string.Empty;
1717

SendItems/Services/FarmerService.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,5 @@ private Domain.Farmer GetFarmerById(string id)
113113
{
114114
return Repository.Instance.SingleOrDefault<Domain.Farmer>(x => x.Id == id);
115115
}
116-
117-
private void DetermineCurrentFarmer()
118-
{
119-
var name = Game1.player.Name;
120-
var farmName = Game1.player.farmName;
121-
_currentFarmer = Repository.Instance.FirstOrDefault<Domain.Farmer>(x => x.Name == name && x.FarmName == farmName);
122-
}
123116
}
124117
}

SendItems/Services/LetterboxService.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@ namespace Denifia.Stardew.SendItems.Services
1313
/// </summary>
1414
public class LetterboxService : ILetterboxService
1515
{
16-
private readonly IConfigurationService _configService;
1716
private readonly IFarmerService _farmerService;
1817

1918
public LetterboxService(
20-
IConfigurationService configService,
2119
IFarmerService farmerService)
2220
{
23-
_configService = configService;
2421
_farmerService = farmerService;
2522

2623
ModEvents.PlayerUsingLetterbox += PlayerUsingLetterbox;

SendItems/Services/PostboxService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private void MailComposed(object sender, MailComposedEventArgs e)
8484

8585
if (item == null) return;
8686

87-
var messageText = string.Format(_messageFormat, fromFarmer.Name, item.ParentSheetIndex, item.getStack());
87+
var messageText = string.Format(_messageFormat, fromFarmer.Name, item.ParentSheetIndex, item.Stack);
8888

8989
// Consider: Moving this to own service
9090
var mail = new Mail()

SendItemsApi/Domain/AzureTableStorageRepository.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ namespace Denifia.Stardew.SendItemsApi.Domain
99
{
1010
public class AzureTableStorageRepository : ITableStorageRepository
1111
{
12-
CloudStorageAccount _storageAccount;
13-
CloudTableClient _tableClient;
14-
CloudTable _table;
15-
AzureStorageConfig _azureTableStorageConfig;
12+
readonly CloudStorageAccount _storageAccount;
13+
readonly CloudTableClient _tableClient;
14+
readonly CloudTable _table;
15+
readonly AzureStorageConfig _azureTableStorageConfig;
1616

1717
public AzureTableStorageRepository(IOptions<AzureStorageConfig> azureTableStorageConfig)
1818
{
@@ -59,7 +59,7 @@ public async Task<TEntity> Retrieve<TEntity>(string partitionKey, string rowKey)
5959
{
6060

6161
}
62-
return default(TEntity);
62+
return default;
6363
}
6464

6565
public async Task<bool> Delete<TEntity>(TEntity entity) where TEntity : ITableEntity

SendItemsApi/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ namespace Denifia.Stardew.SendItemsApi
66
{
77
public class Program
88
{
9-
public static void Main(string[] args)
9+
public static void Main()
1010
{
1111
var host = new WebHostBuilder()
1212
.UseKestrel()
1313
.UseContentRoot(Directory.GetCurrentDirectory())
1414
.UseIISIntegration()
1515
.UseStartup<Startup>()
16-
.UseApplicationInsights()
1716
.Build();
1817

1918
host.Run();

SendItemsApi/Startup.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ public class Startup
1212
public Startup(IWebHostEnvironment env)
1313
{
1414
var builder = new ConfigurationBuilder()
15-
.SetBasePath(env.ContentRootPath);
16-
// .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
17-
// .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
18-
//.AddEnvironmentVariables();
15+
.SetBasePath(env.ContentRootPath)
16+
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
17+
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
18+
.AddEnvironmentVariables();
1919
Configuration = builder.Build();
2020
}
2121

@@ -30,11 +30,8 @@ public void ConfigureServices(IServiceCollection services)
3030
}
3131

3232
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
33-
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
33+
public void Configure(IApplicationBuilder app)
3434
{
35-
// loggerFactory.AddConsole(Configuration.GetSection("Logging"));
36-
// loggerFactory.AddDebug();
37-
3835
app.UseRouting();
3936
app.UseStaticFiles();
4037
app.UseEndpoints(x =>

0 commit comments

Comments
 (0)