• 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

76.09
/Netkan/Validators/ModuleManagerDependsValidator.cs
1
using System.IO;
2
using System.Linq;
3
using System.Text.RegularExpressions;
4
using Newtonsoft.Json.Linq;
5
using ICSharpCode.SharpZipLib.Zip;
6
using log4net;
7

8
using CKAN.NetKAN.Services;
9
using CKAN.NetKAN.Model;
10
using CKAN.Extensions;
11
using CKAN.Games;
12

13
namespace CKAN.NetKAN.Validators
14
{
15
    internal sealed class ModuleManagerDependsValidator : IValidator
16
    {
17
        public ModuleManagerDependsValidator(IHttpService http, IModuleService moduleService, IGame game)
2✔
18
        {
2✔
19
            _http          = http;
2✔
20
            _moduleService = moduleService;
2✔
21
            _game          = game;
2✔
22
        }
2✔
23

24
        public void Validate(Metadata metadata)
25
        {
2✔
26
            Log.Debug("Validating that metadata dependencies are consistent with cfg file syntax");
2✔
27

28
            JObject    json = metadata.AllJson;
2✔
29
            CkanModule mod  = CkanModule.FromJson(json.ToString());
2✔
30
            if (!mod.IsDLC)
2!
31
            {
2✔
32
                var package = _http.DownloadModule(metadata);
2✔
33
                if (!string.IsNullOrEmpty(package))
2✔
34
                {
2✔
35
                    ZipFile zip = new ZipFile(package);
2✔
36
                    var mmConfigs = _moduleService.GetConfigFiles(mod, zip)
2✔
UNCOV
37
                        .Where(cfg => moduleManagerRegex.IsMatch(
×
38
                            new StreamReader(zip.GetInputStream(cfg.source)).ReadToEnd()))
39
                        .Memoize();
40

41
                    bool dependsOnMM = mod?.depends?.Any(r => r.ContainsAny(identifiers)) ?? false;
2✔
42

43
                    if (!dependsOnMM && mmConfigs.Any())
2!
44
                    {
×
45
                        Log.WarnFormat(
×
46
                            "ModuleManager syntax used without ModuleManager dependency: {0}",
47
                            string.Join(", ", mmConfigs.Select(cfg => cfg.source.Name).Order())
×
48
                        );
49
                    }
×
50
                    else if (dependsOnMM && !mmConfigs.Any())
2!
51
                    {
×
52
                        Log.Warn("ModuleManager dependency may not be needed, no ModuleManager syntax found");
×
53
                    }
×
54
                }
2✔
55
            }
2✔
56
        }
2✔
57

58
        private readonly string[] identifiers = new string[] { "ModuleManager" };
2✔
59

60
        private static readonly Regex moduleManagerRegex = new Regex(
2✔
61
            @"^\s*[@+$\-!%]|^\s*[a-zA-Z0-9_]+:",
62
            RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline
63
        );
64

65
        private readonly IHttpService   _http;
66
        private readonly IModuleService _moduleService;
67
        private readonly IGame          _game;
68

69
        private static readonly ILog Log = LogManager.GetLogger(typeof(ModuleManagerDependsValidator));
2✔
70
    }
71
}
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