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

KSP-CKAN / CKAN / 17904669173

22 Sep 2025 04:34AM UTC coverage: 75.604% (+1.2%) from 74.397%
17904669173

push

github

HebaruSan
Merge #4443 Report number of filtered files in install

5231 of 7236 branches covered (72.29%)

Branch coverage included in aggregate %.

192 of 218 new or added lines in 41 files covered. (88.07%)

35 existing lines in 7 files now uncovered.

11163 of 14448 relevant lines covered (77.26%)

1.58 hits per line

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

71.79
/Netkan/Validators/CraftsInShipsValidator.cs
1
using System.Linq;
2
using Newtonsoft.Json.Linq;
3
using ICSharpCode.SharpZipLib.Zip;
4
using log4net;
5

6
using CKAN.NetKAN.Services;
7
using CKAN.NetKAN.Model;
8

9
namespace CKAN.NetKAN.Validators
10
{
11
    internal sealed class CraftsInShipsValidator : IValidator
12
    {
13
        public CraftsInShipsValidator(IHttpService http, IModuleService moduleService)
2✔
14
        {
2✔
15
            _http          = http;
2✔
16
            _moduleService = moduleService;
2✔
17
        }
2✔
18

19
        public void Validate(Metadata metadata)
20
        {
2✔
21
            Log.Debug("Validating that craft files are installed into Ships");
2✔
22

23
            JObject    json = metadata.AllJson;
2✔
24
            CkanModule mod  = CkanModule.FromJson(json.ToString());
2✔
25
            if (!mod.IsDLC)
2!
26
            {
2✔
27
                var package = _http.DownloadModule(metadata);
2✔
28
                if (!string.IsNullOrEmpty(package))
2✔
29
                {
2✔
30
                    var zip       = new ZipFile(package);
2✔
31
                    var badCrafts = _moduleService.GetCrafts(mod, zip)
2✔
NEW
32
                        .Where(f => !AllowedCraftPath(f.destination))
×
33
                        .ToList();
34

35
                    if (badCrafts.Count != 0)
2!
36
                    {
×
37
                        Log.WarnFormat(
×
38
                            "Craft files installed outside Ships folder: {0}",
NEW
39
                            string.Join(", ", badCrafts.Select(f => f.destination).Order()));
×
40
                    }
×
41
                }
2✔
42
            }
2✔
43
        }
2✔
44

45
        private static bool AllowedCraftPath(string path)
46
            => path.StartsWith("Ships/")
×
47
               || path.StartsWith("Missions/")
48
               || path.StartsWith("GameData/ContractPacks/");
49

50
        private readonly IHttpService   _http;
51
        private readonly IModuleService _moduleService;
52

53
        private static readonly ILog Log = LogManager.GetLogger(typeof(CraftsInShipsValidator));
2✔
54
    }
55
}
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

© 2025 Coveralls, Inc