A static method that only computes a value, such as Math.Max or Path.Combine, is called and its result dropped
What it finds
The methods of Math and MathF, the path functions of Path, string.Format, string.Join and string.Concat, and the factories of TimeSpan and Guid have no effect besides their result. A call whose result is dropped does nothing, which usually means that an assignment was forgotten.
From the rule's source, ignored_pure_call.rs.
using System;using System.IO; class Files{ string Locate(string dir, int a, int b) { Math.Max(a, b);tx0 reports: the result of Math.Max is dropped, so the call does nothing Path.Combine(dir, "x");tx0 reports: the result of Path.Combine is dropped, so the call does nothing Console.WriteLine(dir); return Path.Combine(dir, "y"); }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/csharp:ignored-pure-call" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:ignored-pure-call] reason="..."tx0 explain tx0/csharp:ignored-pure-call shows the same in the terminal. Found a false positive? Report it.