You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public void Method(List<int> list)
{
foreach (var element in list) { } // FN - list is not checked for null before the GetEnumerator() method is called on it
}
FN: referencing delegates
public void ConvertUsing(ITypeConverter<TSource, TDestination> converter)
{
ConvertUsing(converter.Convert);
}
FN: most likely related to the conditional operator
public static void ShouldHaveRedirectedTo(this BrowserResponse response, string location, StringComparison stringComparer = StringComparison.Ordinal)
{
var validRedirectStatuses = new[]
{
HttpStatusCode.MovedPermanently,
HttpStatusCode.SeeOther,
HttpStatusCode.TemporaryRedirect
};
if (!validRedirectStatuses.Any(x => x == response.StatusCode)) // FN here due to lambda
{
throw new AssertException(
string.Format("Status code should be one of 'MovedPermanently, SeeOther, TemporaryRedirect', but was {0}.", response.StatusCode));
}
if (!response.Headers["Location"].Equals(location, stringComparer)) // TP considering the lambda not being supported
{
throw new AssertException(string.Format("Location should have been: {0}, but was {1}", location, response.Headers["Location"])); // FP here, the `if` should have learned NotNull
}
}
FP: parameter is assigned a new value or passed to a method as reference before being dereferenced
public void Assignment(object o)
{
o = Create();
o.ToString(); // should not raise
}
public void Deconstruction(object o)
{
(o, _) = (Create(), _);
o.ToString(); // FP
}
public void RefParam(object o)
{
MethodWithRefParam(ref o);
o.ToString(); // FP
}
public void OutParam(object o)
{
MethodWithOutParam(out o);
o.ToString(); // FP
}
private static object Create() => new object();
private static void MethodWithRefParam(ref object obj) { }
private static void MethodWithOutParam(out object obj) { obj = new object(); }
FN: member access after cast operation
public static ActorSelection ActorSelection(string path, ActorSystem system, IActorRef lookupRoot)
{
var provider = ((ActorSystemImpl)system).Provider; // FN
}
FP: inside lambda
Lambda can see ParameterReferenceOperation from outer CFG. And we should not raise when this happens.
public override object RegisterExtension(IExtensionId extension)
{
if (extension == null) return null;
_extensions.GetOrAdd(extension.ExtensionType, t => new Lazy<object>(() => extension.CreateExtension(this), LazyThreadSafetyMode.ExecutionAndPublication)); // FP
return extension.Get(this);
}
FP: is operator
public static bool CanBeSet(this MemberInfo member) => member is PropertyInfo property ? property.CanWrite : !((FieldInfo)member).IsInitOnly;
Issue message: the rule should raise an issue with the message Refactor this constructor to avoid using members of parameter 'paramName' because it could be null. if the parameter is dereferenced inside the call to the base class constructor. If it's dereferenced inside the body of the constructor then the message should be the regular Refactor this method to add validation of parameter 'paramName' before using it.
public class DerivedClass: BaseClass
{
public DerivedClass(object o1, object o2): base(o1.ToString()) // Noncompliant {{Refactor this constructor to avoid using members of parameter 'o1' because it could be null.}}
{
o2.ToString(); // Noncompliant {{Refactor this method to add validation of parameter 'o2' before using it.}}
}
}
The text was updated successfully, but these errors were encountered:
This is a problem with LVA and Captures. New issue was created in Fix S3900 FP: Don't raise if parameter is captured #7060
Object.ReferenceEquals
This is a problem with LVA and Captures. New issue was created in Fix S3900 FP: Don't raise if parameter is captured #7060
Lambda can see
ParameterReferenceOperation
from outer CFG. And we should not raise when this happens.Refactor this constructor to avoid using members of parameter 'paramName' because it could be null.
if the parameter is dereferenced inside the call to the base class constructor. If it's dereferenced inside the body of the constructor then the message should be the regularRefactor this method to add validation of parameter 'paramName' before using it.
The text was updated successfully, but these errors were encountered: