{"record":{"id":"33b0ec468ac178d5","repo":"JosefNemec/Playnite","slug":"uknown-file-exclusion-configuration","errorCode":null,"errorMessage":"Uknown file exclusion configuration.","messagePattern":"Uknown file exclusion configuration\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"source/Playnite/Emulators/Scanner.cs","lineNumber":483,"sourceCode":"                    matches.AddMissing(match);\r\n                }\r\n                else if (excFile.Absolute)\r\n                {\r\n                    var match = files.FirstOrDefault(a => a.Equals(excFile.Path, StringComparison.OrdinalIgnoreCase));\r\n                    if (match != null)\r\n                    {\r\n                        matches.AddMissing(match);\r\n                    }\r\n                }\r\n                else if (!excFile.Absolute)\r\n                {\r\n                    var comp = excFile.Path.PrefixWithDirSeparator();\r\n                    var match = files.Where(a => a.EndsWith(comp, StringComparison.OrdinalIgnoreCase));\r\n                    matches.AddMissing(match);\r\n                }\r\n                else\r\n                {\r\n                    throw new Exception(\"Uknown file exclusion configuration.\");\r\n                }\r\n            }\r\n\r\n            return matches;\r\n        }\r\n\r\n        public static List<string> GetDirectoryExclusionMatches(List<string> dirs, List<ScanExclusion> exclusions)\r\n        {\r\n            var matches = new List<string>();\r\n            foreach (var excDir in exclusions)\r\n            {\r\n                if (excDir.MatchByRegex)\r\n                {\r\n                    // exclusion parser already appends root path if needed so same match can be done here\r\n                    // for any level match and absolute path match\r\n                    var match = dirs.Where(a => Regex.IsMatch(a.TrimEnd(Paths.DirectorySeparators), excDir.Path, RegexOptions.IgnoreCase));\r\n                    matches.AddMissing(match);\r\n                }\r","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Emulators/Scanner.cs#L465-L501","documentation":"Thrown as a dead-code defensive guard in GetFileExclusionMatches. Because the preceding branches are if(MatchByRegex) / else if(Absolute) / else if(!Absolute), the final else is logically unreachable — every ScanExclusion is either absolute or not. This throw exists to catch a logic regression rather than a real runtime input; it fires only if the Absolute flag semantics become non-boolean or branch ordering is broken.","triggerScenarios":"Theoretically unreachable for any boolean Absolute value: the !Absolute branch (line 475) already covers the false case, so the trailing else can never evaluate. Would only trigger if Absolute were changed to a nullable/non-bool type or the branch conditions were reordered incorrectly.","commonSituations":"Not hit in normal operation. A maintainer refactoring the exclusion logic could accidentally make it reachable; otherwise it is vestigial defensive code.","solutions":["No action needed for callers — this branch is unreachable with boolean Absolute.","If encountered during development, audit recent edits to ScanExclusion.Absolute and the if/else chain ordering in GetFileExclusionMatches.","Consider removing the dead branch or converting it to an assertion to clarify intent."],"exampleFix":"// before\nelse if (!excFile.Absolute) { ... }\nelse { throw new Exception(\"Uknown file exclusion configuration.\"); }\n\n// after — collapse the redundant else-if into a final else\nelse { var comp = excFile.Path.PrefixWithDirSeparator(); matches.AddMissing(files.Where(a => a.EndsWith(comp, StringComparison.OrdinalIgnoreCase))); }","handlingStrategy":"validation","validationCode":"// Unreachable for boolean Absolute; no caller validation needed. For safety, assert the type.\nDebug.Assert(excFile.Absolute is bool, \"ScanExclusion.Absolute must be boolean\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat this branch as dead code during reviews; it indicates a logic bug if hit.","Keep ScanExclusion.Absolute as a non-nullable boolean.","Add a unit test asserting every combination of (MatchByRegex, Absolute) is handled by an earlier branch."],"tags":["emulator","scanner","dead-code","exclusion"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}