Skip to content

Fix S2857 FP: Rule is not checking SQL keywords in const interepolated string #6633

@cristian-ambrosini-sonarsource

Description

Description

S2857 fail to check for SQL keywords inside a:

  • constant interpolated string:
  • interpolated string with nameof expression
using System.Data.SqlClient;

public void MyMethod(string unknownValue)
{
  const string One = "One";
  const string myString = $"{One}Two"; // Noncompliant FP
  const string myString1 = $"{nameof(One)}Two"; // Noncompliant FP
  string myString2 = $"{nameof(unknownValue)}Two"; // Noncompliant FP
}

Metadata

Metadata

Labels

False PositiveRule IS triggered when it shouldn't be.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions