To check is a string contains a sub-string, use Contains() and do not use proxy functions such as IndexOf.
Non-Compliant Code Examples
classMyClass{publicstaticvoidprocessString(strings){if(strings.IndexOf(s)==-1){// do something}if(strings.IndexOf(s)<0){// do something else}if(strings.IndexOf(s)>=0){// or do this}}}
Compliant Code Examples
classMyClass{publicstaticvoidprocessString(strings){if(!strings.Contains(s)){// do something}}}
シームレスな統合。 Datadog Code Security をお試しください
Datadog Code Security
このルールを試し、Datadog Code Security でコードを解析する
このルールの使用方法
1
2
rulesets:- csharp-best-practices # Rules to enforce C# best practices.