forked from StefanMaron/BusinessCentral.LinterCop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinterSettings.cs
49 lines (45 loc) · 2.16 KB
/
LinterSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Newtonsoft.Json;
namespace BusinessCentral.LinterCop.Helpers
{
class LinterSettings
{
public int cyclomaticComplexityThreshold = 8;
public int maintainabilityIndexThreshold = 20;
public bool enableRule0011ForTableFields = false;
public bool enableRule0016ForApiObjects = false;
public string WorkingDir = "";
static public LinterSettings instance;
static public void Create(string WorkingDir)
{
if (instance == null || instance.WorkingDir != WorkingDir)
{
try
{
StreamReader r = File.OpenText(Path.Combine(WorkingDir, "LinterCop.json"));
string json = r.ReadToEnd();
r.Close();
instance = new LinterSettings();
InternalLinterSettings internalInstance = JsonConvert.DeserializeObject<InternalLinterSettings>(json);
instance.cyclomaticComplexityThreshold = internalInstance.cyclomaticComplexityThreshold ?? internalInstance.cyclomaticComplexetyThreshold ?? instance.cyclomaticComplexityThreshold;
instance.maintainabilityIndexThreshold = internalInstance.maintainabilityIndexThreshold ?? internalInstance.maintainablityIndexThreshold ?? instance.maintainabilityIndexThreshold;
instance.enableRule0011ForTableFields = internalInstance.enableRule0011ForTableFields;
instance.enableRule0016ForApiObjects = internalInstance.enableRule0016ForApiObjects;
instance.WorkingDir = WorkingDir;
}
catch
{
instance = new LinterSettings();
}
}
}
}
internal class InternalLinterSettings
{
public int? cyclomaticComplexityThreshold;
public int? maintainabilityIndexThreshold;
public int? cyclomaticComplexetyThreshold; // Misspelled, deprecated
public int? maintainablityIndexThreshold; // Misspelled, deprecated
public bool enableRule0011ForTableFields = false;
public bool enableRule0016ForApiObjects = false;
}
}