rspec/rules/S3949/csharp/rule.adoc

33 lines
894 B
Plaintext
Raw Normal View History

2020-06-30 12:48:39 +02:00
Numbers are infinite, but the types that hold them are not. Each numeric type has hard upper and lower bounds. Try to calculate or assign numbers beyond those bounds, and the result will be a value that has silently wrapped around from the expected positive value to a negative one, or vice versa.
2021-02-02 15:02:10 +01:00
2020-06-30 12:48:39 +02:00
This rule is only available for analyses run on Windows machines. It will not be reported in analyses run on any other OS.
== Noncompliant Code Example
----
public int getTheNumber(int val) {
if (val <= 0) {
return val;
}
int num = int.MaxValue;
return num + val; // Noncompliant
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]