• 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

75.41
/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
                {
2✔
31
                    var zip  = new ZipFile(package);
2✔
32

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

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

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

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

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