Clean up stale code identified by static analysis#135
Clean up stale code identified by static analysis#135robinplace wants to merge 7 commits intothomaswp:integrationfrom
Conversation
f3c95f6 to
64af1e7
Compare
There was a problem hiding this comment.
Serializer.cs is FileIO.cs but with unused classes removed. I renamed it because all it does now is serialize-deserialize.
469c348 to
50d6786
Compare
50d6786 to
777d391
Compare
BeaverBuddies/IO/FileIO.cs
Outdated
There was a problem hiding this comment.
Makes me a bit sad to see it go, since this was the original way the mod worked, but there's no active plans to add an actual replay system into the mod, and if we did we'd want to reimplement it anyway.
There was a problem hiding this comment.
This is quite useful code. It doesn't go in the deployed mod, but it's useful for dev. Is there a nice way to mark that for your static analysis tool?
| } | ||
| } | ||
|
|
||
| public void FinishFullTickIfNeededAndThen(Action action) |
There was a problem hiding this comment.
I realize this is actually the method that probably should used, rather than calling the TickingService's directly. Otherwise saving during a pause wouldn't happen until the next tick. So we should keep that
thomaswp
left a comment
There was a problem hiding this comment.
Thanks for the cleanup. I've regretted not starting with a good import organization setting on. I suppose we should be consistent - I'll follow up with a comment about that.
Two main changes (see comments):
ReflectionUtilsis still used, just only in devFinishFullTickifNeededAndThenshould be used.
I can fix both of those and merge.
|
So I assume for imports the simplest thing is just to be consistent in using VS's built-in remove unused and sort actions on save? That's harder to enforce in the repo. I think it's probably good enough to just put that in the readme to keep overhead lower and avoid external tools, but let me know if you have a strong opinion otherwise. |
| @@ -697,9 +692,9 @@ public class GameSaverSavePatcher | |||
| static bool Prefix(GameSaver __instance, QueuedSave queuedSave) | |||
| { | |||
There was a problem hiding this comment.
Here I've changed it to use the ReaplyService method directly so it's no longer unused.
|
Hmm, so unfortunately your static analysis tool seems to have been far too overaggressive on removing imports, especially those needed for HarmonyPatches, both the Harmony import itself and also the classes used in it. So right now this PR isn't usable. Did you actually get it to compile on your end? I see a few options:
|
|
This is also a note to self that once this is cleaned up, I should test to make sure that saving on pause doesn't cause any unforeseen issues with the change I made... |
|
The way to enforce this going forward is definitely a CI job that runs against PRs. We can configure such that build & lint tests get run automatically on every incoming PR. That way authors get feedback & can fix issues themselves. GitHub actions are free for public repositories & there's a ton we can do with them to take effort off your back (it will also catch if e.g. VS Code's built in import cleanup tool kills the build lol). |
Static analysis with Roslynator reveals quite a few unused files, classes, & methods. Removing these means less total code to keep track of for everyone going forward.