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

KSP-CKAN / CKAN / 15889942513

26 Jun 2025 12:20AM UTC coverage: 47.631% (+5.4%) from 42.239%
15889942513

push

github

HebaruSan
Merge #4400 Make hash caches thread-safe, Netkan warning for uncompiled plugins

3880 of 8730 branches covered (44.44%)

Branch coverage included in aggregate %.

33 of 75 new or added lines in 9 files covered. (44.0%)

6 existing lines in 3 files now uncovered.

8334 of 16913 relevant lines covered (49.28%)

1.01 hits per line

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

34.38
/Netkan/Validators/PluginsValidator.cs
1
using System.Linq;
2
using ICSharpCode.SharpZipLib.Zip;
3
using log4net;
4

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

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

20
        public void Validate(Metadata metadata)
21
        {
2✔
22
            Log.Debug("Validating that metadata is appropriate for DLLs");
2✔
23

24
            var json = metadata.AllJson;
2✔
25
            var mod  = CkanModule.FromJson(json.ToString());
2✔
26
            if (!mod.IsDLC)
2!
27
            {
2✔
28
                var package = _http.DownloadModule(metadata);
2✔
29
                if (!string.IsNullOrEmpty(package))
2!
30
                {
×
NEW
31
                    var zip  = new ZipFile(package);
×
NEW
32
                    var inst = new GameInstance(_game, "/", "dummy", new NullUser());
×
33

NEW
34
                    if (_moduleService.GetPlugins(mod, zip, inst)
×
NEW
35
                                      .Select(f => inst.ToRelativeGameDir(f.destination))
×
NEW
36
                                      .OrderBy(f => f)
×
37
                                      .ToArray()
38
                        is { Length: > 0 } plugins)
39
                    {
×
NEW
40
                        if (plugins.Select(inst.DllPathToIdentifier)
×
41
                                   .OfType<string>()
NEW
42
                                   .Where(ident => ident is { Length: > 0 }
×
43
                                                   && !identifiersToIgnore.Contains(ident))
44
                                   .ToHashSet()
45
                            is { Count: > 0 } dllIdentifiers
46
                            && !dllIdentifiers.Contains(metadata.Identifier))
47
                        {
×
NEW
48
                            Log.WarnFormat("No plugin matching the identifier, manual installations won't be detected: {0}",
×
49
                                           string.Join(", ", plugins));
UNCOV
50
                        }
×
51

NEW
52
                        bool boundedCompatibility = json.ContainsKey("ksp_version")
×
53
                                                    || json.ContainsKey("ksp_version_max");
54
                        if (!boundedCompatibility)
×
55
                        {
×
56
                            Log.Warn("Unbounded future compatibility for module with a plugin, consider setting $vref or ksp_version or ksp_version_max");
×
57
                        }
×
58
                    }
×
NEW
59
                    else if (_moduleService.GetSourceCode(mod, zip, inst)
×
NEW
60
                                           .Select(f => inst.ToRelativeGameDir(f.destination))
×
NEW
61
                                           .OrderBy(f => f)
×
62
                                           .ToArray()
63
                             is { Length: > 0 } sourceCode)
NEW
64
                    {
×
NEW
65
                        Log.WarnFormat("Found C# source code without DLL, mod may not have been compiled: {0}",
×
66
                                       string.Join(", ", sourceCode));
NEW
67
                    }
×
UNCOV
68
                }
×
69
            }
2✔
70
        }
2✔
71

72
        /// <summary>
73
        /// These identifiers will not be treated as potential auto-detected mods
74
        /// for purposes of the identifier-matching warning,
75
        /// because they are commonly bundled and installed by other mods,
76
        /// which may or may not have their own plugins.
77
        /// </summary>
78
        private readonly string[] identifiersToIgnore = new string[]
2✔
79
        {
80
            "MiniAVC"
81
        };
82

83
        private readonly IHttpService   _http;
84
        private readonly IModuleService _moduleService;
85
        private readonly IGame          _game;
86

87
        private static readonly ILog Log = LogManager.GetLogger(typeof(PluginsValidator));
2✔
88
    }
89
}
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