• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

KSP-CKAN / CKAN / 15655026327

14 Jun 2025 06:40PM UTC coverage: 27.152% (-3.2%) from 30.329%
15655026327

Pull #4392

github

web-flow
Merge bb1dadfef into 1b4a54286
Pull Request #4392: Writethrough when saving files, add Netkan tests

3703 of 12085 branches covered (30.64%)

Branch coverage included in aggregate %.

19 of 32 new or added lines in 18 files covered. (59.38%)

9 existing lines in 7 files now uncovered.

8041 of 31168 relevant lines covered (25.8%)

0.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

29.41
/Core/Configuration/StabilityToleranceConfig.cs
1
using System;
2
using System.IO;
3
using System.Collections.Generic;
4
using System.ComponentModel;
5

6
using Newtonsoft.Json;
7

8
using CKAN.Extensions;
9

10
namespace CKAN.Configuration
11
{
12
    [JsonObject(MemberSerialization.OptIn)]
13
    public class StabilityToleranceConfig
14
    {
15
        public StabilityToleranceConfig(string path)
2✔
16
        {
2✔
17
            this.path = path;
2✔
18
            try
19
            {
2✔
20
                JsonConvert.PopulateObject(File.ReadAllText(this.path), this);
2✔
21
            }
×
22
            catch
2✔
23
            {
2✔
24
                // File doesn't exist yet, we can create it at save
25
            }
2✔
26
        }
2✔
27

28
        public bool Save()
29
        {
×
30
            try
31
            {
×
NEW
32
                JsonConvert.SerializeObject(this, Formatting.Indented)
×
33
                           .WriteThroughTo(path);
UNCOV
34
                return true;
×
35
            }
36
            catch
×
37
            {
×
38
                return false;
×
39
            }
40
        }
×
41

42
        public ReleaseStatus? ModStabilityTolerance(string identifier)
43
            => modStabilityTolerance.TryGetValue(identifier, out ReleaseStatus relStat)
2!
44
                   ? relStat
45
                   : null;
46

47
        public void SetModStabilityTolerance(string identifier, ReleaseStatus? relStat)
48
        {
×
49
            if (relStat is ReleaseStatus rs)
×
50
            {
×
51
                modStabilityTolerance[identifier] = rs;
×
52
            }
×
53
            else
54
            {
×
55
                modStabilityTolerance.Remove(identifier);
×
56
            }
×
57
            Changed?.Invoke(identifier, relStat);
×
58
            Save();
×
59
        }
×
60

61
        public ReleaseStatus OverallStabilityTolerance
62
        {
63
            get => overallStabilityTolerance;
2✔
64
            set
65
            {
×
66
                overallStabilityTolerance = value;
×
67
                Save();
×
68
                Changed?.Invoke(null, value);
×
69
            }
×
70
        }
71

72
        public ICollection<string> OverriddenModIdentifiers => modStabilityTolerance.Keys;
×
73

74
        public event Action<string?, ReleaseStatus?>? Changed;
75

76
        [JsonProperty("overall_stability_tolerance", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
77
        [DefaultValue(ReleaseStatus.stable)]
78
        private ReleaseStatus overallStabilityTolerance = ReleaseStatus.stable;
2✔
79

80
        [JsonProperty("mod_stability_tolerance", NullValueHandling = NullValueHandling.Ignore)]
81
        private readonly SortedDictionary<string, ReleaseStatus> modStabilityTolerance =
2✔
82
            new SortedDictionary<string, ReleaseStatus>();
83

84
        [JsonIgnore]
85
        private readonly string path;
86
    }
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc