Skip to content

Commit 44196b8

Browse files
blowfishproLisias
authored andcommitted
Address some messages (synthetic commit by lisias)
Do some dependency in jection on InterceptLogHandler, no need to hold onto a reference to it as Unity will Remove paramter checks in StreamLogger as StreamWriter does the same checks Ibut keep basic tests for them)
1 parent c29102e commit 44196b8

26 files changed

+51
-80
lines changed

Source/ModuleManager/Cats/CatAnimator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections;
2+
using System.Diagnostics.CodeAnalysis;
23
using UnityEngine;
34

45
#if CATS
@@ -13,6 +14,7 @@ class CatAnimator : MonoBehaviour
1314
private SpriteRenderer spriteRenderer;
1415
private int spriteIdx;
1516

17+
[SuppressMessage("CodeQuality", "IDE0051", Justification = "Called by Unity")]
1618
void Start()
1719
{
1820
spriteRenderer = this.GetComponent<SpriteRenderer>();

Source/ModuleManager/Cats/CatManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static void LaunchCat()
1616
InitCats();
1717

1818
GameObject cat = LaunchCat(scale);
19-
CatMover catMover = cat.AddComponent<CatMover>();
19+
cat.AddComponent<CatMover>();
2020
}
2121

2222
public static void LaunchCats()

Source/ModuleManager/Cats/CatMover.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections;
1+
using System.Diagnostics.CodeAnalysis;
22
using UnityEngine;
33

44
#if CATS
@@ -25,6 +25,7 @@ public class CatMover : MonoBehaviour
2525
private bool clearTrail = false;
2626

2727
// Use this for initialization
28+
[SuppressMessage("CodeQuality", "IDE0051", Justification = "Called by Unity")]
2829
void Start()
2930
{
3031
trail = this.GetComponent<TrailRenderer>();
@@ -42,6 +43,7 @@ void Start()
4243
clearTrail = true;
4344
}
4445

46+
[SuppressMessage("CodeQuality", "IDE0051", Justification = "Called by Unity")]
4547
void Update()
4648
{
4749
if (trail.time <= 0f)

Source/ModuleManager/Cats/CatOrbiter.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34
using KSP.UI;
45
using UnityEngine;
56
using Random = UnityEngine.Random;
@@ -9,7 +10,7 @@ namespace ModuleManager.Cats
910
{
1011
class CatOrbiter : MonoBehaviour
1112
{
12-
private static List<CatOrbiter> orbiters = new List<CatOrbiter>();
13+
private static readonly List<CatOrbiter> orbiters = new List<CatOrbiter>();
1314

1415
private static CatOrbiter sun;
1516

@@ -21,7 +22,7 @@ class CatOrbiter : MonoBehaviour
2122
private Vector2d force;
2223
private float scale = 1;
2324

24-
private double G = 6.67408E-11;
25+
private const double G = 6.67408E-11;
2526

2627
public double Mass
2728
{
@@ -113,13 +114,14 @@ private void DoForces()
113114
}
114115
}
115116

116-
117+
[SuppressMessage("CodeQuality", "IDE0051", Justification = "Called by Unity")]
117118
void OnDestroy()
118119
{
119120
orbiters.Remove(this);
120121
TimingManager.FixedUpdateRemove(TimingManager.TimingStage.Earlyish, DoForces);
121122
}
122123

124+
[SuppressMessage("CodeQuality", "IDE0051", Justification = "Called by Unity")]
123125
void FixedUpdate()
124126
{
125127
//if (this == sun)

Source/ModuleManager/Extensions/StringExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static bool IsBracketBalanced(this string s)
1818
return level == 0;
1919
}
2020

21-
private static Regex whitespaceRegex = new Regex(@"\s+");
21+
private static readonly Regex whitespaceRegex = new Regex(@"\s+");
2222

2323
public static string RemoveWS(this string withWhite)
2424
{

Source/ModuleManager/Fix16.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System.Collections;
2+
using System.Diagnostics.CodeAnalysis;
23

34
namespace ModuleManager
45
{
56
class Fix16 : LoadingSystem
67
{
8+
[SuppressMessage("CodeQuality", "IDE0051", Justification = "Called by Unity")]
79
private void Awake()
810
{
911
if (Instance != null)

Source/ModuleManager/Logging/UnityLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace ModuleManager.Logging
66
{
77
public class UnityLogger : IBasicLogger
88
{
9-
private ILogger logger;
9+
private readonly ILogger logger;
1010

1111
public UnityLogger(ILogger logger)
1212
{

Source/ModuleManager/MMPatchLoader.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Reflection;
99
using System.Text;
1010
using System.Text.RegularExpressions;
11-
using UnityEngine;
1211

1312
using ModuleManager.Collections;
1413
using ModuleManager.Logging;
@@ -352,7 +351,6 @@ private bool CheckFilesChange(UrlDir.UrlFile[] files, ConfigNode shaConfigNode)
352351
noChange = false;
353352
}
354353
}
355-
356354
for (int i = 0; i < files.Length; i++)
357355
{
358356
string url = files[i].GetUrlWithExtension();

Source/ModuleManager/NeedsChecker.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.Linq;
45
using ModuleManager.Extensions;
56
using ModuleManager.Logging;
@@ -20,6 +21,7 @@ public class NeedsChecker : INeedsChecker
2021
private readonly IEnumerable<string> mods;
2122
private readonly UrlDir gameData;
2223
private readonly IPatchProgress progress;
24+
[SuppressMessage("CodeQuality", "IDE0052", Justification = "Reserved for future use")]
2325
private readonly IBasicLogger logger;
2426

2527
public NeedsChecker(IEnumerable<string> mods, UrlDir gameData, IPatchProgress progress, IBasicLogger logger)

Source/ModuleManager/NodeMatcher.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ public interface INodeMatcher
1010

1111
public class NodeMatcher : INodeMatcher
1212
{
13-
private static readonly char[] sep = { '[', ']' };
14-
15-
private string type;
16-
private string[] namePatterns = null;
17-
private string constraints = "";
13+
private readonly string type;
14+
private readonly string[] namePatterns = null;
15+
private readonly string constraints = "";
1816

1917
public NodeMatcher(string type, string name, string constraints)
2018
{

0 commit comments

Comments
 (0)