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

KSP-CKAN / CKAN / 44970223158

22 Nov 2026 01:10AM UTC coverage: 80.067% (-0.8%) from 80.887%
44970223158

Pull #4740

github

web-flow
Merge 574be593e into c0650d450
Pull Request #4740: Add caching to netkan inflate steps

4264 of 6013 branches covered (70.91%)

Branch coverage included in aggregate %.

330 of 459 new or added lines in 18 files covered. (71.9%)

51 existing lines in 10 files now uncovered.

8730 of 10216 relevant lines covered (85.45%)

0.9 hits per line

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

68.42
/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

12
namespace CKAN.NetKAN.Validators
13
{
14
    internal sealed class ModuleManagerDependsValidator : IValidator
15
    {
16
        public ModuleManagerDependsValidator(IModuleService moduleService, ICacheService cacheService)
1 ✔
17
        {
18
            _moduleService = moduleService;
1 ✔
19
            _cacheService  = cacheService;
1 ✔
20
        }
1 ✔
21

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

26
            JObject    json = metadata.AllJson;
1 ✔
27
            CkanModule mod  = CkanModule.FromJson(json.ToString());
1 ✔
28
            if (mod.IsDLC)
1 !
29
            {
NEW
30
                return ;
×
31
            }
32

33
            _cacheService.ExecuteCached(metadata, typeof(ModuleManagerDependsValidator), package =>
1 ✔
34
            {
35
                if (string.IsNullOrEmpty(package))
1 ✔
36
                {
37
                    return;
1 ✔
38
                }
39

40
                using ZipFile zip = new ZipFile(package);
1 ✔
41
                var mmConfigs = _moduleService.GetConfigFiles(mod, zip)
1 ✔
NEW
42
                    .Where(cfg => moduleManagerRegex.IsMatch(
×
43
                        new StreamReader(zip.GetInputStream(cfg.source)).ReadToEnd()))
44
                    .Memoize();
45

NEW
46
                bool dependsOnMM = mod?.depends?.Any(r => r.ContainsAny(identifiers)) ?? false;
×
47

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

62
        private readonly string[] identifiers = new string[] { "ModuleManager" };
1 ✔
63

64
        private static readonly Regex moduleManagerRegex = new Regex(
1 ✔
65
            @"^\s*[@+$\-!%]|^\s*[a-zA-Z0-9_]+:",
66
            RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline
67
        );
68

69
        private readonly IModuleService _moduleService;
70
        private readonly ICacheService  _cacheService;
71

72
        private static readonly ILog Log = LogManager.GetLogger(typeof(ModuleManagerDependsValidator));
1 ✔
73
    }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc