bound analyzer

Made by DeepSource

Categories

Programming language

Latest version

v0.50.1

Updated on

Jul 20, 2024


Total issues

303

Autofix

97

Sample configuration

version = 1

[[analyzers]]
name = "csharp"

Stats


Anti-pattern

146

Bug risk

101

Documentation

1

Performance

27

Security

28

Issues


View all
Use Guid.Empty to create an empty GUID CS-R1007
Anti-pattern
Autofix

new SomeClass() is the syntax to instantiate a class in C#. However, new Guid() does not generate a new GUID. It instead returns an empty GUID. If you intend to use an empty GUID, consider using Guid.Empty as it is more straightforward to comprehend. If you wish to generate a new usable GUID, consider using Guid.NewGuid().

ToString method should never return null CS-R1011
Anti-pattern

The ToString method should return a string that best represents your class/object. Returning null from such a method does not make any sense and is therefore recommended that you refactor this method to return a more suitable and appropriate representation.

Obsolete attribute should specify the message CS-R1016
Anti-pattern

Obsolete attribute allows you to mark certain entities as obsolete, thereby discouraging users from using them. However, to convey the full context, it is recommended that you specify the obsolete-message/description. Failing to do so produces a blank line/empty string during the build process and can cause confusion.

Use StringComparison.OrdinalIgnoreCase for case insensitive comparisons CS-R1017
Anti-pattern

While converting strings to lower/upper case and then comparing might work to perform a case insensitive comparison, the safer, reliable, and performant alternative is to invoke the string.Equals method while specifying the StringComparison.OrdinalIgnoreCase enum.

Consider simplifying the element access CS-R1019
Anti-pattern
Autofix

Individual elements in a string or an array can be accessed via the bracketed expression. The norm for accessing elements from last is usually in the format of foo[ub - i] where ub is the upper bound and i is an index. This expression however can be simplified and rewritten as foo[^i].