UNPKG

mcp-server-semgrep

Version:

MCP Server for Semgrep Integration - static code analysis with AI

34 lines (33 loc) 1.23 kB
rules: - id: correctness-double-epsilon-equality patterns: - pattern: | $V1 - $V2 - pattern-either: - pattern-inside: | ... <= Double.Epsilon - pattern-inside: | Double.Epsilon <= ... - pattern-not-inside: | double $V1 = 0; ... - pattern-not-inside: | double $V2 = 0; ... - pattern-not-inside: | $V1 = 0; ... - pattern-not-inside: | $V2 = 0; ... message: Double.Epsilon is defined by .NET as the smallest value that can be added to or subtracted from a zero-value Double. It is unsuitable for equality comparisons of non-zero Double values. Furthermore, the value of Double.Epsilon is framework and processor architecture dependent. Wherever possible, developers should prefer the framework Equals() method over custom equality implementations. languages: [csharp] severity: WARNING metadata: references: - https://docs.microsoft.com/en-us/dotnet/api/system.double?view=net-6.0#testing-for-equality - https://docs.microsoft.com/en-us/dotnet/api/system.double.epsilon?view=net-6.0#platform-notes category: correctness technology: - .net confidence: MEDIUM