jellyfin.ruleset 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RuleSet Name="Rules for Jellyfin.Server" Description="Code analysis rules for Jellyfin.Server.csproj" ToolsVersion="14.0">
  3. <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
  4. <!-- error on SA1000: The keyword 'new' should be followed by a space -->
  5. <Rule Id="SA1000" Action="Error" />
  6. <!-- error on SA1001: Commas should not be preceded by whitespace -->
  7. <Rule Id="SA1001" Action="Error" />
  8. <!-- error on SA1106: Code should not contain empty statements -->
  9. <Rule Id="SA1106" Action="Error" />
  10. <!-- error on SA1107: Code should not contain multiple statements on one line -->
  11. <Rule Id="SA1107" Action="Error" />
  12. <!-- error on SA1028: Code should not contain trailing whitespace -->
  13. <Rule Id="SA1028" Action="Error" />
  14. <!-- error on SA1117: The parameters should all be placed on the same line or each parameter should be placed on its own line -->
  15. <Rule Id="SA1117" Action="Error" />
  16. <!-- error on SA1137: Elements should have the same indentation -->
  17. <Rule Id="SA1137" Action="Error" />
  18. <!-- error on SA1142: Refer to tuple fields by name -->
  19. <Rule Id="SA1142" Action="Error" />
  20. <!-- error on SA1210: Using directives should be ordered alphabetically by the namespaces -->
  21. <Rule Id="SA1210" Action="Error" />
  22. <!-- error on SA1316: Tuple element names should use correct casing -->
  23. <Rule Id="SA1316" Action="Error" />
  24. <!-- error on SA1414: Tuple types in signatures should have element names -->
  25. <Rule Id="SA1414" Action="Error" />
  26. <!-- disable warning SA1513: Closing brace should be followed by blank line -->
  27. <Rule Id="SA1513" Action="Error" />
  28. <!-- error on SA1518: File is required to end with a single newline character -->
  29. <Rule Id="SA1518" Action="Error" />
  30. <!-- error on SA1629: Documentation text should end with a period -->
  31. <Rule Id="SA1629" Action="Error" />
  32. <!-- disable warning SA1009: Closing parenthesis should be followed by a space. -->
  33. <Rule Id="SA1009" Action="None" />
  34. <!-- disable warning SA1011: Closing square bracket should be followed by a space. -->
  35. <Rule Id="SA1011" Action="None" />
  36. <!-- disable warning SA1101: Prefix local calls with 'this.' -->
  37. <Rule Id="SA1101" Action="None" />
  38. <!-- disable warning SA1108: Block statements should not contain embedded comments -->
  39. <Rule Id="SA1108" Action="None" />
  40. <!-- disable warning SA1118: Parameter must not span multiple lines. -->
  41. <Rule Id="SA1118" Action="None" />
  42. <!-- disable warning SA1128:: Put constructor initializers on their own line -->
  43. <Rule Id="SA1128" Action="None" />
  44. <!-- disable warning SA1130: Use lambda syntax -->
  45. <Rule Id="SA1130" Action="None" />
  46. <!-- disable warning SA1200: 'using' directive must appear within a namespace declaration -->
  47. <Rule Id="SA1200" Action="None" />
  48. <!-- disable warning SA1202: 'public' members must come before 'private' members -->
  49. <Rule Id="SA1202" Action="None" />
  50. <!-- disable warning SA1204: Static members must appear before non-static members -->
  51. <Rule Id="SA1204" Action="None" />
  52. <!-- disable warning SA1309: Fields must not begin with an underscore -->
  53. <Rule Id="SA1309" Action="None" />
  54. <!-- disable warning SA1311: Static readonly fields should begin with upper-case letter -->
  55. <Rule Id="SA1311" Action="None" />
  56. <!-- disable warning SA1413: Use trailing comma in multi-line initializers -->
  57. <Rule Id="SA1413" Action="None" />
  58. <!-- disable warning SA1512: Single-line comments must not be followed by blank line -->
  59. <Rule Id="SA1512" Action="None" />
  60. <!-- disable warning SA1515: Single-line comment should be preceded by blank line -->
  61. <Rule Id="SA1515" Action="None" />
  62. <!-- disable warning SA1600: Elements should be documented -->
  63. <Rule Id="SA1600" Action="None" />
  64. <!-- disable warning SA1601: Partial elements should be documented -->
  65. <Rule Id="SA1601" Action="None" />
  66. <!-- disable warning SA1602: Enumeration items should be documented -->
  67. <Rule Id="SA1602" Action="None" />
  68. <!-- disable warning SA1633: The file header is missing or not located at the top of the file -->
  69. <Rule Id="SA1633" Action="None" />
  70. </Rules>
  71. <Rules AnalyzerId="Microsoft.CodeAnalysis.NetAnalyzers" RuleNamespace="Microsoft.Design">
  72. <!-- error on CA1001: Types that own disposable fields should be disposable -->
  73. <Rule Id="CA1001" Action="Error" />
  74. <!-- error on CA1012: Abstract types should not have public constructors -->
  75. <Rule Id="CA1012" Action="Error" />
  76. <!-- error on CA1063: Implement IDisposable correctly -->
  77. <Rule Id="CA1063" Action="Error" />
  78. <!-- error on CA1305: Specify IFormatProvider -->
  79. <Rule Id="CA1305" Action="Error" />
  80. <!-- error on CA1307: Specify StringComparison for clarity -->
  81. <Rule Id="CA1307" Action="Error" />
  82. <!-- error on CA1309: Use ordinal StringComparison -->
  83. <Rule Id="CA1309" Action="Error" />
  84. <!-- error on CA1310: Specify StringComparison for correctness -->
  85. <Rule Id="CA1310" Action="Error" />
  86. <!-- error on CA1513: Use 'ObjectDisposedException.ThrowIf' instead of explicitly throwing a new exception instance -->
  87. <Rule Id="CA1513" Action="Error" />
  88. <!-- error on CA1725: Parameter names should match base declaration -->
  89. <Rule Id="CA1725" Action="Error" />
  90. <!-- error on CA1725: Call async methods when in an async method -->
  91. <Rule Id="CA1727" Action="Error" />
  92. <!-- error on CA1813: Avoid unsealed attributes -->
  93. <Rule Id="CA1813" Action="Error" />
  94. <!-- error on CA1834: Use 'StringBuilder.Append(char)' instead of 'StringBuilder.Append(string)' when the input is a constant unit string -->
  95. <Rule Id="CA1834" Action="Error" />
  96. <!-- error on CA1843: Do not use 'WaitAll' with a single task -->
  97. <Rule Id="CA1843" Action="Error" />
  98. <!-- error on CA1845: Use span-based 'string.Concat' -->
  99. <Rule Id="CA1845" Action="Error" />
  100. <!-- error on CA1849: Call async methods when in an async method -->
  101. <Rule Id="CA1849" Action="Error" />
  102. <!-- error on CA1851: Possible multiple enumerations of IEnumerable collection -->
  103. <Rule Id="CA1851" Action="Error" />
  104. <!-- error on CA1854: Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup -->
  105. <Rule Id="CA1854" Action="Error" />
  106. <!-- error on CA1860: Avoid using 'Enumerable.Any()' extension method -->
  107. <Rule Id="CA1860" Action="Error" />
  108. <!-- error on CA1862: Use the 'StringComparison' method overloads to perform case-insensitive string comparisons -->
  109. <Rule Id="CA1862" Action="Error" />
  110. <!-- error on CA1863: Use 'CompositeFormat' -->
  111. <Rule Id="CA1863" Action="Error" />
  112. <!-- error on CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method -->
  113. <Rule Id="CA1864" Action="Error" />
  114. <!-- error on CA1865-CA1867: Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char -->
  115. <Rule Id="CA1865" Action="Error" />
  116. <Rule Id="CA1866" Action="Error" />
  117. <Rule Id="CA1867" Action="Error" />
  118. <!-- error on CA1868: Unnecessary call to 'Contains' for sets -->
  119. <Rule Id="CA1868" Action="Error" />
  120. <!-- error on CA1869: Cache and reuse 'JsonSerializerOptions' instances -->
  121. <Rule Id="CA1869" Action="Error" />
  122. <!-- error on CA1870: Use a cached 'SearchValues' instance -->
  123. <Rule Id="CA1870" Action="Error" />
  124. <!-- error on CA1871: Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull' -->
  125. <Rule Id="CA1871" Action="Error" />
  126. <!-- error on CA1872: Prefer 'Convert.ToHexString' and 'Convert.ToHexStringLower' over call chains based on 'BitConverter.ToString' -->
  127. <Rule Id="CA1872" Action="Error" />
  128. <!-- error on CA2016: Forward the CancellationToken parameter to methods that take one
  129. or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token -->
  130. <Rule Id="CA2016" Action="Error" />
  131. <!-- error on CA2201: Exception type System.Exception is not sufficiently specific -->
  132. <Rule Id="CA2201" Action="Error" />
  133. <!-- error on CA2215: Dispose methods should call base class dispose -->
  134. <Rule Id="CA2215" Action="Error" />
  135. <!-- error on CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability -->
  136. <Rule Id="CA2249" Action="Error" />
  137. <!-- error on CA2254: Template should be a static expression -->
  138. <Rule Id="CA2254" Action="Error" />
  139. <!-- disable warning CA1014: Mark assemblies with CLSCompliantAttribute -->
  140. <Rule Id="CA1014" Action="Info" />
  141. <!-- disable warning CA1024: Use properties where appropriate -->
  142. <Rule Id="CA1024" Action="Info" />
  143. <!-- disable warning CA1031: Do not catch general exception types -->
  144. <Rule Id="CA1031" Action="Info" />
  145. <!-- disable warning CA1032: Implement standard exception constructors -->
  146. <Rule Id="CA1032" Action="Info" />
  147. <!-- disable warning CA1040: Avoid empty interfaces -->
  148. <Rule Id="CA1040" Action="Info" />
  149. <!-- disable warning CA1062: Validate arguments of public methods -->
  150. <Rule Id="CA1062" Action="Info" />
  151. <!-- TODO: enable when false positives are fixed -->
  152. <!-- disable warning CA1508: Avoid dead conditional code -->
  153. <Rule Id="CA1508" Action="Info" />
  154. <!-- disable warning CA1515: Consider making public types internal -->
  155. <Rule Id="CA1515" Action="Info" />
  156. <!-- disable warning CA1716: Identifiers should not match keywords -->
  157. <Rule Id="CA1716" Action="Info" />
  158. <!-- disable warning CA1720: Identifiers should not contain type names -->
  159. <Rule Id="CA1720" Action="Info" />
  160. <!-- disable warning CA1724: Type names should not match namespaces -->
  161. <Rule Id="CA1724" Action="Info" />
  162. <!-- disable warning CA1805: Do not initialize unnecessarily -->
  163. <Rule Id="CA1805" Action="Info" />
  164. <!-- disable warning CA1812: internal class that is apparently never instantiated.
  165. If so, remove the code from the assembly.
  166. If this class is intended to contain only static members, make it static -->
  167. <Rule Id="CA1812" Action="Info" />
  168. <!-- disable warning CA1822: Member does not access instance data and can be marked as static -->
  169. <Rule Id="CA1822" Action="Info" />
  170. <!-- CA1859: Use concrete types when possible for improved performance -->
  171. <Rule Id="CA1859" Action="Info" />
  172. <!-- TODO: Enable -->
  173. <!-- CA1861: Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array -->
  174. <Rule Id="CA1861" Action="Info" />
  175. <!-- disable warning CA2000: Dispose objects before losing scope -->
  176. <Rule Id="CA2000" Action="Info" />
  177. <!-- disable warning CA2253: Named placeholders should not be numeric values -->
  178. <Rule Id="CA2253" Action="Info" />
  179. <!-- disable warning CA5394: Do not use insecure randomness -->
  180. <Rule Id="CA5394" Action="Info" />
  181. <!-- error on CA3003: Review code for file path injection vulnerabilities -->
  182. <Rule Id="CA3003" Action="Info" />
  183. <!-- error on CA3006: Review code for process command injection vulnerabilities -->
  184. <Rule Id="CA3006" Action="Info" />
  185. <!-- disable warning CA1054: Change the type of parameter url from string to System.Uri -->
  186. <Rule Id="CA1054" Action="None" />
  187. <!-- disable warning CA1055: URI return values should not be strings -->
  188. <Rule Id="CA1055" Action="None" />
  189. <!-- disable warning CA1056: URI properties should not be strings -->
  190. <Rule Id="CA1056" Action="None" />
  191. <!-- disable warning CA1303: Do not pass literals as localized parameters -->
  192. <Rule Id="CA1303" Action="None" />
  193. <!-- disable warning CA1308: Normalize strings to uppercase -->
  194. <Rule Id="CA1308" Action="None" />
  195. <!-- disable warning CA1848: Use the LoggerMessage delegates -->
  196. <Rule Id="CA1848" Action="None" />
  197. <!-- disable warning CA2101: Specify marshaling for P/Invoke string arguments -->
  198. <Rule Id="CA2101" Action="None" />
  199. <!-- disable warning CA2234: Pass System.Uri objects instead of strings -->
  200. <Rule Id="CA2234" Action="None" />
  201. </Rules>
  202. <Rules AnalyzerId="Microsoft.CodeAnalysis.BannedApiAnalyzers" RuleNamespace="Microsoft.Design">
  203. <!-- error on RS0030: Do not used banned APIs -->
  204. <Rule Id="RS0030" Action="Error" />
  205. </Rules>
  206. <Rules AnalyzerId="IDisposableAnalyzers" RuleNamespace="IDisposableAnalyzers.Correctness">
  207. <!-- disable warning IDISP001: Dispose created -->
  208. <Rule Id="IDISP001" Action="Info" />
  209. <!-- TODO: Enable when false positives are fixed -->
  210. <!-- disable warning IDISP003: Dispose previous before re-assigning -->
  211. <Rule Id="IDISP003" Action="Info" />
  212. <!-- disable warning IDISP004: Don't ignore created IDisposable -->
  213. <Rule Id="IDISP004" Action="Info" />
  214. <!-- disable warning IDISP007: Don't dispose injected -->
  215. <Rule Id="IDISP007" Action="Info" />
  216. <!-- disable warning IDISP008: Don't assign member with injected and created disposables -->
  217. <Rule Id="IDISP008" Action="Info" />
  218. </Rules>
  219. </RuleSet>